SuperTinyKernel™ RTOS 1.05.3
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.
typedef DListEntry< IKernelTask, _ClosedLoop > DLEntryType
 Convenience alias for this entry type. Used to avoid repeating the full template spelling.
typedef DListHead< IKernelTask, _ClosedLoop > DLHeadType
 Convenience alias for the corresponding list head type.

Public Member Functions

virtual ITaskGetUserTask ()=0
 Get user task.
virtual StackGetUserStack ()=0
 Get pointer to the user task's stack.
virtual int32_t GetWeight () const =0
 Get static base weight assigned to the task.
virtual void SetCurrentWeight (int32_t weight)=0
 Set the current dynamic weight value used by the scheduling strategy.
virtual int32_t 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 relative 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.
DLHeadTypeGetHead () const
 Get the list head this entry currently belongs to.
DLEntryTypeGetNext () const
 Get the next entry in the list.
DLEntryTypeGetPrev () const
 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).

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

DLHeadTypem_head
 Owning list head, or NULL when the entry is not linked.
DLEntryTypem_next
 Next entry in the list, or NULL (open list boundary) / first entry (closed loop).
DLEntryTypem_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 492 of file stk_common.h.

Member Typedef Documentation

◆ DLEntryType

typedef DListEntry<IKernelTask, _ClosedLoop> stk::util::DListEntry< IKernelTask, _ClosedLoop >::DLEntryType
inherited

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

Definition at line 70 of file stk_linked_list.h.

◆ DLHeadType

typedef DListHead<IKernelTask, _ClosedLoop> stk::util::DListEntry< IKernelTask, _ClosedLoop >::DLHeadType
inherited

Convenience alias for the corresponding list head type.

Definition at line 75 of file stk_linked_list.h.

◆ ListEntryType

List entry type of IKernelTask elements.

Definition at line 503 of file stk_common.h.

◆ ListHeadType

List head type for IKernelTask elements.

Definition at line 498 of file stk_common.h.

Member Function Documentation

◆ GetCurrentWeight()

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

Get the current dynamic weight value of this task.

Returns
Current dynamic weight value.
See also
SwitchStrategySmoothWeightedRoundRobin
Note
Weight API

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

Referenced by stk::SwitchStrategySmoothWeightedRoundRobin::GetNext().

Here is the caller graph for this function:

◆ GetHead()

DLHeadType * stk::util::DListEntry< IKernelTask, _ClosedLoop >::GetHead ( ) const
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 80 of file stk_linked_list.h.

80{ return m_head; }
Intrusive doubly-linked list node. Embed this as a base class in any object (T) that needs to partici...

◆ 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::SwitchStrategyMonotonic< MSS_TYPE_RATE >::AddTask(), stk::SchedulabilityCheck::IsSchedulableWCRT(), and stk::test::TEST().

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::SwitchStrategyMonotonic< MSS_TYPE_RATE >::AddTask(), stk::SchedulabilityCheck::IsSchedulableWCRT(), and stk::test::TEST().

Here is the caller graph for this function:

◆ GetHrtRelativeDeadline()

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

Get HRT task's relative deadline.

Returns
Relative deadline of the task (ticks).

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

Referenced by stk::SwitchStrategyEDF::GetNext(), stk::test::TEST(), and stk::test::TEST().

Here is the caller graph for this function:

◆ GetNext()

DLEntryType * stk::util::DListEntry< IKernelTask, _ClosedLoop >::GetNext ( ) const
inlineinherited

Get the next entry in the list.

Returns
Pointer to the next DListEntry, or NULL if this is the last entry (open list) or the first entry (closed loop, where next wraps to first).
Note
In a closed loop (_ClosedLoop == true) this pointer is never NULL when the entry is linked.

Definition at line 88 of file stk_linked_list.h.

88{ return m_next; }

◆ GetPrev()

DLEntryType * stk::util::DListEntry< IKernelTask, _ClosedLoop >::GetPrev ( ) const
inlineinherited

Get the previous entry in the list.

Returns
Pointer to the previous DListEntry, or NULL if this is the first entry (open list) or the last entry (closed loop, where prev wraps to last).
Note
In a closed loop (_ClosedLoop == true) this pointer is never NULL when the entry is linked.

Definition at line 96 of file stk_linked_list.h.

96{ return m_prev; }

◆ GetUserStack()

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

Get pointer to the user task's stack.

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

◆ GetUserTask()

◆ GetWeight()

virtual int32_t stk::IKernelTask::GetWeight ( ) const
pure virtual

◆ IsLinked()

bool stk::util::DListEntry< IKernelTask, _ClosedLoop >::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 101 of file stk_linked_list.h.

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

◆ IsSleeping()

◆ Link()

void stk::util::DListEntry< IKernelTask, _ClosedLoop >::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 137 of file stk_linked_list.h.

138 {
139 m_head = head;
140 m_next = next;
141 m_prev = prev;
142
143 if (m_prev != nullptr)
144 m_prev->m_next = this;
145
146 if (m_next != nullptr)
147 m_next->m_prev = this;
148 }
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::util::DListEntry< IKernelTask, _ClosedLoop >::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, _ClosedLoop>. Eliminates the need for explicit static_cast at call sites.
MISRA deviation: [STK-DEV-004] Rule 5-2-x.

Definition at line 115 of file stk_linked_list.h.

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

◆ operator IKernelTask *()

stk::util::DListEntry< IKernelTask, _ClosedLoop >::operator IKernelTask* ( )
inlineinherited

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

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

Definition at line 108 of file stk_linked_list.h.

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

◆ SetCurrentWeight()

virtual void stk::IKernelTask::SetCurrentWeight ( int32_t 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::SwitchStrategySmoothWeightedRoundRobin::AddTask(), stk::SwitchStrategySmoothWeightedRoundRobin::GetNext(), and stk::SwitchStrategySmoothWeightedRoundRobin::OnTaskWake().

Here is the caller graph for this function:

◆ Unlink()

void stk::util::DListEntry< IKernelTask, _ClosedLoop >::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 157 of file stk_linked_list.h.

158 {
159 if (m_prev != nullptr)
161
162 if (m_next != nullptr)
164
165 m_head = nullptr;
166 m_next = nullptr;
167 m_prev = nullptr;
168 }

◆ 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::util::DListEntry< IKernelTask, _ClosedLoop >::m_head
privateinherited

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

Definition at line 170 of file stk_linked_list.h.

◆ m_next

DLEntryType* stk::util::DListEntry< IKernelTask, _ClosedLoop >::m_next
privateinherited

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

Definition at line 171 of file stk_linked_list.h.

◆ m_prev

DLEntryType* stk::util::DListEntry< IKernelTask, _ClosedLoop >::m_prev
privateinherited

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

Definition at line 172 of file stk_linked_list.h.


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