60 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 78 #if CH_CFG_USE_SEMAPHORES_PRIORITY == TRUE 79 #define sem_insert(tp, qp) queue_prio_insert(tp, qp) 81 #define sem_insert(tp, qp) queue_insert(tp, qp) 154 "inconsistent semaphore");
158 while (++cnt <= (cnt_t)0) {
203 "inconsistent semaphore");
205 if (--sp->
cnt < (cnt_t)0) {
206 currp->u.wtsemp = sp;
210 return currp->u.rdymsg;
270 "inconsistent semaphore");
272 if (--sp->
cnt < (cnt_t)0) {
278 currp->u.wtsemp = sp;
301 "inconsistent semaphore");
302 if (++sp->
cnt <= (cnt_t)0) {
325 "inconsistent semaphore");
327 if (++sp->
cnt <= (cnt_t)0) {
355 "inconsistent semaphore");
357 while (n > (cnt_t)0) {
358 if (++sp->
cnt <= (cnt_t)0) {
386 "inconsistent semaphore");
389 "inconsistent semaphore");
390 if (++sps->
cnt <= (cnt_t)0) {
393 if (--spw->
cnt < (cnt_t)0) {
395 sem_insert(ctp, &spw->
queue);
msg_t chSemWait(semaphore_t *sp)
Performs a wait operation on a semaphore.
void chDbgCheckClassS(void)
S-class functions context check.
cnt_t cnt
The semaphore counter.
void chSemAddCounterI(semaphore_t *sp, cnt_t n)
Adds the specified value to the semaphore counter.
uint64_t sysinterval_t
Type of time interval.
static void chSysLock(void)
Enters the kernel lock state.
msg_t chSemWaitTimeoutS(semaphore_t *sp, sysinterval_t timeout)
Performs a wait operation on a semaphore with timeout specification.
msg_t chSemWaitS(semaphore_t *sp)
Performs a wait operation on a semaphore.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
void chSemSignal(semaphore_t *sp)
Performs a signal operation on a semaphore.
#define currp
Current thread pointer access macro.
msg_t rdymsg
Thread wakeup code.
static void chSysUnlock(void)
Leaves the kernel lock state.
void chDbgCheckClassI(void)
I-class functions context check.
#define MSG_TIMEOUT
Wakeup caused by a timeout condition.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
void chSemReset(semaphore_t *sp, cnt_t n)
Performs a reset operation on the semaphore.
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.
#define chDbgCheck(c)
Function parameters check.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
#define MSG_OK
Normal wakeup message.
#define chDbgAssert(c, r)
Condition assertion.
threads_queue_t queue
Queue of the threads sleeping on this semaphore.
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.
msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw)
Performs atomic signal and wait operations on two semaphores.
void chSemObjectInit(semaphore_t *sp, cnt_t n)
Initializes a semaphore with the specified counter value.
#define CH_STATE_WTSEM
On a semaphore.
union ch_thread::@0 u
State-specific fields.
msg_t chSemWaitTimeout(semaphore_t *sp, sysinterval_t timeout)
Performs a wait operation on a semaphore with timeout specification.
struct ch_semaphore * wtsemp
Pointer to a generic semaphore object.
#define TIME_IMMEDIATE
Zero interval specification for some functions with a timeout specification.
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.
ChibiOS/RT main include file.
void chSemSignalI(semaphore_t *sp)
Performs a signal operation on a semaphore.
thread_t * queue_fifo_remove(threads_queue_t *tqp)
Removes the first-out thread from a queue and returns it.
void chSemResetI(semaphore_t *sp, cnt_t n)
Performs a reset operation on the semaphore.
#define MSG_RESET
Wakeup caused by a reset condition.
Structure representing a thread.