Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
main.c File Reference
#include <zephyr/tc_util.h>
#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <ksched.h>
#include <ipi.h>
#include <zephyr/kernel_structs.h>

Macros

#define STACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define NUM_THREADS   (CONFIG_MP_MAX_NUM_CPUS - 1)
 
#define DELAY_FOR_IPIS   200
 

Functions

static K_THREAD_STACK_ARRAY_DEFINE (stack,(CONFIG_MP_MAX_NUM_CPUS - 1),(1024+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (alt_stack,(1024+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_SEM_DEFINE (sem, 0, 1)
 
static void clear_ipi_counts (void)
 
static void get_ipi_counts (uint32_t *set, size_t n_elem)
 
static void busy_thread_entry (void *p1, void *p2, void *p3)
 
static bool wait_until_busy_threads_ready (uint32_t id)
 
static void pending_thread_entry (void *p1, void *p2, void *p3)
 
static void alt_thread_create (int priority, const char *desc)
 
uint32_t busy_threads_create (int priority)
 
void busy_threads_priority_set (int priority, int delta)
 
 ZTEST (ipi, test_arch_sched_broadcast_ipi)
 Verify that arch_sched_broadcast_ipi() broadcasts IPIs as expected.
 
 ZTEST (ipi, test_low_thread_wakes_no_ipis)
 Verify that waking a thread whose priority is lower than any other currently executing thread does not result in any IPIs being sent.
 
 ZTEST (ipi, test_high_thread_wakes_some_ipis)
 Verify that waking a thread whose priority is higher than all currently executing threads results in the proper IPIs being sent and processed.
 
 ZTEST (ipi, test_thread_priority_set_lower)
 Verify that lowering the priority of an active thread results in an IPI.
 
 ZTEST (ipi, test_thread_coop_no_ipis)
 
static void * ipi_tests_setup (void)
 
static void cleanup_threads (void *fixture)
 
 ZTEST_SUITE (ipi, NULL, ipi_tests_setup, NULL, cleanup_threads, NULL)
 

Variables

static struct k_thread thread [(CONFIG_MP_MAX_NUM_CPUS - 1)]
 
static struct k_thread alt_thread
 
static bool alt_thread_created
 
static uint32_t ipi_count [CONFIG_MP_MAX_NUM_CPUS]
 
static struct k_spinlock ipilock
 
static atomic_t busy_started
 
static volatile bool alt_thread_done
 

Macro Definition Documentation

◆ DELAY_FOR_IPIS

#define DELAY_FOR_IPIS   200

◆ NUM_THREADS

#define NUM_THREADS   (CONFIG_MP_MAX_NUM_CPUS - 1)

◆ STACK_SIZE

#define STACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

Function Documentation

◆ alt_thread_create()

static void alt_thread_create ( int  priority,
const char *  desc 
)
static

◆ busy_thread_entry()

static void busy_thread_entry ( void *  p1,
void *  p2,
void *  p3 
)
static

◆ busy_threads_create()

uint32_t busy_threads_create ( int  priority)

◆ busy_threads_priority_set()

void busy_threads_priority_set ( int  priority,
int  delta 
)

◆ cleanup_threads()

static void cleanup_threads ( void *  fixture)
static

◆ clear_ipi_counts()

static void clear_ipi_counts ( void  )
static

◆ get_ipi_counts()

static void get_ipi_counts ( uint32_t set,
size_t  n_elem 
)
static

◆ ipi_tests_setup()

static void * ipi_tests_setup ( void  )
static

◆ K_SEM_DEFINE()

static K_SEM_DEFINE ( sem  ,
,
 
)
static

◆ K_THREAD_STACK_ARRAY_DEFINE()

static K_THREAD_STACK_ARRAY_DEFINE ( stack  ,
(CONFIG_MP_MAX_NUM_CPUS - 1)  ,
(1024+CONFIG_TEST_EXTRA_STACK_SIZE)   
)
static

◆ K_THREAD_STACK_DEFINE()

static K_THREAD_STACK_DEFINE ( alt_stack  ,
(1024+CONFIG_TEST_EXTRA_STACK_SIZE)   
)
static

◆ pending_thread_entry()

static void pending_thread_entry ( void *  p1,
void *  p2,
void *  p3 
)
static

◆ wait_until_busy_threads_ready()

static bool wait_until_busy_threads_ready ( uint32_t  id)
static

◆ ZTEST() [1/5]

ZTEST ( ipi  ,
test_arch_sched_broadcast_ipi   
)

Verify that arch_sched_broadcast_ipi() broadcasts IPIs as expected.

◆ ZTEST() [2/5]

ZTEST ( ipi  ,
test_high_thread_wakes_some_ipis   
)

Verify that waking a thread whose priority is higher than all currently executing threads results in the proper IPIs being sent and processed.

◆ ZTEST() [3/5]

ZTEST ( ipi  ,
test_low_thread_wakes_no_ipis   
)

Verify that waking a thread whose priority is lower than any other currently executing thread does not result in any IPIs being sent.

◆ ZTEST() [4/5]

ZTEST ( ipi  ,
test_thread_coop_no_ipis   
)

◆ ZTEST() [5/5]

ZTEST ( ipi  ,
test_thread_priority_set_lower   
)

Verify that lowering the priority of an active thread results in an IPI.

If directed IPIs are enabled, then only the CPU executing that active thread ought to receive the IPI. Otherwise if IPIs are broadcast, then all other CPUs save the current CPU ought to receive IPIs.

◆ ZTEST_SUITE()

ZTEST_SUITE ( ipi  ,
NULL  ,
ipi_tests_setup  ,
NULL  ,
cleanup_threads  ,
NULL   
)

Variable Documentation

◆ alt_thread

struct k_thread alt_thread
static

◆ alt_thread_created

bool alt_thread_created
static

◆ alt_thread_done

volatile bool alt_thread_done
static

◆ busy_started

atomic_t busy_started
static

◆ ipi_count

uint32_t ipi_count[CONFIG_MP_MAX_NUM_CPUS]
static

◆ ipilock

struct k_spinlock ipilock
static

◆ thread

struct k_thread thread[(CONFIG_MP_MAX_NUM_CPUS - 1)]
static