pub fn sys_thread_sync(
    operations: &mut [ThreadSync],
    timeout: Option<Duration>
) -> Result<usize, ThreadSyncError>
Expand description

Perform a number of ThreadSync operations, either waking of threads waiting on words of memory, or sleeping this thread on one or more words of memory (or both). The order these requests are processed in is undefined.

The caller may optionally specify a timeout, causing this thread to sleep for at-most that Duration. However, the exact time is not guaranteed (it may be less if the thread is woken up, or slightly more due to scheduling uncertainty). If no operations are specified, the thread will sleep until the timeout expires.

Returns either Ok(ready_count), indicating how many operations were immediately ready, or Err(ThreadSyncError), indicating failure. After return, the kernel may have modified the ThreadSync entries to indicate additional information about each request, with Err to indicate error and Ok(n) to indicate success. For sleep requests, n is 0 if the operation went to sleep or 1 otherwise. For wakeup requests, n indicates the number of threads woken up by this operation.

Note that spurious wakeups are possible, and that even if a timeout occurs the function may return Ok(0).