39 #define MSG_OK (msg_t)0 40 #define MSG_TIMEOUT (msg_t)-1 42 #define MSG_RESET (msg_t)-2 50 #define NOPRIO (tprio_t)0 52 #define IDLEPRIO (tprio_t)1 53 #define LOWPRIO (tprio_t)2 54 #define NORMALPRIO (tprio_t)128 55 #define HIGHPRIO (tprio_t)255 62 #define CH_STATE_READY (tstate_t)0 64 #define CH_STATE_CURRENT (tstate_t)1 65 #define CH_STATE_WTSTART (tstate_t)2 66 #define CH_STATE_SUSPENDED (tstate_t)3 67 #define CH_STATE_QUEUED (tstate_t)4 68 #define CH_STATE_WTSEM (tstate_t)5 69 #define CH_STATE_WTMTX (tstate_t)6 70 #define CH_STATE_WTCOND (tstate_t)7 71 #define CH_STATE_SLEEPING (tstate_t)8 72 #define CH_STATE_WTEXIT (tstate_t)9 73 #define CH_STATE_WTOREVT (tstate_t)10 74 #define CH_STATE_WTANDEVT (tstate_t)11 75 #define CH_STATE_SNDMSGQ (tstate_t)12 77 #define CH_STATE_SNDMSG (tstate_t)13 79 #define CH_STATE_WTMSG (tstate_t)14 81 #define CH_STATE_FINAL (tstate_t)15 88 #define CH_STATE_NAMES \ 89 "READY", "CURRENT", "WTSTART", "SUSPENDED", "QUEUED", "WTSEM", "WTMTX", \ 90 "WTCOND", "SLEEPING", "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", \ 91 "SNDMSG", "WTMSG", "FINAL" 98 #define CH_FLAG_MODE_MASK (tmode_t)3U 100 #define CH_FLAG_MODE_STATIC (tmode_t)0U 101 #define CH_FLAG_MODE_HEAP (tmode_t)1U 103 #define CH_FLAG_MODE_MPOOL (tmode_t)2U 105 #define CH_FLAG_TERMINATE (tmode_t)4U 145 struct port_context ctx;
146 #if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) 151 #if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) 157 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) || \ 174 #if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) 183 #if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__) 186 #if (CH_DBG_THREADS_PROFILING == TRUE) || defined(__DOXYGEN__) 227 #if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__) 233 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 242 #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) 251 #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__) 260 #if (CH_CFG_USE_WAITEXIT == TRUE) || defined(__DOXYGEN__) 266 #if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__) 272 #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__) 276 eventmask_t epending;
278 #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) 289 #if ((CH_CFG_USE_DYNAMIC == TRUE) && (CH_CFG_USE_MEMPOOLS == TRUE)) || \ 296 #if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__) 302 #if defined(CH_CFG_THREAD_EXTRA_FIELDS) 335 #if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__) 338 #if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__) 350 struct ch_ready_list {
354 struct port_context ctx;
356 #if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) 376 const char *
volatile panic_msg;
377 #if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__) 387 #if (CH_DBG_TRACE_MASK != CH_DBG_TRACE_MASK_DISABLED) || defined(__DOXYGEN__) 417 #if (CH_CFG_USE_TM == TRUE) || defined(__DOXYGEN__) 423 #if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__) 441 #define firstprio(rlp) ((rlp)->next->prio) 448 #define currp ch.rlist.current 454 #if !defined(__DOXYGEN__) 475 #if CH_CFG_OPTIMIZE_SPEED == FALSE 571 #if CH_CFG_OPTIMIZE_SPEED == TRUE 694 tprio_t p2 =
currp->prio;
696 #if CH_CFG_TIME_QUANTUM > 0 697 if (
currp->ticks > (tslices_t)0) {
void _scheduler_init(void)
Scheduler initialization.
System debug data structure.
static void chSchPreemption(void)
Inline-able preemption code.
uint64_t systime_t
Type of system time.
uint64_t sysinterval_t
Type of time interval.
tprio_t prio
Thread priority.
void chSchDoRescheduleBehind(void)
Switches to the first thread on the runnable queue.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
void queue_prio_insert(thread_t *tp, threads_queue_t *tqp)
Inserts a thread into a priority ordered queue.
Type of a time measurement calibration data.
#define firstprio(rlp)
Returns the priority of the first thread on the given ready list.
Generic threads bidirectional linked list header and element.
#define currp
Current thread pointer access macro.
#define CH_CFG_SYSTEM_EXTRA_FIELDS
System structure extension.
Type of a Time Measurement object.
static void list_init(threads_list_t *tlp)
Threads list initialization.
static void chSchDoYieldS(void)
Yields the time slot.
struct ch_ready_list ready_list_t
Type of a ready list header.
thread_t * next
Next in the list/queue.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
static bool list_notempty(threads_list_t *tlp)
Evaluates to true if the specified threads list is not empty.
thread_t * next
Next in the list/queue.
void(* vtfunc_t)(void *p)
Type of a Virtual Timer callback function.
Virtual timers list header.
bool chSchIsPreemptionRequired(void)
Evaluates if preemption is required.
void chSchGoSleepS(tstate_t newstate)
Puts the current thread to sleep into the specified state.
static void queue_init(threads_queue_t *tqp)
Threads queue initialization.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
thread_t * list_remove(threads_list_t *tlp)
Pops a thread from the top of a stack list and returns it.
static bool chSchIsRescRequiredI(void)
Determines if the current thread must reschedule.
ready_list_t rlist
Ready list header.
ch_system_t ch
System data structures.
static bool chSchCanYieldS(void)
Determines if yielding is possible.
Generic threads single link list, it works like a stack.
void queue_insert(thread_t *tp, threads_queue_t *tqp)
Inserts a thread into a queue.
thread_t * prev
Previous in the queue.
thread_t * queue_lifo_remove(threads_queue_t *tqp)
Removes the last-out thread from a queue and returns it.
static bool queue_isempty(const threads_queue_t *tqp)
Evaluates to true if the specified threads queue is empty.
void chSchDoRescheduleAhead(void)
Switches to the first thread on the runnable queue.
#define CH_CFG_THREAD_EXTRA_FIELDS
Threads descriptor structure extension.
Virtual Timer descriptor structure.
Type of a kernel statistics structure.
static bool list_isempty(threads_list_t *tlp)
Evaluates to true if the specified threads list is empty.
void chDbgCheckClassI(void)
I-class functions context check.
thread_t * queue_dequeue(thread_t *tp)
Removes a thread from a queue and returns it.
static bool queue_notempty(const threads_queue_t *tqp)
Evaluates to true if the specified threads queue is not empty.
void chSchWakeupS(thread_t *ntp, msg_t msg)
Wakes up a thread.
void chDbgCheckClassS(void)
S-class functions context check.
thread_t * chSchReadyAheadI(thread_t *tp)
Inserts a thread in the Ready List placing it ahead its peers.
void list_insert(thread_t *tp, threads_list_t *tlp)
Pushes a thread_t on top of a stack list.
thread_t * queue_fifo_remove(threads_queue_t *tqp)
Removes the first-out thread from a queue and returns it.
threads_queue_t queue
Threads queue header.
void chSchDoReschedule(void)
Switches to the first thread on the runnable queue.
Structure representing a thread.