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::IPlatform::IEventHandler Class Referenceabstract

Interface for a back-end event handler. More...

#include <stk_common.h>

Inheritance diagram for stk::IPlatform::IEventHandler:
Collaboration diagram for stk::IPlatform::IEventHandler:

Public Member Functions

virtual void OnStart (Stack *&active)=0
 Called by ISR handler to notify that scheduling is about to start.
virtual void OnStop ()=0
 Called by driver to notify that scheduling is stopped.
virtual bool OnTick (Stack *&idle, Stack *&active, Timeout &ticks)=0
 Called by ISR handler to notify about the next system tick.
virtual void OnTaskExit (const Stack *stack)=0
 Called from the Thread process when task finished (its Run function exited by return).
virtual TId OnGetTid (Word caller_SP)=0
 Called from the Thread process when for getting task/thread id of the process.
virtual void OnSuspend (bool suspended)=0
 Called by the driver when scheduling is suspended or resumed (tickless suspend, see IPlatform::Suspend).
virtual bool OnForceContextSwitch (TId id, Stack *&idle, Stack *&active)=0
 Called when a task state change forces a context switch (sleep, wait, suspend, yield, exit).

Detailed Description

Interface for a back-end event handler.

It is inherited by the kernel implementation and delivers events from ISR.

Definition at line 1141 of file stk_common.h.

Member Function Documentation

◆ OnForceContextSwitch()

virtual bool stk::IPlatform::IEventHandler::OnForceContextSwitch ( TId id,
Stack *& idle,
Stack *& active )
pure virtual

Called when a task state change forces a context switch (sleep, wait, suspend, yield, exit).

Parameters
[in]idTask id causing this forced context switch.
[out]idleStack of the task which must enter Idle state.
[out]activeStack of the task which must enter Active state (to which context will switch).
Returns
True if context switch is required, False otherwise.

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

◆ OnGetTid()

virtual TId stk::IPlatform::IEventHandler::OnGetTid ( Word caller_SP)
pure virtual

Called from the Thread process when for getting task/thread id of the process.

Parameters
[in]caller_SPValue of Stack Pointer (SP) register (for locating the calling process inside the kernel).
Returns
Task/thread id of the process (returns always valid TId belonging to a task).

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

◆ OnStart()

virtual void stk::IPlatform::IEventHandler::OnStart ( Stack *& active)
pure virtual

Called by ISR handler to notify that scheduling is about to start.

Note
This event can be used to change hardware access mode for the first task.
Parameters
[out]activeStack of the task which must enter Active state (to which context will switch).

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

◆ OnStop()

virtual void stk::IPlatform::IEventHandler::OnStop ( )
pure virtual

Called by driver to notify that scheduling is stopped.

Note
Resets internal kernel state so that Start() may be called again (KERNEL_DYNAMIC mode only). Has no effect in KERNEL_STATIC mode.

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

◆ OnSuspend()

virtual void stk::IPlatform::IEventHandler::OnSuspend ( bool suspended)
pure virtual

Called by the driver when scheduling is suspended or resumed (tickless suspend, see IPlatform::Suspend).

Parameters
[in]suspendedtrue if scheduling was suspended, false if it was resumed.

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

◆ OnTaskExit()

virtual void stk::IPlatform::IEventHandler::OnTaskExit ( const Stack * stack)
pure virtual

Called from the Thread process when task finished (its Run function exited by return).

Parameters
[in]stackStack of the exited task.

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

◆ OnTick()

virtual bool stk::IPlatform::IEventHandler::OnTick ( Stack *& idle,
Stack *& active,
Timeout & ticks )
pure virtual

Called by ISR handler to notify about the next system tick.

Parameters
[out]idleStack of the task which must enter Idle state.
[out]activeStack of the task which must enter Active state (to which context will switch).
[in,out]ticks(STK_TICKLESS_IDLE=1 only) On entry: actual ticks elapsed since the previous call, as measured by the platform driver. On return: the minimum remaining sleep ticks across all active tasks, clamped to [1, STK_TICKLESS_TICKS_MAX]. Platform driver programs this value into the hardware timer to suppress unnecessary wakeups. Absent in non-tickless builds.
Note
To use a custom tick handler instead of the driver's built-in one, disable the driver's handler in stk_config.h and call ProcessTick() manually:
#define STK_SYSTICK_HANDLER _STK_SYSTICK_HANDLER_DISABLE
Returns
True if context switch is required, False otherwise.

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


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