distortos  v0.5.0
object-oriented C++ RTOS for microcontrollers
distortos::test::anonymous_namespace{MutexPriorityInheritanceOperationsTestCase.cpp} Namespace Reference

Classes

class  LockThread
 
class  TryLockForThread
 

Functions

bool testBasicPriorityInheritance (const Mutex::Type type)
 Tests basic priority inheritance mechanism of mutexes with PriorityInheritance protocol. More...
 
bool testCanceledLock (const Mutex::Type type)
 Tests behavior of priority inheritance mechanism of mutexes in the event of canceled (timed-out) lock attempt. More...
 
bool testPriorityChange (const Mutex::Type type)
 Tests behavior of priority inheritance mechanism of mutexes in the event of priority change. More...
 

Variables

constexpr uint8_t testThreadPriority {MutexPriorityInheritanceOperationsTestCase::getTestCasePriority()}
 priority of current test thread More...
 
constexpr size_t testThreadStackSize {512}
 size of stack for test thread, bytes More...
 

Function Documentation

◆ testBasicPriorityInheritance()

bool distortos::test::anonymous_namespace{MutexPriorityInheritanceOperationsTestCase.cpp}::testBasicPriorityInheritance ( const Mutex::Type  type)

Tests basic priority inheritance mechanism of mutexes with PriorityInheritance protocol.

8 threads are created and "connected" into a tree-like hierarchy using mutexes. This structure is presented on the diagram below. Mutexes are marked with "Mx" boxes and threads with "Tx" ellipses. The higher the thread is drawn, the higher its priority is (drawn on the side).

Main thread is expected to inherit priority of each started test thread when this thread blocks on the mutex. After the last step main thread will inherit priority of thread T7 through a chain of 3 mutexes blocking 3 threads. After the test (when all links are broken) all priorities are expected to return to their previous values.

Parameters
[in]typeis the Mutex::Type that will be tested
Returns
true if the test case succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testCanceledLock()

bool distortos::test::anonymous_namespace{MutexPriorityInheritanceOperationsTestCase.cpp}::testCanceledLock ( const Mutex::Type  type)

Tests behavior of priority inheritance mechanism of mutexes in the event of canceled (timed-out) lock attempt.

8 threads are created and "connected" into a "vertical" hierarchy with current thread using mutexes (2 for each thread, except the last one). Each mutex "connects" two adjacent threads. Each thread locks the first mutex "normally" (with no timeout) and the second one with timeout, with exception of main thread - which locks its only mutex with no timeout - and last thread - which locks its only mutex with timeout. Timeouts of each thread are selected so that the highest priority thread time-outs first, and the lowest priority thread - last.

Main thread is expected to inherit priority of each started test thread when this thread blocks on the mutex. After last thread is started main thread will inherit priority of thread T7 through a chain of 8 mutexes blocking 8 threads. After each thread cancels block on its mutex (due to timeout) main thread's priority is expected to decrease by one - to the value inherited from the new last thread in the chain.

Parameters
[in]typeis the Mutex::Type that will be tested
Returns
true if the test case succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testPriorityChange()

bool distortos::test::anonymous_namespace{MutexPriorityInheritanceOperationsTestCase.cpp}::testPriorityChange ( const Mutex::Type  type)

Tests behavior of priority inheritance mechanism of mutexes in the event of priority change.

8 threads are created and "connected" into a "vertical" hierarchy with current thread using mutexes (2 for each thread, except the last one). Each mutex "connects" two adjacent threads.

Main thread is expected to inherit priority of each started test thread when this thread blocks on the mutex. After last thread is started main thread will inherit priority of thread T7 through a chain of 8 mutexes blocking 8 threads.

Change of priority applied to any of the threads in the chain is expected to propagate "up" this chain, up to main thread.

Parameters
[in]typeis the Mutex::Type that will be tested
Returns
true if the test case succeeded, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ testThreadPriority

constexpr uint8_t distortos::test::anonymous_namespace{MutexPriorityInheritanceOperationsTestCase.cpp}::testThreadPriority {MutexPriorityInheritanceOperationsTestCase::getTestCasePriority()}

priority of current test thread

◆ testThreadStackSize

constexpr size_t distortos::test::anonymous_namespace{MutexPriorityInheritanceOperationsTestCase.cpp}::testThreadStackSize {512}

size of stack for test thread, bytes