ChibiOS 21.11.5
chschd.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006-2026 Giovanni Di Sirio.
3
4 This file is part of ChibiOS.
5
6 ChibiOS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation version 3 of the License.
9
10 ChibiOS is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/**
20 * @file rt/src/chschd.c
21 * @brief Scheduler code.
22 *
23 * @addtogroup scheduler
24 * @details This module provides the default portable scheduler code.
25 * @{
26 */
27
28#include "ch.h"
29
30/*===========================================================================*/
31/* Module local definitions. */
32/*===========================================================================*/
33
34/*===========================================================================*/
35/* Module exported variables. */
36/*===========================================================================*/
37
38/*===========================================================================*/
39/* Module local types. */
40/*===========================================================================*/
41
42/*===========================================================================*/
43/* Module local variables. */
44/*===========================================================================*/
45
46/*===========================================================================*/
47/* Module local functions. */
48/*===========================================================================*/
49
50/**
51 * @brief Inserts a thread in the Ready List placing it behind its peers.
52 * @details The thread is positioned behind all threads with higher or equal
53 * priority.
54 * @pre The thread must not be already inserted in any list through its
55 * @p next and @p prev or list corruption would occur.
56 * @post This function does not reschedule so a call to a rescheduling
57 * function must be performed before unlocking the kernel. Note that
58 * interrupt handlers always reschedule on exit so an explicit
59 * reschedule must not be performed in ISRs.
60 *
61 * @param[in] tp the thread to be made ready
62 * @return The thread pointer.
63 *
64 * @notapi
65 */
67
69 (tp->state != CH_STATE_FINAL),
70 "invalid state");
71
72 /* Tracing the event.*/
73 __trace_ready(tp, tp->u.rdymsg);
74
75 /* The thread is marked ready.*/
77
78 /* Insertion in the priority queue.*/
80 &tp->hdr.pqueue));
81}
82
83/**
84 * @brief Inserts a thread in the Ready List placing it ahead its peers.
85 * @details The thread is positioned ahead all threads with higher or equal
86 * priority.
87 * @pre The thread must not be already inserted in any list through its
88 * @p next and @p prev or list corruption would occur.
89 * @post This function does not reschedule so a call to a rescheduling
90 * function must be performed before unlocking the kernel. Note that
91 * interrupt handlers always reschedule on exit so an explicit
92 * reschedule must not be performed in ISRs.
93 *
94 * @param[in] tp the thread to be made ready
95 * @return The thread pointer.
96 *
97 * @notapi
98 */
100
102 (tp->state != CH_STATE_FINAL),
103 "invalid state");
104
105 /* Tracing the event.*/
106 __trace_ready(tp, tp->u.rdymsg);
107
108 /* The thread is marked ready.*/
109 tp->state = CH_STATE_READY;
110
111 /* Insertion in the priority queue.*/
113 &tp->hdr.pqueue));
114}
115
116/**
117 * @brief Switches to the first thread on the runnable queue.
118 * @details The current thread is positioned in the ready list behind all
119 * threads having the same priority. The thread regains its time
120 * quantum.
121 * @note Not a user function, it is meant to be invoked by the scheduler
122 * itself.
123 *
124 * @notapi
125 */
126static void __sch_reschedule_behind(void) {
127 os_instance_t *oip = currcore;
129 thread_t *ntp;
130
131 /* Picks the first thread from the ready queue and makes it current.*/
133 ntp->state = CH_STATE_CURRENT;
135
136 /* Handling idle-leave hook.*/
137 if (otp->hdr.pqueue.prio == IDLEPRIO) {
139 }
140
141#if CH_CFG_TIME_QUANTUM > 0
142 /* It went behind peers so it gets a new time quantum.*/
144#endif
145
146 /* Placing in ready list behind peers.*/
147 otp = __sch_ready_behind(otp);
148
149 /* Swap operation as tail call.*/
150 chSysSwitch(ntp, otp);
151}
152
153/**
154 * @brief Switches to the first thread on the runnable queue.
155 * @details The current thread is positioned in the ready list ahead of all
156 * threads having the same priority.
157 * @note Not a user function, it is meant to be invoked by the scheduler
158 * itself.
159 *
160 * @notapi
161 */
162static void __sch_reschedule_ahead(void) {
163 os_instance_t *oip = currcore;
165 thread_t *ntp;
166
167 /* Picks the first thread from the ready queue and makes it current.*/
169 ntp->state = CH_STATE_CURRENT;
171
172 /* Handling idle-leave hook.*/
173 if (otp->hdr.pqueue.prio == IDLEPRIO) {
175 }
176
177 /* Placing in ready list ahead of peers.*/
178 otp = __sch_ready_ahead(otp);
179
180 /* Swap operation as tail call.*/
181 chSysSwitch(ntp, otp);
182}
183
184/*
185 * Timeout wakeup callback.
186 */
187static void __sch_wakeup(virtual_timer_t *vtp, void *p) {
188 thread_t *tp = threadref(p);
189
190 (void)vtp;
191
193 switch (tp->state) {
194 case CH_STATE_READY:
195 /* Handling the special case where the thread has been made ready by
196 another thread with higher priority.*/
198 return;
200 *tp->u.wttrp = NULL;
201 break;
202#if CH_CFG_USE_SEMAPHORES == TRUE
203 case CH_STATE_WTSEM:
205#endif
206 /* Falls through.*/
207 case CH_STATE_QUEUED:
208 /* Falls through.*/
209#if CH_CFG_USE_MESSAGES == TRUE
210 case CH_STATE_SNDMSGQ:
211 /* Falls through.*/
212#endif
213#if (CH_CFG_USE_CONDVARS == TRUE) && (CH_CFG_USE_CONDVARS_TIMEOUT == TRUE)
214 case CH_STATE_WTCOND:
215#endif
216 /* States requiring dequeuing.*/
217 (void) ch_queue_dequeue(&tp->hdr.queue);
218 break;
219 default:
220 /* Any other state, nothing to do.*/
221 break;
222 }
223
224 /* Standard message for timeout conditions.*/
225 tp->u.rdymsg = MSG_TIMEOUT;
226
227 /* Goes behind peers because it went to sleep voluntarily.*/
228 (void) __sch_ready_behind(tp);
230
231 return;
232}
233
234/*===========================================================================*/
235/* Module exported functions. */
236/*===========================================================================*/
237
238#if (CH_CFG_OPTIMIZE_SPEED == FALSE) || defined(__DOXYGEN__)
239/**
240 * @brief Inserts a thread into a priority ordered queue.
241 * @note The insertion is done by scanning the list from the highest
242 * priority toward the lowest.
243 *
244 * @param[in] qp the pointer to the threads list header
245 * @param[in] tp the pointer to the thread to be inserted in the list
246 *
247 * @notapi
248 */
250
251 ch_queue_t *cp = qp;
252 do {
253 cp = cp->next;
254 } while ((cp != qp) &&
255 (threadref(cp)->hdr.pqueue.prio >= threadref(tp)->hdr.pqueue.prio));
256 tp->next = cp;
257 tp->prev = cp->prev;
258 tp->prev->next = tp;
259 cp->prev = tp;
260}
261#endif /* CH_CFG_OPTIMIZE_SPEED */
262
263/**
264 * @brief Inserts a thread in the Ready List placing it behind its peers.
265 * @details The thread is positioned behind all threads with higher or equal
266 * priority.
267 * @pre The thread must not be already inserted in any list through its
268 * @p next and @p prev or list corruption would occur.
269 * @post This function does not reschedule so a call to a rescheduling
270 * function must be performed before unlocking the kernel. Note that
271 * interrupt handlers always reschedule on exit so an explicit
272 * reschedule must not be performed in ISRs.
273 *
274 * @param[in] tp the thread to be made ready
275 * @return The thread pointer.
276 *
277 * @iclass
278 */
280
282 chDbgCheck(tp != NULL);
283
284#if CH_CFG_SMP_MODE == TRUE
285 if (tp->owner != currcore) {
286 /* Readying up the remote thread and triggering a reschedule on
287 the other core.*/
289 }
290#endif
291
292 return __sch_ready_behind(tp);
293}
294
295/**
296 * @brief Puts the current thread to sleep into the specified state.
297 * @details The thread goes into a sleeping state. The possible
298 * @ref thread_states are defined into @p chschd.h.
299 *
300 * @param[in] newstate the new thread state
301 *
302 * @sclass
303 */
304void chSchGoSleepS(tstate_t newstate) {
305 os_instance_t *oip = currcore;
307 thread_t *ntp;
308
310
311 chDbgAssert(otp != chSysGetIdleThreadX(), "sleeping in idle thread");
312 chDbgAssert(otp->owner == oip, "invalid core");
313
314 /* New state.*/
315 otp->state = newstate;
316
317#if CH_CFG_TIME_QUANTUM > 0
318 /* The thread is renouncing its remaining time slices so it will have a new
319 time quantum when it will wakeup.*/
321#endif
322
323 /* Next thread in ready list becomes current.*/
325 ntp->state = CH_STATE_CURRENT;
327
328 /* Handling idle-enter hook.*/
329 if (ntp->hdr.pqueue.prio == IDLEPRIO) {
331 }
332
333 /* Swap operation as tail call.*/
334 chSysSwitch(ntp, otp);
335}
336
337/**
338 * @brief Puts the current thread to sleep into the specified state with
339 * timeout specification.
340 * @details The thread goes into a sleeping state, if it is not awakened
341 * explicitly within the specified timeout then it is forcibly
342 * awakened with a @p MSG_TIMEOUT low level message. The possible
343 * @ref thread_states are defined into @p chschd.h.
344 *
345 * @param[in] newstate the new thread state
346 * @param[in] timeout the number of ticks before the operation timeouts, the
347 * special values are handled as follow:
348 * - @a TIME_INFINITE the thread enters an infinite sleep
349 * state, this is equivalent to invoking
350 * @p chSchGoSleepS() but, of course, less efficient.
351 * - @a TIME_IMMEDIATE this value is not allowed.
352 * .
353 * @return The wakeup message.
354 * @retval MSG_TIMEOUT if a timeout occurs.
355 *
356 * @sclass
357 */
360
362
363 if (TIME_INFINITE != timeout) {
365
366 chVTDoSetI(&vt, timeout, __sch_wakeup, (void *)tp);
367 chSchGoSleepS(newstate);
368 if (chVTIsArmedI(&vt)) {
369 chVTDoResetI(&vt);
370 }
371 }
372 else {
373 chSchGoSleepS(newstate);
374 }
375
376 return tp->u.rdymsg;
377}
378
379/**
380 * @brief Wakes up a thread.
381 * @details The thread is inserted into the ready list or immediately made
382 * running depending on its relative priority compared to the current
383 * thread.
384 * @pre The thread must not be already inserted in any list through its
385 * @p next and @p prev or list corruption would occur.
386 * @note It is equivalent to a @p chSchReadyI() followed by a
387 * @p chSchRescheduleS() but much more efficient.
388 * @note The function assumes that the current thread has the highest
389 * priority.
390 *
391 * @param[in] ntp the thread to be made ready
392 * @param[in] msg the wakeup message
393 *
394 * @sclass
395 */
396void chSchWakeupS(thread_t *ntp, msg_t msg) {
397 os_instance_t *oip = currcore;
399
401
402 chDbgAssert((oip->rlist.pqueue.next == &oip->rlist.pqueue) ||
403 (oip->rlist.current->hdr.pqueue.prio >= oip->rlist.pqueue.next->prio),
404 "priority order violation");
405
406 /* Storing the message to be retrieved by the target thread when it will
407 restart execution.*/
408 ntp->u.rdymsg = msg;
409
410#if CH_CFG_SMP_MODE == TRUE
411 if (ntp->owner != oip) {
412 /* Readying up the remote thread and triggering a reschedule on
413 the other core.*/
415 (void) __sch_ready_behind(ntp);
416 return;
417 }
418#endif
419
420 /* If the woken thread has a not-greater priority than the current
421 one then it is just inserted in the ready list else it made
422 running immediately and the invoking thread goes in the ready
423 list instead.
424 Note, we are favoring the path where the woken thread has higher
425 priority.*/
426 if (unlikely(ntp->hdr.pqueue.prio <= otp->hdr.pqueue.prio)) {
427 (void) __sch_ready_behind(ntp);
428 }
429 else {
430 /* The old thread goes back in the ready list ahead of its peers
431 because it has not exhausted its time slice.*/
432 otp = __sch_ready_ahead(otp);
433
434 /* Handling idle-leave hook.*/
435 if (otp->hdr.pqueue.prio == IDLEPRIO) {
437 }
438
439 /* The extracted thread is marked as current.*/
440 ntp->state = CH_STATE_CURRENT;
442
443 /* Swap operation as tail call.*/
444 chSysSwitch(ntp, otp);
445 }
446}
447
448/**
449 * @brief Performs a reschedule if a higher priority thread is runnable.
450 * @details If a thread with a higher priority than the current thread is in
451 * the ready list then make the higher priority thread running.
452 * @note Only local threads are considered, other cores are signaled
453 * and perform a reschedule locally.
454 *
455 * @sclass
456 */
458 os_instance_t *oip = currcore;
460
462
463 /* Note, we are favoring the path where the reschedule is necessary
464 because higher priority threads are ready.*/
465 if (likely(firstprio(&oip->rlist.pqueue) > tp->hdr.pqueue.prio)) {
467 }
468}
469
470#if !defined(CH_SCH_IS_PREEMPTION_REQUIRED_HOOKED)
471/**
472 * @brief Evaluates if preemption is required.
473 * @details The decision is taken by comparing the relative priorities and
474 * depending on the state of the round robin timeout counter.
475 * @note Not a user function, it is meant to be invoked from within
476 * the port layer in the IRQ-related preemption code.
477 *
478 * @retval true if there is a thread that must go in running state
479 * immediately.
480 * @retval false if preemption is not required.
481 *
482 * @special
483 */
485 os_instance_t *oip = currcore;
487
488 tprio_t p1 = firstprio(&oip->rlist.pqueue);
489 tprio_t p2 = tp->hdr.pqueue.prio;
490
491#if CH_CFG_TIME_QUANTUM > 0
492 /* If the running thread has not reached its time quantum, reschedule only
493 if the first thread on the ready queue has a higher priority.
494 Otherwise, if the running thread has used up its time quantum, reschedule
495 if the first thread on the ready queue has equal or higher priority.*/
496 return (tp->ticks > (tslices_t)0) ? (p1 > p2) : (p1 >= p2);
497#else
498 /* If the round robin preemption feature is not enabled then performs a
499 simpler comparison.*/
500 return p1 > p2;
501#endif
502}
503#endif /* !defined(CH_SCH_IS_PREEMPTION_REQUIRED_HOOKED) */
504
505#if !defined(CH_SCH_DO_PREEMPTION_HOOKED)
506/**
507 * @brief Switches to the first thread on the runnable queue.
508 * @details The current thread is positioned in the ready list behind or
509 * ahead of all threads having the same priority depending on
510 * if it used its whole time slice.
511 * @note Not a user function, it is meant to be invoked from within
512 * the port layer in the IRQ-related preemption code.
513 *
514 * @special
515 */
517 os_instance_t *oip = currcore;
519 thread_t *ntp;
520
521 /* Picks the first thread from the ready queue and makes it current.*/
523 ntp->state = CH_STATE_CURRENT;
525
526 /* Handling idle-leave hook.*/
527 if (otp->hdr.pqueue.prio == IDLEPRIO) {
529 }
530
531#if CH_CFG_TIME_QUANTUM > 0
532 /* If CH_CFG_TIME_QUANTUM is enabled then there are two different scenarios
533 to handle on preemption: time quantum elapsed or not.*/
534 if (otp->ticks == (tslices_t)0) {
535
536 /* The thread consumed its time quantum so it is enqueued behind threads
537 with same priority level, however, it acquires a new time quantum.*/
538 otp = __sch_ready_behind(otp);
539
540 /* The thread being swapped out receives a new time quantum.*/
542 }
543 else {
544 /* The thread didn't consume all its time quantum so it is put ahead of
545 threads with equal priority and does not acquire a new time quantum.*/
546 otp = __sch_ready_ahead(otp);
547 }
548#else /* !(CH_CFG_TIME_QUANTUM > 0) */
549 /* If the round-robin mechanism is disabled then the thread goes always
550 ahead of its peers.*/
551 otp = __sch_ready_ahead(otp);
552#endif /* !(CH_CFG_TIME_QUANTUM > 0) */
553
554 /* Swap operation as tail call.*/
555 chSysSwitch(ntp, otp);
556}
557#endif /* !defined(CH_SCH_DO_PREEMPTION_HOOKED) */
558
559#if !defined(CH_SCH_PREEMPTION_HOOKED)
560/**
561 * @brief All-in-one preemption code.
562 * @note Not a user function, it is meant to be invoked from within
563 * the port layer in the IRQ-related preemption code.
564 *
565 * @special
566 */
567void chSchPreemption(void) {
568 os_instance_t *oip = currcore;
570 tprio_t p1 = firstprio(&oip->rlist.pqueue);
571 tprio_t p2 = tp->hdr.pqueue.prio;
572
573 /* Note, we are favoring the path where preemption is necessary
574 because higher priority threads are ready.*/
575#if CH_CFG_TIME_QUANTUM > 0
576 if (tp->ticks > (tslices_t)0) {
577 if (likely(p1 > p2)) {
579 }
580 }
581 else {
582 if (likely(p1 >= p2)) {
584 }
585 }
586#else /* CH_CFG_TIME_QUANTUM == 0 */
587 if (likely(p1 > p2)) {
589 }
590#endif /* CH_CFG_TIME_QUANTUM == 0 */
591}
592#endif /* !defined(CH_SCH_PREEMPTION_HOOKED) */
593
594/**
595 * @brief Yields the time slot.
596 * @details Yields the CPU control to the next thread in the ready list with
597 * equal or higher priority, if any.
598 *
599 * @sclass
600 */
601void chSchDoYieldS(void) {
602 os_instance_t *oip = currcore;
604
606
607 /* If this function has been called then it is likely there are threads
608 at same priority level.*/
609 if (likely(firstprio(&oip->rlist.pqueue) >= tp->hdr.pqueue.prio)) {
611 }
612}
613
614/**
615 * @brief Makes runnable the fist thread in the ready list, does not
616 * reschedule internally.
617 * @details The current thread is positioned in the ready list ahead of all
618 * threads having the same priority.
619 * @note Not a user function, it is meant to be invoked by the scheduler
620 * itself.
621 *
622 * @return The pointer to the thread being switched in.
623 *
624 * @special
625 */
627 os_instance_t *oip = currcore;
629 thread_t *ntp;
630
631 /* Picks the first thread from the ready queue and makes it current.*/
633 ntp->state = CH_STATE_CURRENT;
635
636 /* Handling idle-leave hook.*/
637 if (otp->hdr.pqueue.prio == IDLEPRIO) {
639 }
640
641 /* Placing in ready list ahead of peers.*/
642 (void) __sch_ready_ahead(otp);
643
644 return ntp;
645}
646
647/** @} */
#define chSysLockFromISR()
Enters the kernel lock state from within an interrupt handler.
#define chSchWakeupS(ntp, msg)
Wakes up a thread.
#define chSchGoSleepS(newstate)
Puts the current thread to sleep into the specified state.
#define chSysUnlockFromISR()
Leaves the kernel lock state from within an interrupt handler.
#define chSemFastSignalI(sp)
Increases the semaphore counter.
#define chDbgAssert(c, r)
Condition assertion.
Definition chdebug.h:143
#define chDbgCheck(c)
Function parameters check.
Definition chdebug.h:117
#define chDbgCheckClassS()
Definition chdebug.h:99
#define chDbgCheckClassI()
Definition chdebug.h:98
#define CH_CFG_TIME_QUANTUM
Round robin interval.
#define CH_CFG_IDLE_LEAVE_HOOK()
Idle thread leave hook.
#define CH_CFG_IDLE_ENTER_HOOK()
Idle thread enter hook.
#define __instance_set_currthread(oip, tp)
Current thread pointer set macro.
Definition chinstances.h:60
#define __instance_get_currthread(oip)
Current thread pointer get macro.
Definition chinstances.h:55
static ch_priority_queue_t * ch_pqueue_insert_ahead(ch_priority_queue_t *pqp, ch_priority_queue_t *p)
Inserts an element in the priority queue placing it ahead of its peers.
Definition chlists.h:401
static ch_priority_queue_t * ch_pqueue_remove_highest(ch_priority_queue_t *pqp)
Removes the highest priority element from a priority queue and returns it.
Definition chlists.h:351
static ch_queue_t * ch_queue_dequeue(ch_queue_t *p)
Removes an element from a queue and returns it.
Definition chlists.h:317
struct ch_queue ch_queue_t
Type of a generic bidirectional linked list header and element.
Definition chlists.h:62
static ch_priority_queue_t * ch_pqueue_insert_behind(ch_priority_queue_t *pqp, ch_priority_queue_t *p)
Inserts an element in the priority queue placing it behind its peers.
Definition chlists.h:372
#define threadref(p)
Safe cast of a queue pointer to a thread pointer.
Definition chearly.h:205
#define likely(x)
Marks a boolean expression as likely true.
Definition chearly.h:177
struct ch_virtual_timer virtual_timer_t
Type of a Virtual Timer.
Definition chobjects.h:59
int32_t msg_t
Definition chearly.h:87
uint8_t tstate_t
Definition chearly.h:83
uint32_t tprio_t
Definition chearly.h:86
struct ch_os_instance os_instance_t
Type of an OS instance structure.
Definition chearly.h:137
uint8_t tslices_t
Definition chearly.h:85
#define unlikely(x)
Marks a boolean expression as likely false.
Definition chearly.h:190
struct ch_thread thread_t
Type of a thread structure.
Definition chearly.h:132
#define CH_STATE_READY
Waiting on the ready list.
Definition chschd.h:61
#define CH_STATE_FINAL
Thread terminated.
Definition chschd.h:80
thread_t * chSchSelectFirst(void)
Makes runnable the fist thread in the ready list, does not reschedule internally.
Definition chschd.c:626
#define CH_STATE_CURRENT
Currently running.
Definition chschd.h:63
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
Definition chschd.c:457
#define CH_STATE_WTCOND
On a cond.variable.
Definition chschd.h:69
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
Definition chschd.c:279
#define CH_STATE_QUEUED
On a queue.
Definition chschd.h:66
static thread_t * __sch_ready_behind(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
Definition chschd.c:66
void chSchDoYieldS(void)
Yields the time slot.
Definition chschd.c:601
#define CH_STATE_SUSPENDED
Suspended state.
Definition chschd.h:65
static void __sch_reschedule_behind(void)
Switches to the first thread on the runnable queue.
Definition chschd.c:126
void chSchPreemption(void)
All-in-one preemption code.
Definition chschd.c:567
bool chSchIsPreemptionRequired(void)
Evaluates if preemption is required.
Definition chschd.c:484
#define firstprio(rlp)
Returns the priority of the first thread on the given ready list.
Definition chschd.h:129
static void __sch_wakeup(virtual_timer_t *vtp, void *p)
Definition chschd.c:187
#define MSG_TIMEOUT
Wakeup caused by a timeout condition.
Definition chschd.h:39
void ch_sch_prio_insert(ch_queue_t *qp, ch_queue_t *tp)
Inserts a thread into a priority ordered queue.
Definition chschd.c:249
static thread_t * __sch_ready_ahead(thread_t *tp)
Inserts a thread in the Ready List placing it ahead its peers.
Definition chschd.c:99
#define IDLEPRIO
Idle priority.
Definition chschd.h:51
#define CH_STATE_SNDMSGQ
Sending a message, in queue.
Definition chschd.h:74
void chSchDoPreemption(void)
Switches to the first thread on the runnable queue.
Definition chschd.c:516
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
Definition chschd.c:358
static void __sch_reschedule_ahead(void)
Switches to the first thread on the runnable queue.
Definition chschd.c:162
#define CH_STATE_WTSEM
On a semaphore.
Definition chschd.h:67
#define chSysSwitch(ntp, otp)
Performs a context switch.
Definition chsys.h:304
thread_t * chSysGetIdleThreadX(void)
Returns a pointer to the idle thread.
Definition chsys.c:247
#define currcore
Access to current core's instance structure.
Definition chsys.h:89
static void chSysNotifyInstance(os_instance_t *oip)
Notifies an OS instance to check for reschedule.
Definition chsys.h:521
uint64_t sysinterval_t
Type of time interval.
Definition chtime.h:118
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
Definition chtime.h:54
void chVTDoSetI(virtual_timer_t *vtp, sysinterval_t delay, vtfunc_t vtfunc, void *par)
Enables a one-shot virtual timer.
Definition chvt.c:276
static bool chVTIsArmedI(const virtual_timer_t *vtp)
Returns true if the specified timer is armed.
Definition chvt.h:247
void chVTDoResetI(virtual_timer_t *vtp)
Disables a Virtual Timer.
Definition chvt.c:337
#define __trace_ready(tp, msg)
Definition chtrace.h:220
ready_list_t rlist
Ready list header.
Definition chobjects.h:407
ch_priority_queue_t * next
Next in the queue.
Definition chlists.h:85
tprio_t prio
Priority of this element.
Definition chlists.h:87
ch_queue_t * prev
Previous in the queue.
Definition chlists.h:70
ch_queue_t * next
Next in the list/queue.
Definition chlists.h:69
thread_t * current
The currently running thread.
Definition chobjects.h:366
ch_priority_queue_t pqueue
Threads ordered queues header.
Definition chobjects.h:362
ch_queue_t queue
Threads queues element.
Definition chobjects.h:165
union ch_thread::@065317322233202114332352372014266163076165303275 hdr
Shared list headers.
msg_t rdymsg
Thread wakeup code.
Definition chobjects.h:239
thread_reference_t * wttrp
Pointer to a generic thread reference object.
Definition chobjects.h:260
tslices_t ticks
Number of ticks remaining to this thread.
Definition chobjects.h:218
tstate_t state
Current thread state.
Definition chobjects.h:203
ch_priority_queue_t pqueue
Threads ordered queues element.
Definition chobjects.h:169
struct ch_semaphore * wtsemp
Pointer to a generic semaphore object.
Definition chobjects.h:268
union ch_thread::@250330312022121344252011223135034045240103044261 u
State-specific fields.
os_instance_t * owner
OS instance owner of this thread.
Definition chobjects.h:184