Go to the documentation of this file.
105 #define KERNEL_PID_UNDEF 0
110 #define KERNEL_PID_FIRST (KERNEL_PID_UNDEF + 1)
115 #define KERNEL_PID_LAST (KERNEL_PID_FIRST + MAXTHREADS - 1)
120 #define PRIkernel_pid PRIi16
171 #define STATUS_ON_RUNQUEUE STATUS_RUNNING
173 #define STATUS_NOT_FOUND ((thread_status_t)-1)
179 #ifndef SCHED_PRIO_LEVELS
180 #define SCHED_PRIO_LEVELS 16
261 #if IS_USED(MODULE_SCHED_CB) || defined(DOXYGEN)
int16_t kernel_pid_t
Unique process identifier.
@ STATUS_STOPPED
has terminated
Add definitions required on the native board.
@ STATUS_REPLY_BLOCKED
waiting for a message response
Common macros and compiler attributes/pragmas configuration.
volatile int sched_num_threads
Number of running (non-terminated) threads.
void sched_register_cb(sched_callback_t callback)
Register a callback that will be called on every scheduler run.
static int pid_is_valid(kernel_pid_t pid)
Determine if the given pid is valid.
void(* sched_callback_t)(kernel_pid_t active, kernel_pid_t next)
Scheduler run callback.
@ STATUS_RUNNING
currently running
@ STATUS_RECEIVE_BLOCKED
waiting for a message
thread_t * sched_run(void)
Triggers the scheduler to schedule the next thread.
@ STATUS_ZOMBIE
has terminated & keeps thread's thread_t
#define KERNEL_PID_FIRST
The first valid PID (inclusive).
NORETURN void sched_task_exit(void)
Removes thread from scheduler and set status to STATUS_STOPPED.
@ STATUS_NUMOF
number of supported thread states
thread_t holds thread's context data.
NORETURN void cpu_switch_context_exit(void)
Call context switching at thread exit.
@ STATUS_PENDING
waiting to be scheduled to run
#define NORETURN
The NORETURN keyword tells the compiler to assume that the function cannot return.
volatile unsigned int sched_context_switch_request
Flag indicating whether a context switch is necessary after handling an interrupt.
@ STATUS_SEND_BLOCKED
waiting for message to be delivered
void sched_arch_idle(void)
Set CPU to idle mode (CPU dependent)
void sched_switch(uint16_t other_prio)
Yield if appropriate.
@ STATUS_MBOX_BLOCKED
waiting for get/put on mbox
@ STATUS_SLEEPING
sleeping
@ STATUS_MUTEX_BLOCKED
waiting for a locked mutex
#define SCHED_PRIO_LEVELS
The number of thread priority levels.
clist_node_t sched_runqueues[SCHED_PRIO_LEVELS]
List of runqueues per priority level.
volatile thread_t * sched_threads[KERNEL_PID_LAST+1]
Thread table.
#define KERNEL_PID_LAST
The last valid PID (inclusive).
void sched_set_status(thread_t *process, thread_status_t status)
Set the status of the specified process.
@ STATUS_COND_BLOCKED
waiting for a condition variable
Adds include for missing inttype definitions.
@ STATUS_FLAG_BLOCKED_ALL
waiting for all flags in flag_mask
thread_status_t status
thread's status
@ STATUS_FLAG_BLOCKED_ANY
waiting for any flag from flag_mask