Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
Offload to the Kernel workqueue. More...
Macros | |
#define | NUM_MILLISECONDS 50 |
#define | TEST_TIMEOUT 200 |
#define | OFFLOAD_WORKQUEUE_STACK_SIZE 1024 |
#define | STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) |
Functions | |
static | K_THREAD_STACK_DEFINE (offload_work_q_stack, 1024) |
static | K_THREAD_STACK_DEFINE (stack1,(1024+CONFIG_TEST_EXTRA_STACK_SIZE)) |
static | K_THREAD_STACK_DEFINE (stack2,(1024+CONFIG_TEST_EXTRA_STACK_SIZE)) |
K_SEM_DEFINE (ALT_SEM, 0, UINT_MAX) | |
K_SEM_DEFINE (REGRESS_SEM, 0, UINT_MAX) | |
K_SEM_DEFINE (TEST_SEM, 0, UINT_MAX) | |
void | critical_rtn (struct k_work *unused) |
Routine to be called from a workqueue. | |
uint32_t | critical_loop (const char *tag, uint32_t count) |
Common code for invoking work. | |
void | alternate_thread (void *arg1, void *arg2, void *arg3) |
Alternate thread. | |
void | regression_thread (void *arg1, void *arg2, void *arg3) |
Regression thread. | |
ZTEST (kernel_offload_wq, test_offload_workqueue) | |
Verify thread context. | |
ZTEST_SUITE (kernel_offload_wq, NULL, NULL, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL) | |
Variables | |
static uint32_t | critical_var |
static uint32_t | alt_thread_iterations |
static struct k_work_q | offload_work_q |
static struct k_thread | thread1 |
static struct k_thread | thread2 |
Offload to the Kernel workqueue.
This test verifies that the kernel workqueue operates as expected.
This test has two threads that increment a counter. The routine that increments the counter is invoked from workqueue due to the two threads calling using it. The final result of the counter is expected to be the number of times work item was called to increment the counter.
This is done with time slicing both disabled and enabled to ensure that the result always matches the number of times the workqueue is called.
#define NUM_MILLISECONDS 50 |
#define OFFLOAD_WORKQUEUE_STACK_SIZE 1024 |
#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) |
#define TEST_TIMEOUT 200 |
void alternate_thread | ( | void * | arg1, |
void * | arg2, | ||
void * | arg3 | ||
) |
Alternate thread.
This routine invokes the workqueue many times.
Common code for invoking work.
tag | text identifying the invocation context |
count | number of critical section calls made thus far |
void critical_rtn | ( | struct k_work * | unused | ) |
Routine to be called from a workqueue.
This routine increments the global variable critical_var.
K_SEM_DEFINE | ( | ALT_SEM | , |
0 | , | ||
UINT_MAX | |||
) |
K_SEM_DEFINE | ( | REGRESS_SEM | , |
0 | , | ||
UINT_MAX | |||
) |
K_SEM_DEFINE | ( | TEST_SEM | , |
0 | , | ||
UINT_MAX | |||
) |
|
static |
|
static |
|
static |
void regression_thread | ( | void * | arg1, |
void * | arg2, | ||
void * | arg3 | ||
) |
Regression thread.
This routine invokes the workqueue many times. It also checks to ensure that the number of times it is called matches the global variable critical_var.
ZTEST_SUITE | ( | kernel_offload_wq | , |
NULL | , | ||
NULL | , | ||
ztest_simple_1cpu_before | , | ||
ztest_simple_1cpu_after | , | ||
NULL | |||
) |
|
static |
|
static |
|
static |
|
static |
|
static |