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

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

#include <stk_common.h>

Inheritance 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)=0
 Called by ISR handler to notify about the next system tick.
virtual void OnTaskSwitch (Word caller_SP)=0
 Called by Thread process (via IKernelService::SwitchToNext) to switch to a next task.
virtual void OnTaskSleep (Word caller_SP, Timeout ticks)=0
 Called by Thread process (via IKernelService::Sleep) for exclusion of the calling process from scheduling (sleeping).
virtual void OnTaskSleepUntil (Word caller_SP, Ticks timestamp)=0
 Called by Thread process (via IKernelService::SleepUntil) for exclusion of the calling process from scheduling (sleeping).
virtual void OnTaskExit (Stack *stack)=0
 Called from the Thread process when task finished (its Run function exited by return).
virtual IWaitObjectOnTaskWait (Word caller_SP, ISyncObject *sync_obj, IMutex *mutex, Timeout timeout)=0
 Called from the Thread process when task needs to wait.
virtual TId OnGetTid (Word caller_SP)=0
 Called from the Thread process when for getting task/thread id of the process.

Detailed Description

Interface for a back-end event handler.

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

Definition at line 582 of file stk_common.h.

Member Function Documentation

◆ 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.

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 >.

◆ OnTaskExit()

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

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

Parameters
[out]stackStack of the exited task.

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

◆ OnTaskSleep()

virtual void stk::IPlatform::IEventHandler::OnTaskSleep ( Word caller_SP,
Timeout ticks )
pure virtual

Called by Thread process (via IKernelService::Sleep) for exclusion of the calling process from scheduling (sleeping).

Parameters
[in]caller_SPValue of Stack Pointer (SP) register (for locating the calling process inside the kernel).
[in]ticksTime to sleep (ticks).

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

◆ OnTaskSleepUntil()

virtual void stk::IPlatform::IEventHandler::OnTaskSleepUntil ( Word caller_SP,
Ticks timestamp )
pure virtual

Called by Thread process (via IKernelService::SleepUntil) for exclusion of the calling process from scheduling (sleeping).

Parameters
[in]caller_SPValue of Stack Pointer (SP) register (for locating the calling process inside the kernel).
[in]timestampAbsolute timestamp (ticks).

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

◆ OnTaskSwitch()

virtual void stk::IPlatform::IEventHandler::OnTaskSwitch ( Word caller_SP)
pure virtual

Called by Thread process (via IKernelService::SwitchToNext) to switch to a next task.

Parameters
[in]caller_SPValue of Stack Pointer (SP) register (for locating the calling process inside the kernel).

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

◆ OnTaskWait()

virtual IWaitObject * stk::IPlatform::IEventHandler::OnTaskWait ( Word caller_SP,
ISyncObject * sync_obj,
IMutex * mutex,
Timeout timeout )
pure virtual

Called from the Thread process when task needs to wait.

Parameters
[in]caller_SPValue of Stack Pointer (SP) register (for locating the calling process inside the kernel).
[in]sync_objISyncObject instance (passed by Wait).
[in]mutexIMutex instance (passed by Wait).
[in]timeoutTime to sleep (ticks).

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

◆ OnTick()

virtual bool stk::IPlatform::IEventHandler::OnTick ( Stack *& idle,
Stack *& active )
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

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

References STK_TICKLESS_IDLE.


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