Go to the documentation of this file.
60 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
78 #if CH_CFG_USE_SEMAPHORES_PRIORITY == TRUE
79 #define sem_insert(tp, qp) ch_sch_prio_insert(&tp->hdr.queue, qp)
81 #define sem_insert(tp, qp) ch_queue_insert(&tp->hdr.queue, qp)
149 "inconsistent semaphore");
197 "inconsistent semaphore");
199 if (--sp->
cnt < (cnt_t)0) {
200 currp->u.wtsemp = sp;
204 return currp->u.rdymsg;
264 "inconsistent semaphore");
266 if (--sp->
cnt < (cnt_t)0) {
272 currp->u.wtsemp = sp;
295 "inconsistent semaphore");
296 if (++sp->
cnt <= (cnt_t)0) {
319 "inconsistent semaphore");
321 if (++sp->
cnt <= (cnt_t)0) {
349 "inconsistent semaphore");
351 while (n > (cnt_t)0) {
352 if (++sp->
cnt <= (cnt_t)0) {
380 "inconsistent semaphore");
383 "inconsistent semaphore");
384 if (++sps->
cnt <= (cnt_t)0) {
387 if (--spw->
cnt < (cnt_t)0) {
389 sem_insert(ctp, &spw->
queue);
static void chSysLock(void)
Enters the kernel lock state.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
#define currp
Current thread pointer access macro.
msg_t rdymsg
Thread wakeup code.
void chSemAddCounterI(semaphore_t *sp, cnt_t n)
Adds the specified value to the semaphore counter.
#define chDbgAssert(c, r)
Condition assertion.
void chSemSignal(semaphore_t *sp)
Performs a signal operation on a semaphore.
msg_t chSemWait(semaphore_t *sp)
Performs a wait operation on a semaphore.
static bool ch_queue_notempty(const ch_queue_t *qp)
Evaluates to true if the specified queue is not empty.
static bool ch_queue_isempty(const ch_queue_t *qp)
Evaluates to true if the specified queue is empty.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
#define chDbgCheck(c)
Function parameters check.
#define TIME_IMMEDIATE
Zero interval specification for some functions with a timeout specification.
msg_t chSemWaitS(semaphore_t *sp)
Performs a wait operation on a semaphore.
Structure representing a thread.
void chSemResetWithMessageI(semaphore_t *sp, cnt_t n, msg_t msg)
Performs a reset operation on the semaphore.
void chSchGoSleepS(tstate_t newstate)
Puts the current thread to sleep into the specified state.
void chSemObjectInit(semaphore_t *sp, cnt_t n)
Initializes a semaphore with the specified counter value.
static ch_queue_t * ch_queue_fifo_remove(ch_queue_t *qp)
Removes the first-out element from a queue and returns it.
union ch_thread::@1 u
State-specific fields.
ch_queue_t queue
Queue of the threads sleeping on this semaphore.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
static void ch_queue_init(ch_queue_t *qp)
Queue initialization.
void chDbgCheckClassI(void)
I-class functions context check.
#define MSG_OK
Normal wakeup message.
cnt_t cnt
The semaphore counter.
static ch_queue_t * ch_queue_lifo_remove(ch_queue_t *qp)
Removes the last-out element from a queue and returns it.
uint64_t sysinterval_t
Type of time interval.
msg_t chSemWaitTimeout(semaphore_t *sp, sysinterval_t timeout)
Performs a wait operation on a semaphore with timeout specification.
void chSemResetWithMessage(semaphore_t *sp, cnt_t n, msg_t msg)
Performs a reset operation on the semaphore.
struct ch_semaphore * wtsemp
Pointer to a generic semaphore object.
ChibiOS/RT main include file.
#define MSG_TIMEOUT
Wakeup caused by a timeout condition.
static void chSysUnlock(void)
Leaves the kernel lock state.
msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw)
Performs atomic signal and wait operations on two semaphores.
void chDbgCheckClassS(void)
S-class functions context check.
msg_t chSemWaitTimeoutS(semaphore_t *sp, sysinterval_t timeout)
Performs a wait operation on a semaphore with timeout specification.
void chSemSignalI(semaphore_t *sp)
Performs a signal operation on a semaphore.
#define CH_STATE_WTSEM
On a semaphore.
void chSchWakeupS(thread_t *ntp, msg_t msg)
Wakes up a thread.