ChibiOS/RT  6.0.3
chschd.h File Reference

Scheduler macros and structures. More...

Go to the source code of this file.

Data Structures

struct  ch_threads_list
 Generic threads single link list, it works like a stack. More...
 
struct  ch_threads_queue
 Generic threads bidirectional linked list header and element. More...
 
struct  ch_thread
 Structure representing a thread. More...
 
struct  ch_virtual_timer
 Virtual Timer descriptor structure. More...
 
struct  ch_virtual_timers_list
 Virtual timers list header. More...
 
struct  ch_system_debug
 System debug data structure. More...
 
struct  ch_system
 System data structure. More...
 

Macros

#define firstprio(rlp)   ((rlp)->next->prio)
 Returns the priority of the first thread on the given ready list. More...
 
#define currp   ch.rlist.current
 Current thread pointer access macro. More...
 
Wakeup status codes
#define MSG_OK   (msg_t)0
 Normal wakeup message. More...
 
#define MSG_TIMEOUT   (msg_t)-1
 Wakeup caused by a timeout condition. More...
 
#define MSG_RESET   (msg_t)-2
 Wakeup caused by a reset condition. More...
 
Priority constants
#define NOPRIO   (tprio_t)0
 Ready list header priority. More...
 
#define IDLEPRIO   (tprio_t)1
 Idle priority. More...
 
#define LOWPRIO   (tprio_t)2
 Lowest priority. More...
 
#define NORMALPRIO   (tprio_t)128
 Normal priority. More...
 
#define HIGHPRIO   (tprio_t)255
 Highest priority. More...
 
Thread states
#define CH_STATE_READY   (tstate_t)0
 Waiting on the ready list. More...
 
#define CH_STATE_CURRENT   (tstate_t)1
 Currently running. More...
 
#define CH_STATE_WTSTART   (tstate_t)2
 Just created. More...
 
#define CH_STATE_SUSPENDED   (tstate_t)3
 Suspended state. More...
 
#define CH_STATE_QUEUED   (tstate_t)4
 On a queue. More...
 
#define CH_STATE_WTSEM   (tstate_t)5
 On a semaphore. More...
 
#define CH_STATE_WTMTX   (tstate_t)6
 On a mutex. More...
 
#define CH_STATE_WTCOND   (tstate_t)7
 On a cond.variable. More...
 
#define CH_STATE_SLEEPING   (tstate_t)8
 Sleeping. More...
 
#define CH_STATE_WTEXIT   (tstate_t)9
 Waiting a thread. More...
 
#define CH_STATE_WTOREVT   (tstate_t)10
 One event. More...
 
#define CH_STATE_WTANDEVT   (tstate_t)11
 Several events. More...
 
#define CH_STATE_SNDMSGQ   (tstate_t)12
 Sending a message, in queue. More...
 
#define CH_STATE_SNDMSG   (tstate_t)13
 Sent a message, waiting answer. More...
 
#define CH_STATE_WTMSG   (tstate_t)14
 Waiting for a message. More...
 
#define CH_STATE_FINAL   (tstate_t)15
 Thread terminated. More...
 
#define CH_STATE_NAMES
 Thread states as array of strings. More...
 
Thread flags and attributes
#define CH_FLAG_MODE_MASK   (tmode_t)3U
 Thread memory mode mask. More...
 
#define CH_FLAG_MODE_STATIC   (tmode_t)0U
 Static thread. More...
 
#define CH_FLAG_MODE_HEAP   (tmode_t)1U
 Thread allocated from a Memory Heap. More...
 
#define CH_FLAG_MODE_MPOOL   (tmode_t)2U
 Thread allocated from a Memory Pool. More...
 
#define CH_FLAG_TERMINATE   (tmode_t)4U
 Termination requested flag. More...
 

Functions

void _scheduler_init (void)
 Scheduler initialization. More...
 
thread_tchSchReadyI (thread_t *tp)
 Inserts a thread in the Ready List placing it behind its peers. More...
 
thread_tchSchReadyAheadI (thread_t *tp)
 Inserts a thread in the Ready List placing it ahead its peers. More...
 
void chSchGoSleepS (tstate_t newstate)
 Puts the current thread to sleep into the specified state. More...
 
msg_t chSchGoSleepTimeoutS (tstate_t newstate, sysinterval_t timeout)
 Puts the current thread to sleep into the specified state with timeout specification. More...
 
void chSchWakeupS (thread_t *ntp, msg_t msg)
 Wakes up a thread. More...
 
void chSchRescheduleS (void)
 Performs a reschedule if a higher priority thread is runnable. More...
 
bool chSchIsPreemptionRequired (void)
 Evaluates if preemption is required. More...
 
void chSchDoRescheduleBehind (void)
 Switches to the first thread on the runnable queue. More...
 
void chSchDoRescheduleAhead (void)
 Switches to the first thread on the runnable queue. More...
 
void chSchDoReschedule (void)
 Switches to the first thread on the runnable queue. More...
 
void queue_prio_insert (thread_t *tp, threads_queue_t *tqp)
 Inserts a thread into a priority ordered queue. More...
 
void queue_insert (thread_t *tp, threads_queue_t *tqp)
 Inserts a thread into a queue. More...
 
thread_tqueue_fifo_remove (threads_queue_t *tqp)
 Removes the first-out thread from a queue and returns it. More...
 
thread_tqueue_lifo_remove (threads_queue_t *tqp)
 Removes the last-out thread from a queue and returns it. More...
 
thread_tqueue_dequeue (thread_t *tp)
 Removes a thread from a queue and returns it. More...
 
void list_insert (thread_t *tp, threads_list_t *tlp)
 Pushes a thread_t on top of a stack list. More...
 
thread_tlist_remove (threads_list_t *tlp)
 Pops a thread from the top of a stack list and returns it. More...
 
static void list_init (threads_list_t *tlp)
 Threads list initialization. More...
 
static bool list_isempty (threads_list_t *tlp)
 Evaluates to true if the specified threads list is empty. More...
 
static bool list_notempty (threads_list_t *tlp)
 Evaluates to true if the specified threads list is not empty. More...
 
static void queue_init (threads_queue_t *tqp)
 Threads queue initialization. More...
 
static bool queue_isempty (const threads_queue_t *tqp)
 Evaluates to true if the specified threads queue is empty. More...
 
static bool queue_notempty (const threads_queue_t *tqp)
 Evaluates to true if the specified threads queue is not empty. More...
 
static bool chSchIsRescRequiredI (void)
 Determines if the current thread must reschedule. More...
 
static bool chSchCanYieldS (void)
 Determines if yielding is possible. More...
 
static void chSchDoYieldS (void)
 Yields the time slot. More...
 
static void chSchPreemption (void)
 Inline-able preemption code. More...
 

Detailed Description

Scheduler macros and structures.

Definition in file chschd.h.