ThreadControlBlock class is a simple description of a Thread.
More...
#include "distortos/internal/scheduler/ThreadControlBlock.hpp"
|
void | reposition (bool loweringBefore) |
| Repositions the thread on the list it's currently on. More...
|
|
ThreadControlBlock class is a simple description of a Thread.
◆ ThreadControlBlock()
ThreadControlBlock's constructor.
- Parameters
-
[in] | stack | is an rvalue reference to Stack object which will be adopted for this thread |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | schedulingPolicy | is the scheduling policy of the thread |
[in] | threadGroupControlBlock | is a pointer to ThreadGroupControlBlock to which this object will be added, nullptr to inherit thread group from currently running thread |
[in] | signalsReceiver | is a pointer to SignalsReceiver object for this thread, nullptr to disable reception of signals for this thread |
[in] | owner | is a reference to RunnableThread object that owns this ThreadControlBlock |
◆ ~ThreadControlBlock()
distortos::internal::ThreadControlBlock::~ThreadControlBlock |
( |
| ) |
|
◆ addHook()
int distortos::internal::ThreadControlBlock::addHook |
( |
| ) |
|
Hook function executed when thread is added to scheduler.
If threadGroupControlBlock_ is nullptr, it is inherited from currently running thread. Then this object is added to the thread group (if it is valid).
- Attention
- This function should be called only by Scheduler::addInternal().
- Returns
- 0 on success, error code otherwise:
- EINVAL - inherited thread group is invalid;
◆ blockHook()
void distortos::internal::ThreadControlBlock::blockHook |
( |
const UnblockFunctor *const |
unblockFunctor | ) |
|
|
inline |
◆ getList()
ThreadList* distortos::internal::ThreadControlBlock::getList |
( |
| ) |
const |
|
inline |
- Returns
- pointer to list that has this object
◆ getOwnedProtocolMutexList()
MutexList& distortos::internal::ThreadControlBlock::getOwnedProtocolMutexList |
( |
| ) |
|
|
inline |
- Returns
- reference to list of mutexes (mutex control blocks) with enabled priority protocol owned by this thread
◆ getOwner()
RunnableThread& distortos::internal::ThreadControlBlock::getOwner |
( |
| ) |
const |
|
inline |
◆ getRoundRobinQuantum()
◆ getSchedulingPolicy()
SchedulingPolicy distortos::internal::ThreadControlBlock::getSchedulingPolicy |
( |
| ) |
const |
|
inline |
- Returns
- scheduling policy of the thread
◆ getSequenceNumber()
uintptr_t distortos::internal::ThreadControlBlock::getSequenceNumber |
( |
| ) |
const |
|
inline |
- Returns
- sequence number, one half of thread identifier
◆ getSignalsReceiverControlBlock()
◆ getStack() [1/2]
Stack& distortos::internal::ThreadControlBlock::getStack |
( |
| ) |
|
|
inline |
- Returns
- reference to internal Stack object
◆ getStack() [2/2]
const Stack& distortos::internal::ThreadControlBlock::getStack |
( |
| ) |
const |
|
inline |
- Returns
- const reference to internal Stack object
◆ getState()
ThreadState distortos::internal::ThreadControlBlock::getState |
( |
| ) |
const |
|
inline |
- Returns
- current state of object
◆ reposition()
void distortos::internal::ThreadControlBlock::reposition |
( |
bool |
loweringBefore | ) |
|
|
private |
Repositions the thread on the list it's currently on.
This function should be called when thread's effective priority changes.
- Attention
- list_ must not be nullptr
- Parameters
-
[in] | loweringBefore | selects the method of ordering when lowering the priority (it must be false when the priority is raised!):
- true - the thread is moved to the head of the group of threads with the new priority, this is accomplished by temporarily boosting effective priority by 1,
- false - the thread is moved to the tail of the group of threads with the new priority.
|
◆ setList()
void distortos::internal::ThreadControlBlock::setList |
( |
ThreadList *const |
list | ) |
|
|
inline |
Sets the list that has this object.
- Parameters
-
[in] | list | is a pointer to list that has this object |
◆ setPriority()
void distortos::internal::ThreadControlBlock::setPriority |
( |
uint8_t |
priority, |
|
|
bool |
alwaysBehind = {} |
|
) |
| |
Changes priority of thread.
If the priority really changes, the position in the thread list is adjusted and context switch may be requested.
- Parameters
-
[in] | priority | is the new priority of thread |
[in] | alwaysBehind | selects the method of ordering when lowering the priority
- false - the thread is moved to the head of the group of threads with the new priority (default),
- true - the thread is moved to the tail of the group of threads with the new priority.
|
◆ setPriorityInheritanceMutexControlBlock()
void distortos::internal::ThreadControlBlock::setPriorityInheritanceMutexControlBlock |
( |
const MutexControlBlock *const |
priorityInheritanceMutexControlBlock | ) |
|
|
inline |
- Parameters
-
[in] | priorityInheritanceMutexControlBlock | is a pointer to MutexControlBlock (with priorityInheritance protocol) that blocks this thread |
◆ setSchedulingPolicy()
void distortos::internal::ThreadControlBlock::setSchedulingPolicy |
( |
SchedulingPolicy |
schedulingPolicy | ) |
|
param [in] schedulingPolicy is the new scheduling policy of the thread
◆ setState()
void distortos::internal::ThreadControlBlock::setState |
( |
const ThreadState |
state | ) |
|
|
inline |
- Parameters
-
[in] | state | is the new state of object |
◆ switchedToHook()
void distortos::internal::ThreadControlBlock::switchedToHook |
( |
| ) |
|
|
inline |
Hook function called when context is switched to this thread.
Sets global _impure_ptr (from newlib) to thread's reent_ member variable.
- Attention
- This function should be called only by Scheduler::switchContext().
◆ unblockHook()
void distortos::internal::ThreadControlBlock::unblockHook |
( |
UnblockReason |
unblockReason | ) |
|
Unblock hook function of thread.
Resets round-robin's quantum and executes unblock functor saved in blockHook().
- Attention
- This function should be called only by Scheduler::unblockInternal().
- Parameters
-
[in] | unblockReason | is the new reason of unblocking of the thread |
◆ updateBoostedPriority()
void distortos::internal::ThreadControlBlock::updateBoostedPriority |
( |
uint8_t |
boostedPriority = {} | ) |
|
Updates boosted priority of the thread.
This function should be called after all operations involving this thread and a mutex with enabled priority protocol.
- Parameters
-
[in] | boostedPriority | is the initial boosted priority, this should be effective priority of the thread that is about to be blocked on a mutex owned by this thread, default - 0 |
◆ list_
ThreadList* distortos::internal::ThreadControlBlock::list_ |
|
private |
pointer to list that has this object
◆ ownedProtocolMutexList_
MutexList distortos::internal::ThreadControlBlock::ownedProtocolMutexList_ |
|
private |
list of mutexes (mutex control blocks) with enabled priority protocol owned by this thread
◆ owner_
◆ priorityInheritanceMutexControlBlock_
const MutexControlBlock* distortos::internal::ThreadControlBlock::priorityInheritanceMutexControlBlock_ |
|
private |
pointer to MutexControlBlock (with priorityInheritance protocol) that blocks this thread
◆ reent_
_reent distortos::internal::ThreadControlBlock::reent_ |
|
private |
newlib's _reent structure with thread-specific data
◆ roundRobinQuantum_
◆ schedulingPolicy_
scheduling policy of the thread
◆ sequenceNumber_
uintptr_t distortos::internal::ThreadControlBlock::sequenceNumber_ |
|
private |
sequence number, one half of thread identifier
◆ signalsReceiverControlBlock_
◆ stack_
Stack distortos::internal::ThreadControlBlock::stack_ |
|
private |
◆ state_
ThreadState distortos::internal::ThreadControlBlock::state_ |
|
private |
◆ threadGroupControlBlock_
◆ unblockFunctor_
const UnblockFunctor* distortos::internal::ThreadControlBlock::unblockFunctor_ |
|
private |
The documentation for this class was generated from the following files: