75 if ((tp->
state == state) && (tp->u1.p == p)) {
98 while (cnt < (
cnt_t)0) {
101 "pointer out of range");
114#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
291#if CH_DBG_ENABLE_STACK_CHECK == TRUE
300#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
304#if CH_CFG_AUTOSTART_THREADS == TRUE
306 tdp = nil_thd_configs;
310 }
while (tdp->
funcp != NULL);
335 nil.dbg_panic_msg = reason;
359#if CH_CFG_ST_TIMEDELTA == 0
373#if CH_CFG_USE_SEMAPHORES == TRUE
396 chDbgAssert(
nil.nexttime == port_timer_get_alarm(),
"time mismatch");
410 tp->timeout = timeout;
439 nil.lasttime =
nil.nexttime;
442 port_timer_set_alarm(
nil.nexttime);
446 port_timer_stop_alarm();
451#if (CH_PORT_SUPPORTS_RECURSIVE_LOCKS == TRUE) || defined(__DOXYGEN__)
534#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
675 "idle cannot sleep");
678 otp->
state = newstate;
680#if CH_CFG_ST_TIMEDELTA > 0
693 if (
nil.lasttime ==
nil.nexttime) {
695 port_timer_start_alarm(abstime);
696 nil.nexttime = abstime;
702 port_timer_set_alarm(abstime);
703 nil.nexttime = abstime;
708 otp->timeout = abstime -
nil.lasttime;
713 otp->timeout = timeout;
721 nil.current =
nil.next = ntp;
726 return nil.current->u1.msg;
732 "pointer out of range");
771 (tdp->
wbase != NULL) &&
775 (tdp->
funcp != NULL));
782 "priority slot taken");
784#if CH_CFG_USE_EVENTS == TRUE
787#if CH_DBG_ENABLE_STACK_CHECK == TRUE
845#if CH_CFG_USE_WAITEXIT == TRUE
860 nil.current->u1.msg = msg;
884 nil.current->u1.tp = tp;
916 nil.current->u1.trp = trp;
1020 nil.current->u1.tqp = tqp;
1062 if (tqp->cnt < (
cnt_t)0) {
#define CH_CFG_THREAD_EXT_INIT_HOOK(tr)
Threads initialization hook.
#define CH_CFG_MAX_THREADS
Maximum number of user threads in the application.
msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread on a threads queue object.
syssts_t chSysGetStatusAndLockX(void)
Returns the execution status and enters a critical zone.
#define NIL_STATE_READY
Thread ready or executing.
#define chSchIsRescRequiredI()
Evaluates if a reschedule is required.
void chDbgCheckClassS(void)
S-class functions context check.
void __dbg_check_disable(void)
Guard code for chSysDisable().
bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end)
Realtime window test.
void chSysTimerHandlerI(void)
Time management handler.
void chThdExit(msg_t msg)
Terminates the current thread.
void __dbg_check_unlock(void)
Guard code for chSysUnlock().
#define chSysSuspend()
Raises the system interrupt priority mask to system level.
#define __dbg_enter_lock()
#define NIL_STATE_WTEXIT
Waiting a thread.
void chDbgCheckClassI(void)
I-class functions context check.
msg_t chThdWait(thread_t *tp)
Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...
void chThdResume(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
msg_t chThdSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout)
Sends the current thread sleeping and sets a reference variable.
#define chSysLockFromISR()
Enters the kernel lock state from within an interrupt handler.
void chSchRescheduleS(void)
Reschedules if needed.
void chSysPolledDelayX(rtcnt_t cycles)
Polled delay.
thread_t * chThdCreateI(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
void chThdResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
#define chTimeAddX(systime, interval)
Adds an interval to a system time returning a system time.
#define chSysUnlock()
Leaves the kernel lock state.
os_instance_t nil
System data structures.
cnt_t nil_ready_all(void *p, cnt_t cnt, msg_t msg)
Puts in ready state all thread matching the specified status and associated object.
#define NIL_STATE_WTQUEUE
On queue or semaph.
#define NIL_STATE_SUSPENDED
Thread suspended.
void chThdSleepUntil(systime_t abstime)
Suspends the invoking thread until the system time arrives to the specified value.
void __dbg_check_lock(void)
Guard code for chSysLock().
#define NIL_THD_IS_FINAL(tp)
#define chThdSleepUntilS(abstime)
Suspends the invoking thread until the system time arrives to the specified value.
void chSysRestoreStatusX(syssts_t sts)
Restores the specified execution status and leaves a critical zone.
#define chThdResumeS(trp, msg)
Wakes up a thread waiting on a thread reference object.
#define chSysLock()
Enters the kernel lock state.
void chThdSleep(sysinterval_t timeout)
Suspends the invoking thread for the specified time.
bool chSchIsPreemptionRequired(void)
Evaluates if preemption is required.
void __dbg_check_leave_isr(void)
Guard code for CH_IRQ_EPILOGUE().
void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object, if any.
#define NIL_STATE_FINAL
Thread terminated.
void chSysUnconditionalUnlock(void)
Unconditionally leaves the kernel lock state.
bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
#define NIL_THD_IS_SUSPENDED(tp)
#define chVTGetSystemTimeX()
Current system time.
#define chThdSleepS(timeout)
Suspends the invoking thread for the specified time.
#define chTimeDiffX(start, end)
Subtracts two system times returning an interval.
#define NIL_THD_IS_WTSTART(tp)
void __dbg_check_enable(void)
Guard code for chSysEnable().
void __dbg_check_lock_from_isr(void)
Guard code for chSysLockFromIsr().
void __dbg_check_unlock_from_isr(void)
Guard code for chSysUnlockFromIsr().
thread_t * chSchReadyI(thread_t *tp, msg_t msg)
Makes the specified thread ready for execution.
#define __dbg_leave_lock()
thread_t * chThdCreate(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
thread_t * nil_find_thread(tstate_t state, void *p)
Retrieves the highest priority thread in the specified state and associated to the specified object.
#define chSysUnlockFromISR()
Leaves the kernel lock state from within an interrupt handler.
void chSchDoPreemption(void)
Switches to the first thread on the runnable queue.
#define NIL_THD_IS_READY(tp)
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object.
void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the threads queue object.
void __dbg_check_enter_isr(void)
Guard code for CH_IRQ_PROLOGUE().
#define NIL_THD_IS_WTQUEUE(tp)
void __dbg_check_suspend(void)
Guard code for chSysSuspend().
void chSysUnconditionalLock(void)
Unconditionally enters the kernel lock state.
void chSysInit(void)
Initializes the kernel.
void chSysHalt(const char *reason)
Halts the system.
#define chDbgAssert(c, r)
Condition assertion.
#define chDbgCheck(c)
Function parameters check.
#define CH_CFG_SYSTEM_HALT_HOOK(reason)
System halt hook.
#define CH_CFG_IDLE_LEAVE_HOOK()
Idle thread leave hook.
#define CH_CFG_IDLE_ENTER_HOOK()
Idle thread enter hook.
#define CH_CFG_THREAD_EXIT_HOOK(tp)
Threads finalization hook.
#define CH_CFG_SYSTEM_INIT_HOOK()
System initialization hook.
#define MEM_IS_ALIGNED(p, a)
Returns whatever a pointer or memory size is aligned.
struct ch_os_instance os_instance_t
Type of an OS instance structure.
thread_t * thread_reference_t
Type of a thread reference.
port_stkalign_t stkalign_t
struct ch_thread thread_t
Type of a thread structure.
static void __oslib_init(void)
Initialization of all library modules.
static void port_unlock_from_isr(void)
Kernel-unlock action from an interrupt handler.
#define PORT_WORKING_AREA_ALIGN
Working Areas alignment constant.
static void port_disable(void)
Disables all the interrupt sources.
static void port_lock_from_isr(void)
Kernel-lock action from an interrupt handler.
#define PORT_STACK_ALIGN
Stack alignment constant.
#define PORT_SETUP_CONTEXT(tp, wbase, wtop, pf, arg)
Platform dependent part of the chThdCreateI() API.
#define port_get_lock_status()
Returns a word representing a critical section status.
#define port_is_locked(sts)
Determines if in a critical section.
static bool port_is_isr_context(void)
Determines the current execution context.
#define port_switch(ntp, otp)
Performs a context switch between two threads.
#define CH_CFG_ST_TIMEDELTA
#define MSG_OK
Normal wakeup message.
#define MSG_TIMEOUT
Wakeup caused by a timeout condition.
#define chSysGetRealtimeCounterX()
Returns the current value of the system real time counter.
uint64_t systime_t
Type of system time.
#define TIME_IMMEDIATE
Zero interval specification for some functions with a timeout specification.
uint64_t sysinterval_t
Type of time interval.
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
stkalign_t * wabase
Working area base address.
tstate_t state
Current thread state.
Type of a thread descriptor.
stkalign_t * wbase
Pointer to the working area base.
stkalign_t * wend
Pointer to the working area end.
void * arg
Thread argument.
tprio_t prio
Thread priority.
tfunc_t funcp
Thread function pointer.