sched.h

Scheduler API definition.

SCHED_PRIO_LEVELS

The number of thread priority levels.

1
16
struct _thread thread_t

forward declaration for thread_t, defined in thread.h

unsigned int sched_context_switch_request

Flag indicating whether a context switch is necessary after handling an interrupt.

Supposed to be set in an ISR.

sched.h::thread_t * sched_threads()

Thread table.

sched.h::thread_t * sched_active_thread

Currently active thread.

int sched_num_threads

Number of running (non-terminated) threads.

kernel_types.h::kernel_pid_t sched_active_pid

Process ID of active thread.

clist.h::clist_node_t sched_runqueues()

List of runqueues per priority level.

int sched_run(void)

Triggers the scheduler to schedule the next thread.

Return values

  • 1 if sched_active_thread/sched_active_pid was changed, 0 otherwise.
void sched_set_status(sched.h::thread_t * process, unsigned int status)

Set the status of the specified process.

Parameters

process:Pointer to the thread control block of the targeted process
status:The new status of this thread

void sched_switch(uint16_t other_prio)

Yield if approriate.

Either yield if other_prio is higher than the current priority, or if the current thread is not on the runqueue.

Depending on whether the current execution is in an ISR (irq.h::irq_is_in()), thread.h::thread_yield_higher() is called or sched.h::sched_context_switch_request is set, respectively.

Parameters

other_prio:The priority of the target thread.

kernel_defines.h::NORETURN void cpu_switch_context_exit(void)

Call context switching at thread exit.

kernel_defines.h::NORETURN void sched_task_exit(void)

Removes thread from scheduler and set status to thread.h::STATUS_STOPPED.