|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
POSIX-named scheduling API (<sched.h>) for STK: sched_yield(), sched_get_priority_min/max() and struct sched_param. Implemented by stk_c_pthread.cpp (no dependency on the STK C API). More...
#include <sys/types.h>Go to the source code of this file.
Classes | |
| struct | sched_param |
| Scheduling parameters. More... | |
Macros | |
| #define | _SYS__PTHREADTYPES_H_ |
| #define | STK_C_PTHREADTYPES_GUARD |
| #define | SCHED_OTHER (0) |
| #define | SCHED_FIFO (1) |
| #define | SCHED_RR (2) |
| #define | STK_C_SCHED_PRIORITY_MIN (0) |
| #define | STK_C_SCHED_PRIORITY_MAX (31) |
| #define | STK_C_SCHED_PRIORITY_DEFAULT ((STK_C_SCHED_PRIORITY_MAX + 1) / 2) |
Functions | |
| int | sched_yield (void) |
| Yield the CPU to another ready task. | |
| int | sched_get_priority_min (int policy) |
| Get the minimum priority of a scheduling policy. | |
| int | sched_get_priority_max (int policy) |
| Get the maximum priority of a scheduling policy. | |
| int | sched_getscheduler (pid_t pid) |
| Get the scheduling policy of a thread. | |
| int | sched_setscheduler (pid_t pid, int policy, const struct sched_param *param) |
| Set the policy and priority of the calling thread (see pthread_setschedparam()). | |
| int | sched_getparam (pid_t pid, struct sched_param *param) |
| Get the priority of the calling thread. | |
| int | sched_setparam (pid_t pid, const struct sched_param *param) |
| Set the priority of the calling thread, keeping its policy (see pthread_setschedprio()). | |
| int | sched_rr_get_interval (pid_t pid, struct timespec *tp) |
| Get the round-robin time slice: one kernel tick (stk::GetTickResolution()). | |
POSIX-named scheduling API (<sched.h>) for STK: sched_yield(), sched_get_priority_min/max() and struct sched_param. Implemented by stk_c_pthread.cpp (no dependency on the STK C API).
The kernel must use sched::SwitchStrategyFixedPriority: sched_priority is the fixed priority level of the task (its weight), 0 is the lowest and MAX_PRIORITIES - 1 the highest (sched::SwitchStrategyFP32: 0..31, the default level is PRIORITY_NORMAL = MAX_PRIORITIES / 2). The priority of a running thread can be changed (pthread_setschedparam(), pthread_setschedprio()) through stk::SetWeight(). The policy is always decided by the switch strategy: SCHED_OTHER, SCHED_FIFO and SCHED_RR are accepted and remembered for pthread_attr_setschedpolicy() / pthread_getschedparam() only, they do not change how the kernel schedules (preemptive, round-robin inside one priority level).
Definition in file sched.h.
| #define SCHED_FIFO (1) |
Definition at line 44 of file sched.h.
Referenced by stk::pthread::IsValidSchedPolicy().
| #define SCHED_OTHER (0) |
Definition at line 43 of file sched.h.
Referenced by stk::pthread::IsValidSchedPolicy(), pthread_attr_init(), pthread_create(), and stk::pthread::PthreadTask::PthreadTask().
| #define SCHED_RR (2) |
Definition at line 45 of file sched.h.
Referenced by stk::pthread::IsValidSchedPolicy().
| #define STK_C_SCHED_PRIORITY_DEFAULT ((STK_C_SCHED_PRIORITY_MAX + 1) / 2) |
Definition at line 61 of file sched.h.
Referenced by stk::pthread::ReaperTask::GetWeight(), pthread_attr_init(), pthread_create(), and stk::pthread::PthreadTask::PthreadTask().
| #define STK_C_SCHED_PRIORITY_MAX (31) |
Definition at line 58 of file sched.h.
Referenced by stk::pthread::IsValidSchedPriority(), and sched_get_priority_max().
| #define STK_C_SCHED_PRIORITY_MIN (0) |
Definition at line 55 of file sched.h.
Referenced by stk::pthread::IsValidSchedPriority(), and sched_get_priority_min().
| int sched_get_priority_max | ( | int | policy | ) |
Get the maximum priority of a scheduling policy.
| [in] | policy | SCHED_OTHER, SCHED_FIFO or SCHED_RR. |
Definition at line 2353 of file stk_c_pthread.cpp.
References stk::pthread::IsValidSchedPolicy(), and STK_C_SCHED_PRIORITY_MAX.
| int sched_get_priority_min | ( | int | policy | ) |
Get the minimum priority of a scheduling policy.
| [in] | policy | SCHED_OTHER, SCHED_FIFO or SCHED_RR. |
Definition at line 2337 of file stk_c_pthread.cpp.
References stk::pthread::IsValidSchedPolicy(), and STK_C_SCHED_PRIORITY_MIN.
| int sched_getparam | ( | pid_t | pid, |
| struct sched_param * | param ) |
Get the priority of the calling thread.
Definition at line 4495 of file stk_c_pthread.cpp.
References stk::pthread::PthreadTask::GetWeight(), sched_param::sched_priority, SchedTarget(), and pthread_stk_ctrl_t::task.
| int sched_getscheduler | ( | pid_t | pid | ) |
Get the scheduling policy of a thread.
| [in] | pid | 0 or the value of getpid() select the CALLING thread (STK has one process, its threads have no pids); any other value fails with ESRCH. |
Definition at line 4488 of file stk_c_pthread.cpp.
References stk::pthread::PthreadTask::GetPolicy(), SchedTarget(), and pthread_stk_ctrl_t::task.
| int sched_rr_get_interval | ( | pid_t | pid, |
| struct timespec * | tp ) |
Get the round-robin time slice: one kernel tick (stk::GetTickResolution()).
| [out] | tp | Receives the interval. |
Definition at line 4561 of file stk_c_pthread.cpp.
References SchedTarget(), and stk::pthread::TicksToTimespec().
| int sched_setparam | ( | pid_t | pid, |
| const struct sched_param * | param ) |
Set the priority of the calling thread, keeping its policy (see pthread_setschedprio()).
Definition at line 4539 of file stk_c_pthread.cpp.
References stk::pthread::PthreadTask::GetPolicy(), pthread_setschedparam(), SchedTarget(), and pthread_stk_ctrl_t::task.
| int sched_setscheduler | ( | pid_t | pid, |
| int | policy, | ||
| const struct sched_param * | param ) |
Set the policy and priority of the calling thread (see pthread_setschedparam()).
Definition at line 4516 of file stk_c_pthread.cpp.
References stk::pthread::PthreadTask::GetPolicy(), pthread_setschedparam(), SchedTarget(), and pthread_stk_ctrl_t::task.
| int sched_yield | ( | void | ) |
Yield the CPU to another ready task.
Definition at line 2331 of file stk_c_pthread.cpp.
References stk::Yield().
Referenced by thrd_yield().