os_sched_sleep

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

ArgumentsDescription
tPointer to task
nticksNumber of ticks to sleep in OS ticks

Returned values

Returns 0 on success.

Notes

Must be called with interrupts disabled.

Example

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);

}