#include <oskit/com/libcenv.h>void oskit_libcenv_sleep_init(oskit_libcenv_t *c, osenv_sleeprec_t *sleeprec);
oskit_error_t oskit_libcenv_sleep(oskit_libcenv_t *s, osenv_sleeprec_t *sleeprec, struct oskit_timespec *timeout);
void oskit_libcenv_wakeup(oskit_libcenv_t *s, osenv_sleeprec_t *sleeprec);
The sleep/wakeup interface is provided so that the C/POSIX library uses a standard mechanism for giving up control of the CPU, in both single and multi threaded applications. The sleep_init method initializes a ``sleep record'' structure in preparation for the going to sleep waiting for some event to occur. The sleep record is used to avoid races between actually going to sleep and the event of interest, and to provide a ``handle'' on the current activity by which wakeup can indicate which process to awaken. Once the sleep record is initialized, the sleep and wakeup methods are used to put the caller to sleep, or to initiate a wakeup. An optional timeout value may be supplied to sleep. The caller will be woken if the timeout expires, and OSKIT_ETIMEDOUT will be returned to indicate timeout.
- c
- The oskit_libcenv object to operate on.
- sleeprec
- A pointer to a sleep record, allocated by the caller.
- timeout
- A timeout value used to bound the length of the sleep interval.
The sleep function returns 0 if woken up normally, otherwise OSKIT_ETIMEDOUT is returned if the timeout expires.