SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::IKernelTask Class Referenceabstract

Scheduling-strategy-facing interface for a kernel task slot. More...

#include <stk_common.h>

Inheritance diagram for stk::IKernelTask:
Collaboration diagram for stk::IKernelTask:

Public Types

typedef DLHeadType ListHeadType
 List head type for IKernelTask elements.
typedef DLEntryType ListEntryType
 List entry type of IKernelTask elements.
enum  
 A tag for type-safe casts done by CastListEntryToParent. More...
typedef DListEntry< IKernelTask, TClosedLoop > DLEntryType
 Convenience alias for this entry type. Used to avoid repeating the full template spelling.
typedef DListHead< IKernelTask, TClosedLoop > DLHeadType
 Convenience alias for the corresponding list head type.

Public Member Functions

virtual ITask * GetUserTask ()=0
 Get user task.
virtual Stack GetUserStack () const =0
 Get user task's Stack info.
virtual Weight GetWeight () const =0
 Get the effective weight of the task.
virtual Weight GetBaseWeight () const =0
 Get the base (configured) weight of the task, ignoring any priority-inheritance boost.
virtual void SetCurrentWeight (Weight weight)=0
 Set the current dynamic weight value used by the scheduling strategy.
virtual Weight GetCurrentWeight () const =0
 Get the current dynamic weight value of this task.
virtual Timeout GetHrtPeriodicity () const =0
 Get HRT task execution periodicity.
virtual Timeout GetHrtDeadline () const =0
 Get HRT task deadline (max allowed task execution time).
virtual Timeout GetHrtRelativeDeadline () const =0
 Get HRT task's remaining deadline.
virtual bool IsSleeping () const =0
 Check whether the task is currently sleeping.
virtual void Wake ()=0
 Wake a sleeping task on the next scheduling tick.
DLHeadType * GetHead ()
 Get the list head this entry currently belongs to.
DLEntryType * GetNext ()
 Get the next entry in the list.
DLEntryType * GetPrev ()
 Get the previous entry in the list.
bool IsLinked () const
 Check whether this entry is currently a member of any list.
 operator IKernelTask * ()
 Implicit conversion to a mutable pointer to the host object (T).
 operator const IKernelTask * () const
 Implicit conversion to a const pointer to the host object (T).

Protected Member Functions

 ~IKernelTask ()=default
 Destructor.

Private Member Functions

void Link (DLHeadType *head, DLEntryType *next, DLEntryType *prev)
 Wire this entry into a list between prev and next.
void Unlink ()
 Remove this entry from its current list.

Private Attributes

DLHeadType * m_head
 Owning list head, or NULL when the entry is not linked.
DLEntryType * m_next
 Next entry in the list, or NULL (open list boundary) / first entry (closed loop).
DLEntryType * m_prev
 Previous entry in the list, or NULL (open list boundary) / last entry (closed loop).

Detailed Description

Scheduling-strategy-facing interface for a kernel task slot.

Wraps a user ITask and exposes the metadata that task-switching strategy implementations (ITaskSwitchStrategy) need to make scheduling decisions: sleep state (IsSleeping, Wake), HRT timing (GetHrtPeriodicity, GetHrtDeadline, GetHrtRelativeDeadline), and weighted-round-robin support (GetWeight, GetCurrentWeight, SetCurrentWeight).

Definition at line 1031 of file stk_common.h.

Member Typedef Documentation

◆ DLEntryType

typedef DListEntry<IKernelTask, TClosedLoop> stk::detail::DListEntry< IKernelTask, TClosedLoop >::DLEntryType
inherited

Convenience alias for this entry type. Used to avoid repeating the full template spelling.

Definition at line 75 of file stk_linked_list.h.

◆ DLHeadType

typedef DListHead<IKernelTask, TClosedLoop> stk::detail::DListEntry< IKernelTask, TClosedLoop >::DLHeadType
inherited

Convenience alias for the corresponding list head type.

Definition at line 80 of file stk_linked_list.h.

◆ ListEntryType

List entry type of IKernelTask elements.

Definition at line 1042 of file stk_common.h.

◆ ListHeadType

List head type for IKernelTask elements.

Definition at line 1037 of file stk_common.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

A tag for type-safe casts done by CastListEntryToParent.

See also
CastListEntryToParent.

Definition at line 70 of file stk_linked_list.h.

70{ DLEntryTag = 1 };
Intrusive doubly-linked list node. Embed this as a base class in any object (T) that needs to partici...

Constructor & Destructor Documentation

◆ ~IKernelTask()

stk::IKernelTask::~IKernelTask ( )
protecteddefault

Destructor.

Note
Protected by design. Prevents unsafe polymorphic delete.

Member Function Documentation

◆ GetBaseWeight()

virtual Weight stk::IKernelTask::GetBaseWeight ( ) const
pure virtual

Get the base (configured) weight of the task, ignoring any priority-inheritance boost.

Returns
ITask::GetWeight() if WEIGHT_API is true; DEFAULT_WEIGHT otherwise. Unlike GetWeight(), the value does not change while the task has inherited a higher weight.
See also
SwitchStrategyPreemptionThreshold
Note
Weight API

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Referenced by stk::sched::SwitchStrategyPreemptionThreshold< 32 >::GetRawThreshold().

Here is the caller graph for this function:

◆ GetCurrentWeight()

virtual Weight stk::IKernelTask::GetCurrentWeight ( ) const
pure virtual

Get the current dynamic weight value of this task.

Returns
Current dynamic weight value. For strategies with priority inheritance NO_WEIGHT means the task is not boosted.
See also
SwitchStrategySmoothWeightedRoundRobin
Note
Weight API

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Referenced by stk::sched::SwitchStrategySmoothWeightedRoundRobinT< false >::GetNext().

Here is the caller graph for this function:

◆ GetHead()

DLHeadType * stk::detail::DListEntry< IKernelTask, TClosedLoop >::GetHead ( )
inlineinherited

Get the list head this entry currently belongs to.

Returns
Pointer to the owning DListHead, or NULL if the entry is not linked.

Definition at line 85 of file stk_linked_list.h.

85{ return m_head; }

◆ GetHrtDeadline()

virtual Timeout stk::IKernelTask::GetHrtDeadline ( ) const
pure virtual

Get HRT task deadline (max allowed task execution time).

Returns
Deadline of the task (ticks).

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Referenced by stk::sched::SwitchStrategyMonotonic< MSS_TYPE_RATE >::AddTask(), and stk::sched::SchedulabilityCheck::IsSchedulableWCRT().

Here is the caller graph for this function:

◆ GetHrtPeriodicity()

virtual Timeout stk::IKernelTask::GetHrtPeriodicity ( ) const
pure virtual

Get HRT task execution periodicity.

Returns
Periodicity of the task (ticks).

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Referenced by stk::sched::SwitchStrategyMonotonic< MSS_TYPE_RATE >::AddTask(), and stk::sched::SchedulabilityCheck::IsSchedulableWCRT().

Here is the caller graph for this function:

◆ GetHrtRelativeDeadline()

virtual Timeout stk::IKernelTask::GetHrtRelativeDeadline ( ) const
pure virtual

Get HRT task's remaining deadline.

Returns
Ticks left before the deadline of the current activation expires (GetHrtDeadline() minus the ticks the task has been active). Zero means this is the last tick still within the deadline, a negative value means the deadline is missed.
See also
GetHrtDeadline, GetHrtPeriodicity

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Referenced by stk::sched::SwitchStrategyEDF::GetNext().

Here is the caller graph for this function:

◆ GetNext()

DLEntryType * stk::detail::DListEntry< IKernelTask, TClosedLoop >::GetNext ( )
inlineinherited

Get the next entry in the list.

Returns
Next entry. In an open list NULL for the last entry; in a closed loop the last entry wraps to the first one, so the result is never NULL for a linked entry.

Definition at line 96 of file stk_linked_list.h.

96{ return m_next; }

◆ GetPrev()

DLEntryType * stk::detail::DListEntry< IKernelTask, TClosedLoop >::GetPrev ( )
inlineinherited

Get the previous entry in the list.

Returns
Previous entry. In an open list NULL for the first entry; in a closed loop the first entry wraps to the last one, so the result is never NULL for a linked entry.

Definition at line 106 of file stk_linked_list.h.

106{ return m_prev; }

◆ GetUserStack()

virtual Stack stk::IKernelTask::GetUserStack ( ) const
pure virtual

Get user task's Stack info.

Returns
Snapshot of Stack info.

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

◆ GetUserTask()

virtual ITask * stk::IKernelTask::GetUserTask ( )
pure virtual

◆ GetWeight()

◆ IsLinked()

bool stk::detail::DListEntry< IKernelTask, TClosedLoop >::IsLinked ( ) const
inlineinherited

Check whether this entry is currently a member of any list.

Returns
true if linked (m_head != NULL); false otherwise.

Definition at line 115 of file stk_linked_list.h.

115{ return (GetHead() != nullptr); }

◆ IsSleeping()

◆ Link()

void stk::detail::DListEntry< IKernelTask, TClosedLoop >::Link ( DLHeadType * head,
DLEntryType * next,
DLEntryType * prev )
inlineprivateinherited

Wire this entry into a list between prev and next.

Parameters
[in]headThe owning DListHead. Stored as a back-pointer for IsLinked() and ownership checks.
[in]nextThe entry that will follow this one, or NULL if this becomes the last entry.
[in]prevThe entry that will precede this one, or NULL if this becomes the first entry.
Note
Called exclusively by DListHead::Link(). Assumes the entry is not currently linked. Updates the neighbours' forward/back pointers to splice this entry in.

Definition at line 150 of file stk_linked_list.h.

151 {
152 m_head = head;
153 m_next = next;
154 m_prev = prev;
155
156 if (m_prev != nullptr)
157 {
158 m_prev->m_next = this;
159 }
160
161 if (m_next != nullptr)
162 {
163 m_next->m_prev = this;
164 }
165 }
DLEntryType * m_next
Next entry in the list, or NULL (open list boundary) / first entry (closed loop).
DLEntryType * m_prev
Previous entry in the list, or NULL (open list boundary) / last entry (closed loop).

◆ operator const IKernelTask *()

stk::detail::DListEntry< IKernelTask, TClosedLoop >::operator const IKernelTask * ( ) const
inlineinherited

Implicit conversion to a const pointer to the host object (T).

Note
Safe because T must derive from DListEntry<T, TClosedLoop>. Eliminates the need for explicit static_cast at call sites.
MISRA deviation: [STK-DEV-004] Rule 5-2-x.

Definition at line 129 of file stk_linked_list.h.

129{ return static_cast<const T *>(this); }

◆ operator IKernelTask *()

stk::detail::DListEntry< IKernelTask, TClosedLoop >::operator IKernelTask* ( )
inlineinherited

Implicit conversion to a mutable pointer to the host object (T).

Note
Safe because T must derive from DListEntry<T, TClosedLoop>. Eliminates the need for explicit static_cast at call sites.
MISRA deviation: [STK-DEV-004] Rule 5-2-x.

Definition at line 122 of file stk_linked_list.h.

122{ return static_cast<T *>(this); }

◆ SetCurrentWeight()

virtual void stk::IKernelTask::SetCurrentWeight ( Weight weight)
pure virtual

Set the current dynamic weight value used by the scheduling strategy.

Parameters
[in]weightNew current dynamic weight value.
See also
SwitchStrategySmoothWeightedRoundRobin
Note
Weight API

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Referenced by stk::sched::SwitchStrategySmoothWeightedRoundRobinT< false >::AddTask(), stk::sched::SwitchStrategySmoothWeightedRoundRobinT< false >::GetNext(), and stk::sched::SwitchStrategySmoothWeightedRoundRobinT< false >::OnTaskWake().

Here is the caller graph for this function:

◆ Unlink()

void stk::detail::DListEntry< IKernelTask, TClosedLoop >::Unlink ( )
inlineprivateinherited

Remove this entry from its current list.

Note
Called exclusively by DListHead::Unlink(). Patches the neighbours' pointers to bridge over this entry, then clears m_head, m_next, and m_prev to NULL so the entry is in a clean unlinked state.
Does not update DListHead::m_count or m_first / m_last — those are the responsibility of the calling DListHead::Unlink().

Definition at line 174 of file stk_linked_list.h.

175 {
176 if (m_prev != nullptr)
177 {
179 }
180
181 if (m_next != nullptr)
182 {
184 }
185
186 m_head = nullptr;
187 m_next = nullptr;
188 m_prev = nullptr;
189 }

◆ Wake()

virtual void stk::IKernelTask::Wake ( )
pure virtual

Wake a sleeping task on the next scheduling tick.

Warning
The task must currently be sleeping (IsSleeping() == true). Calling Wake() on a non-sleeping task is a programming error and will trigger an assertion in the concrete implementation.

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask.

Member Data Documentation

◆ m_head

DLHeadType* stk::detail::DListEntry< IKernelTask, TClosedLoop >::m_head
privateinherited

Owning list head, or NULL when the entry is not linked.

Definition at line 191 of file stk_linked_list.h.

◆ m_next

DLEntryType* stk::detail::DListEntry< IKernelTask, TClosedLoop >::m_next
privateinherited

Next entry in the list, or NULL (open list boundary) / first entry (closed loop).

Definition at line 192 of file stk_linked_list.h.

◆ m_prev

DLEntryType* stk::detail::DListEntry< IKernelTask, TClosedLoop >::m_prev
privateinherited

Previous entry in the list, or NULL (open list boundary) / last entry (closed loop).

Definition at line 193 of file stk_linked_list.h.


The documentation for this class was generated from the following file: