MutexControlBlock class is a control block for Mutex.
More...
#include "distortos/internal/synchronization/MutexControlBlock.hpp"
|
void | beforeBlock () const |
| Performs any actions required before actually blocking on the mutex. More...
|
|
void | doTransferLock () |
| Performs transfer of lock from current owner to next thread on the list. More...
|
|
void | doUnlock () |
| Performs actual unlocking of previously locked mutex. More...
|
|
MutexControlBlock class is a control block for Mutex.
◆ Protocol
◆ RecursiveLocksCount
type used for counting recursive locks
◆ Type
◆ MutexControlBlock()
constexpr distortos::internal::MutexControlBlock::MutexControlBlock |
( |
const Type |
type, |
|
|
const Protocol |
protocol, |
|
|
const uint8_t |
priorityCeiling |
|
) |
| |
|
inlineprotected |
MutexControlBlock's constructor.
- Parameters
-
[in] | type | is the type of mutex |
[in] | protocol | is the mutex protocol |
[in] | priorityCeiling | is the priority ceiling of mutex, ignored when protocol != Protocol::priorityProtect |
◆ beforeBlock()
void distortos::internal::MutexControlBlock::beforeBlock |
( |
| ) |
const |
|
private |
Performs any actions required before actually blocking on the mutex.
In case of priorityInheritance protocol, priority of owner thread is boosted and this mutex is set as the blocking mutex of the calling thread. In all other cases this function does nothing.
- Attention
- must be called in block() and blockUntil() before actually blocking of the calling thread.
◆ doBlock()
int distortos::internal::MutexControlBlock::doBlock |
( |
| ) |
|
|
protected |
Blocks current thread, transferring it to blockedList_.
- Returns
- 0 on success, error code otherwise:
◆ doBlockUntil()
Blocks current thread with timeout, transferring it to blockedList_.
- Parameters
-
[in] | timePoint | is the time point at which the thread will be unblocked (if not already unblocked) |
- Returns
- 0 on success, error code otherwise:
◆ doLock()
void distortos::internal::MutexControlBlock::doLock |
( |
| ) |
|
|
protected |
Performs actual locking of previously unlocked mutex.
- Attention
- mutex must be unlocked
◆ doTransferLock()
void distortos::internal::MutexControlBlock::doTransferLock |
( |
| ) |
|
|
private |
Performs transfer of lock from current owner to next thread on the list.
- Attention
- mutex must be locked and blockedList_ must not be empty
◆ doUnlock()
void distortos::internal::MutexControlBlock::doUnlock |
( |
| ) |
|
|
private |
Performs actual unlocking of previously locked mutex.
- Attention
- mutex must be locked and blockedList_ must be empty
◆ doUnlockOrTransferLock()
void distortos::internal::MutexControlBlock::doUnlockOrTransferLock |
( |
| ) |
|
|
protected |
Performs unlocking or transfer of lock from current owner to next thread on the list.
Mutex is unlocked if blockedList_ is empty, otherwise the ownership is transferred to the next thread.
- Attention
- mutex must be locked
◆ getBoostedPriority()
uint8_t distortos::internal::MutexControlBlock::getBoostedPriority |
( |
| ) |
const |
Gets "boosted priority" of the mutex.
"Boosted priority" of the mutex depends on the selected priority protocol:
- none - 0,
- priorityInheritance - effective priority of the highest priority thread blocked on this mutex or 0 if no threads are blocked,
- priorityProtect - priority ceiling.
- Returns
- "boosted priority" of the mutex
◆ getOwner()
- Returns
- owner of the mutex, nullptr if mutex is currently unlocked
◆ getPriorityCeiling()
uint8_t distortos::internal::MutexControlBlock::getPriorityCeiling |
( |
| ) |
const |
|
inlineprotected |
◆ getProtocol()
Protocol distortos::internal::MutexControlBlock::getProtocol |
( |
| ) |
const |
|
inlineprotected |
◆ getRecursiveLocksCount()
- Returns
- reference to number of recursive locks
◆ getType()
Type distortos::internal::MutexControlBlock::getType |
( |
| ) |
const |
|
inlineprotected |
◆ blockedList_
ThreadList distortos::internal::MutexControlBlock::blockedList_ |
|
private |
◆ owner_
◆ priorityCeiling_
uint8_t distortos::internal::MutexControlBlock::priorityCeiling_ |
|
private |
◆ protocolShift
constexpr uint8_t distortos::internal::MutexControlBlock::protocolShift {typeShift + typeWidth} |
|
static |
shift of "protocol" subfield, bits
◆ protocolWidth
constexpr uint8_t distortos::internal::MutexControlBlock::protocolWidth {CHAR_BIT / 2} |
|
static |
width of "protocol" subfield, bits
◆ recursiveLocksCount_
number of recursive locks, used when mutex type is recursive
◆ typeProtocol_
uint8_t distortos::internal::MutexControlBlock::typeProtocol_ |
|
private |
type of mutex and its protocol
◆ typeShift
constexpr uint8_t distortos::internal::MutexControlBlock::typeShift {0} |
|
static |
shift of "type" subfield, bits
◆ typeWidth
constexpr uint8_t distortos::internal::MutexControlBlock::typeWidth {CHAR_BIT / 2} |
|
static |
width of "type" subfield, bits
The documentation for this class was generated from the following files: