|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Interface for the kernel services exposed to the user processes during run-time when Kernel started scheduling the processes. More...
#include <stk_common.h>
Classes | |
| class | ScopedSchedulerLock |
| Disable task switching (equivalent of CMSIS-RTOS2 osKernelLock). Ticks, timeouts and ISRs keep running. Ensures the lock is always unlocked when leaving the scope, even when exceptions are thrown. More... | |
Public Member Functions | |
| virtual TId | GetTid () const =0 |
| Get thread Id of the currently running task. | |
| virtual Ticks | GetTicks () const =0 |
| Get number of ticks elapsed since kernel start. | |
| virtual uint32_t | GetTickResolution () const =0 |
| Get number of microseconds in one tick. | |
| virtual Cycles | GetSysTimerCount () const =0 |
| Get system timer count value. | |
| virtual uint32_t | GetSysTimerFrequency () const =0 |
| Get system timer frequency. | |
| virtual void | Delay (Timeout ticks)=0 |
| Delay calling process. | |
| virtual bool | Sleep (Timeout ticks)=0 |
| Put calling process into a sleep state. | |
| virtual bool | SleepUntil (Ticks timestamp)=0 |
| Put calling process into a sleep state until the specified timestamp. | |
| virtual void | SleepCancel (TId task_id)=0 |
| Cancel sleep of the task. | |
| virtual void | SwitchToNext ()=0 |
| Notify scheduler to switch to the next task (yield). | |
| virtual void | ExitTask ()=0 |
| Terminate the calling task: schedule its removal and switch it out. Does not return. | |
| virtual EWaitResult | Wait (ISyncObject *sobj, IMutex *mutex, Timeout timeout)=0 |
| Put calling process into a waiting state until synchronization object is signaled or timeout occurs. | |
| virtual void | Wake (ISyncObject *sobj, bool all)=0 |
| Wake one or all tasks currently waiting on a synchronization object. | |
| virtual Timeout | Suspend ()=0 |
| Suspend scheduling. | |
| virtual void | Resume (Timeout elapsed_ticks)=0 |
| Resume scheduling after a prior Suspend() call. | |
| virtual void | InheritWeight (TId tid, Weight weight)=0 |
| Inherit weight for the task. | |
| virtual void | RestoreWeight (TId tid, ISyncObject *sobj=nullptr)=0 |
| Restore weight of the task to the original value. | |
| virtual Weight | SetWeight (TId tid, Weight weight)=0 |
| Change the base weight of the task at run-time (replaces ITask::GetWeight() value). | |
| virtual Timeout | SetTimeSlice (TId tid, Timeout ticks)=0 |
| Change the time-slice quantum of the task at run-time and reload its slice. | |
| virtual ELockResult | LockScheduler ()=0 |
| Disable task switching (equivalent of CMSIS-RTOS2 osKernelLock). Ticks, timeouts and ISRs keep running. | |
| virtual ELockResult | UnlockScheduler ()=0 |
| Enable task switching (equivalent of CMSIS-RTOS2 osKernelUnlock). | |
| virtual ELockResult | RestoreSchedulerLock (bool locked)=0 |
| Set the lock state (equivalent of CMSIS-RTOS2 osKernelRestoreLock). | |
Static Public Member Functions | |
| static IKernelService * | GetInstance () |
| Get CPU-local instance of the kernel service. | |
Protected Member Functions | |
| ~IKernelService ()=default | |
| Destructor. | |
Static Protected Member Functions | |
| static IWaitObject::ListHeadType & | GetMutableWaitList (ISyncObject *sobj) |
| Access helper to the mutable IWaitObject::GetWaitList(). | |
Interface for the kernel services exposed to the user processes during run-time when Kernel started scheduling the processes.
Definition at line 1812 of file stk_common.h.
|
protecteddefault |
Destructor.
|
pure virtual |
Delay calling process.
| [in] | ticks | Delay time (ticks). |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::Delay().
|
pure virtual |
Terminate the calling task: schedule its removal and switch it out. Does not return.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::ExitTask().
|
static |
Get CPU-local instance of the kernel service.
Referenced by stk::Delay(), stk::ExitTask(), EXTI0_IRQHandler(), stk::GetSysTimerCount(), stk::GetSysTimerFrequency(), stk::GetTickResolution(), stk::GetTicks(), stk::GetTid(), stk::GetTimeNowMs(), stk::pthread::IsMutexOwner(), stk::LockScheduler(), LowPowerOverrider::OnSleep(), osKernelResume(), osKernelSuspend(), stk::RestoreSchedulerLock(), stk::IKernelService::ScopedSchedulerLock::ScopedSchedulerLock(), stk::SetTimeSlice(), stk::SetWeight(), stk::Sleep(), stk::SleepCancel(), stk::SleepUntil(), stk::sync::FastMutex::TimedLockEx(), stk::sync::Mutex::TimedLockEx(), stk::sync::FastMutex::Unlock(), stk::sync::Mutex::Unlock(), stk::UnlockScheduler(), vTaskPrioritySet(), stk::sync::ConditionVariable::WaitEx(), stk::sync::Event::WaitEx(), stk::sync::SemaphoreT< T >::WaitEx(), stk::SyncObjectBase::WakeAll(), stk::SyncObjectBase::WakeOne(), stk::Yield(), and stk::IKernelService::ScopedSchedulerLock::~ScopedSchedulerLock().
|
inlinestaticprotected |
Access helper to the mutable IWaitObject::GetWaitList().
Definition at line 2091 of file stk_common.h.
References __stk_forceinline, and stk::ISyncObject::GetMutableWaitList().
Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Wake().
|
pure virtual |
Get system timer count value.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::GetSysTimerCount().
|
pure virtual |
Get system timer frequency.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::GetSysTimerFrequency().
|
pure virtual |
Get number of microseconds in one tick.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::GetTickResolution(), and stk::GetTimeNowMs().
|
pure virtual |
Get number of ticks elapsed since kernel start.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::GetTicks(), and stk::GetTimeNowMs().
|
pure virtual |
Get thread Id of the currently running task.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::GetTid(), stk::sync::FastMutex::TimedLockEx(), and stk::sync::Mutex::TimedLockEx().
Inherit weight for the task.
| [in] | tid | Task id. |
| [in] | weight | New weight, shall be higher than task's current weight (see ITask::GetWeight). |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::sync::FastMutex::TimedLockEx(), stk::sync::Mutex::TimedLockEx(), stk::sync::FastMutex::Unlock(), and stk::sync::Mutex::Unlock().
|
pure virtual |
Disable task switching (equivalent of CMSIS-RTOS2 osKernelLock). Ticks, timeouts and ISRs keep running.
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::LockScheduler(), and stk::IKernelService::ScopedSchedulerLock::ScopedSchedulerLock().
|
pure virtual |
Set the lock state (equivalent of CMSIS-RTOS2 osKernelRestoreLock).
| [in] | locked | true to lock, false to unlock. |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::RestoreSchedulerLock(), and stk::IKernelService::ScopedSchedulerLock::~ScopedSchedulerLock().
|
pure virtual |
Restore weight of the task to the original value.
| [in] | tid | Task id. |
| [in] | sobj | Optional, if provided than weight will be restored to the highest weight of the task in the wait list, otherwise to the original value. |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::sync::FastMutex::TimedLockEx(), stk::sync::Mutex::TimedLockEx(), stk::sync::FastMutex::Unlock(), and stk::sync::Mutex::Unlock().
|
pure virtual |
Resume scheduling after a prior Suspend() call.
| [in] | elapsed_ticks | Number of ticks that elapsed during the suspended period. The kernel uses this value to advance internal time counters and wake tasks whose sleep deadlines have expired. |
stk::KERNEL_TICKLESS; asserts otherwise. Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by EXTI0_IRQHandler(), LowPowerOverrider::OnSleep(), and osKernelResume().
Change the time-slice quantum of the task at run-time and reload its slice.
| [in] | tid | Task id. |
| [in] | ticks | New quantum (ticks), NO_TIME_SLICE disables time-slicing for the task. |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::SetTimeSlice().
Change the base weight of the task at run-time (replaces ITask::GetWeight() value).
| [in] | tid | Task id. |
| [in] | weight | New base weight. Must not be NO_WEIGHT; must satisfy the constraints of the active strategy (see e.g. SwitchStrategyPreemptionThreshold::MakeWeight). |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::sched::SwitchStrategyPreemptionThreshold< 32 >::ChangeThreshold(), and stk::SetWeight().
|
pure virtual |
Put calling process into a sleep state.
| [in] | ticks | Sleep time (ticks). |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::Sleep().
|
pure virtual |
Cancel sleep of the task.
| [in] | task_id | Id of the task. |
Ends a sleep started by Sleep()/SleepUntil() early. If the task is instead blocked on a synchronization object (KERNEL_SYNC mode), the wait is cancelled the same way as IKernel::CancelTaskWait() does: the task is removed from the object's wait list and its Wait() returns WAIT_RESULT_CANCELED (not WAIT_RESULT_TIMEOUT or WAIT_RESULT_SIGNAL, no resource is acquired or consumed).
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::SleepCancel().
|
pure virtual |
Put calling process into a sleep state until the specified timestamp.
| [in] | timestamp | Absolute timestamp (ticks). |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::SleepUntil().
|
pure virtual |
Suspend scheduling.
stk::KERNEL_TICKLESS; asserts otherwise. Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by EXTI0_IRQHandler(), LowPowerOverrider::OnSleep(), and osKernelSuspend().
|
pure virtual |
Notify scheduler to switch to the next task (yield).
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::Yield().
|
pure virtual |
Enable task switching (equivalent of CMSIS-RTOS2 osKernelUnlock).
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::UnlockScheduler().
|
pure virtual |
Put calling process into a waiting state until synchronization object is signaled or timeout occurs.
| [in] | sobj | Synchronization object to wait on. |
| [in] | mutex | Mutex protecting the state of the synchronization object. |
| [in] | timeout | Maximum wait time (ticks). Use WAIT_INFINITE to block indefinitely, use NO_WAIT to poll without blocking. |
EWaitResult). WAIT_RESULT_FAIL without waiting. Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::sync::FastMutex::TimedLockEx(), stk::sync::Mutex::TimedLockEx(), stk::sync::ConditionVariable::WaitEx(), stk::sync::Event::WaitEx(), and stk::sync::SemaphoreT< T >::WaitEx().
|
pure virtual |
Wake one or all tasks currently waiting on a synchronization object.
| [in] | sobj | Synchronization object whose waiting queue will be notified. |
| [in] | all | If true, unblocks all waiting tasks (broadcast mode); if false, unblocks only the next waiting task (signal mode). |
Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService.
Referenced by stk::SyncObjectBase::WakeAll(), and stk::SyncObjectBase::WakeOne().