int os_sched_sleep(struct os_task *t, os_time_t nticks)
Task ‘t’ state is changed from ready to run to sleeping. Sleep time will be specified in nticks.
Task will be woken up after sleep timer expires, unless there are other signals causing it to wake up.
If nticks is set to OS_TIMEOUT_NEVER, task never wakes up with a sleep timer.
Arguments | Description |
---|---|
t | Pointer to task |
nticks | Number of ticks to sleep in OS ticks |
Returns 0 on success.
Must be called with interrupts disabled.
OS_ENTER_CRITICAL(sr);
pull_one: ev = STAILQ_FIRST(&evq->evq_list); if (ev) { STAILQ_REMOVE(&evq->evq_list, ev, os_event, ev_next); ev->ev_queued = 0; } else { evq->evq_task = os_sched_get_current_task(); os_sched_sleep(evq->evq_task, OS_TIMEOUT_NEVER); OS_EXIT_CRITICAL(sr);
os_sched(NULL); OS_ENTER_CRITICAL(sr); evq->evq_task = NULL; goto pull_one; } OS_EXIT_CRITICAL(sr); return (ev);
}