Scheduler API definition. More...
Scheduler API definition.
Definition in file sched.h.
#include <stddef.h>#include <inttypes.h>#include "kernel_defines.h"#include "native_sched.h"#include "clist.h" Include dependency graph for sched.h:
 Include dependency graph for sched.h: This graph shows which files directly or indirectly include this file:
 This graph shows which files directly or indirectly include this file:Go to the source code of this file.
| Macros | |
| #define | MAXTHREADS 0 | 
| The maximum number of threads to be scheduled. | |
| #define | KERNEL_PID_UNDEF 0 | 
| Canonical identifier for an invalid PID. | |
| #define | KERNEL_PID_FIRST (KERNEL_PID_UNDEF + 1) | 
| The first valid PID (inclusive). | |
| #define | KERNEL_PID_LAST (KERNEL_PID_FIRST + MAXTHREADS - 1) | 
| The last valid PID (inclusive). | |
| #define | PRIkernel_pid PRIi16 | 
| Macro for printing formatter. | |
| #define | SCHED_TEST_STACK 1 | 
| Enables detection of stack overflows and measures stack usage when != 0. | |
| #define | SCHED_PRIO_LEVELS 16 | 
| The number of thread priority levels. | |
| Typedefs | |
| typedef int16_t | kernel_pid_t | 
| Unique process identifier. | |
| typedef struct _thread | thread_t | 
| forward declaration for thread_t, defined in thread.h | |
| typedef void(* | sched_callback_t) (kernel_pid_t active, kernel_pid_t next) | 
| Scheduler run callback.  More... | |
| Functions | |
| static int | pid_is_valid (kernel_pid_t pid) | 
| Determine if the given pid is valid.  More... | |
| thread_t * | sched_run (void) | 
| Triggers the scheduler to schedule the next thread.  More... | |
| void | sched_set_status (thread_t *process, thread_status_t status) | 
| Set the status of the specified process.  More... | |
| void | sched_switch (uint16_t other_prio) | 
| Yield if appropriate.  More... | |
| NORETURN void | cpu_switch_context_exit (void) | 
| Call context switching at thread exit. | |
| NORETURN void | sched_task_exit (void) | 
| Removes thread from scheduler and set status to STATUS_STOPPED. | |
| void | sched_change_priority (thread_t *thread, uint8_t priority) | 
| Change the priority of the given thread.  More... | |
| void | sched_arch_idle (void) | 
| Set CPU to idle mode (CPU dependent)  More... | |
| void | sched_register_cb (sched_callback_t callback) | 
| Register a callback that will be called on every scheduler run.  More... | |
| static void | sched_runq_advance (uint8_t prio) | 
| Advance a runqueue.  More... | |
| void | sched_runq_callback (uint8_t prio) | 
| Scheduler runqueue (change) callback.  More... | |
| static int | sched_runq_is_empty (uint8_t prio) | 
| Tell if the number of threads in a runqueue is 0.  More... | |
| static int | sched_runq_exactly_one (uint8_t prio) | 
| Tell if the number of threads in a runqueue is 1.  More... | |
| static int | sched_runq_more_than_one (uint8_t prio) | 
| Tell if the number of threads in a runqueue greater than 1.  More... | |
| Variables | |
| volatile unsigned int | sched_context_switch_request | 
| Flag indicating whether a context switch is necessary after handling an interrupt.  More... | |
| volatile thread_t * | sched_threads [KERNEL_PID_LAST+1] | 
| Thread table. | |
| volatile int | sched_num_threads | 
| Number of running (non-terminated) threads. | |
| clist_node_t | sched_runqueues [SCHED_PRIO_LEVELS] | 
| List of runqueues per priority level. | |
| Helpers to work with thread states | |
| #define | STATUS_ON_RUNQUEUE STATUS_RUNNING | 
| to check if on run queue: st >= STATUS_ON_RUNQUEUE | |
| #define | STATUS_NOT_FOUND ((thread_status_t)~0) | 
| Describes an illegal thread status. | |
| Thread states supported by RIOT | |
| Keep in sync with OpenOCD src/rtos/riot.c | |
| enum | thread_status_t { STATUS_STOPPED , STATUS_ZOMBIE , STATUS_SLEEPING , STATUS_MUTEX_BLOCKED , STATUS_RECEIVE_BLOCKED , STATUS_SEND_BLOCKED , STATUS_REPLY_BLOCKED , STATUS_FLAG_BLOCKED_ANY , STATUS_FLAG_BLOCKED_ALL , STATUS_MBOX_BLOCKED , STATUS_COND_BLOCKED , STATUS_RUNNING , STATUS_PENDING , STATUS_NUMOF } |