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