Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
#include <ztest.h>
Macros | |
#define | TIMEOUT 500 |
#define | STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) |
#define | THREAD_HIGH_PRIORITY 1 |
#define | THREAD_MID_PRIORITY 3 |
#define | THREAD_LOW_PRIORITY 5 |
Variables | |
static ZTEST_DMEM int | case_type |
static ZTEST_DMEM int | thread_ret = TC_FAIL |
static struct k_mutex | mutex |
static struct k_thread | tdata |
static struct k_thread | tdata2 |
static struct k_thread | tdata3 |
#define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) |
#define THREAD_HIGH_PRIORITY 1 |
#define THREAD_LOW_PRIORITY 5 |
#define THREAD_MID_PRIORITY 3 |
#define TIMEOUT 500 |
K_MUTEX_DEFINE | ( | kmutex | ) |
TESTPOINT: init via K_MUTEX_DEFINE
|
static |
|
static |
|
static |
TESTPOINT: test k_mutex_init mutex
TESTPOINT: test K_MUTEX_DEFINE mutex
Test mutex's priority inheritance mechanism.
To verify mutex provide priority inheritance to prevent prority inversion, and there are 3 cases need to run. The thread T1 hold the mutex first and cases list as below:
TESTPOINT: run test case 1, given priority T1 < T2
TESTPOINT: The current thread does not own the mutex.
TESTPOINT: run test case 2, given priority T1 > T2, this means priority inheritance won't happen.
TESTPOINT: run test case 3, given priority T1 < T3 < T2, but t2 do not get mutex due to timeout.
Test recursive mutex.
To verify that getting a lock of a mutex already locked will succeed and waiters will be unblocked only when the number of locks reaches zero.
TESTPOINT: when mutex has no owner, we cannot unlock it
TESTPOINT: lock the mutex recursively
TESTPOINT: unlock the mutex recursively
TESTPOINT: waiter thread got the mutex
TESTPOINT: test k_mutex_init mutex
TESTPOINT: test K_MUTEX_DEFINE mutex
TESTPOINT: test k_mutex_init mutex
TESTPOINT: test K_MUTEX_DEFINE mutex
TESTPOINT: test k_mutex_init mutex
TESTPOINT: test K_MUTEX_DEFINE mutex
TESTPOINT: test k_mutex_init mutex
TESTPOINT: test K_MUTEX_DEFINE mutex
|
static |
|
static |
TESTPOINT: test k_mutex_init mutex
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |