class WaitQueue
Defined at line 352 of file ../../zircon/kernel/include/kernel/thread.h
NOTE: must be inside critical section when using these
Public Methods
zx_status_t BlockEtc (Thread * current_thread, const Deadline & deadline, uint signal_mask, ResourceOwnership reason, Interruptible interruptible)
Block until a wait queue is notified, ignoring existing signals
in |signal_mask|.
This function puts the current thread at the end of a wait
queue and then blocks until some other thread wakes the queue
up again.
If the deadline is zero, this function returns immediately with
ZX_ERR_TIMED_OUT. If the deadline is ZX_TIME_INFINITE, this function
waits indefinitely. Otherwise, this function returns with
ZX_ERR_TIMED_OUT when the deadline elapses.
Parameters
Returns
ZX_ERR_TIMED_OUT on timeout, else returns the return
value specified when the queue was woken by wait_queue_wake_one().
Defined at line 253 of file ../../zircon/kernel/kernel/wait.cc
bool WakeOne (zx_status_t wait_queue_error)
Wake up one thread sleeping on a wait queue
This function removes one thread (if any) from the head of the wait queue and
makes it executable. The new thread will be placed in the run queue.
Parameters
Returns
Whether a thread was woken
Defined at line 297 of file ../../zircon/kernel/kernel/wait.cc
void WaitQueue ()
Defined at line 354 of file ../../zircon/kernel/include/kernel/thread.h
void WaitQueue (WaitQueue & )
Defined at line 357 of file ../../zircon/kernel/include/kernel/thread.h
void WaitQueue (WaitQueue && )
Defined at line 358 of file ../../zircon/kernel/include/kernel/thread.h
WaitQueue & operator= (WaitQueue & )
Defined at line 359 of file ../../zircon/kernel/include/kernel/thread.h
WaitQueue & operator= (WaitQueue && )
Defined at line 360 of file ../../zircon/kernel/include/kernel/thread.h
zx_status_t Block (Thread *const current_thread, const Deadline & deadline, Interruptible interruptible)
Block on a wait queue.
The returned status is whatever the caller of WaitQueue::Wake_*() specifies.
A deadline other than Deadline::infinite() will abort at the specified time
and return ZX_ERR_TIMED_OUT. A deadline in the past will immediately return.
Defined at line 382 of file ../../zircon/kernel/include/kernel/thread.h
zx_status_t Block (Thread *const current_thread, zx_instant_mono_t deadline, Interruptible interruptible)
Block on a wait queue with a zx_instant_mono_t-typed deadline.
Defined at line 389 of file ../../zircon/kernel/include/kernel/thread.h
Thread * PeekFront ()
Returns the current highest priority blocked thread on this wait queue, or
nullptr if no threads are blocked.
Defined at line 406 of file ../../zircon/kernel/include/kernel/thread.h
const Thread * PeekFront ()
Defined at line 407 of file ../../zircon/kernel/include/kernel/thread.h
zx_status_t UnblockThread (Thread * t, zx_status_t wait_queue_error)
Wake a specific thread from a specific wait queue
TODO(johngro): Update this comment. UnblockThread does not actually remove
the thread from the wait queue, it simply finishes the unblock operation,
propagating any PI effects and dropping the PI lock chain starting from the
wait queue in the processes.
This function extracts a specific thread from a wait queue, wakes it, puts it
into a Scheduler's run queue, and does a reschedule if necessary. Callers of
this function must be sure that they are holding the locks for all of the
nodes in the PI chain, starting from the thread, before calling the function.
Static analysis can only ensure that the thread and its immediately
downstream blocking wait queue are locked.
Parameters
Returns
ZX_ERR_BAD_STATE if thread was not in any wait queue.
Defined at line 579 of file ../../zircon/kernel/kernel/wait.cc
void WakeAll (zx_status_t wait_queue_error)
Wake all threads sleeping on a wait queue
This function removes all threads (if any) from the wait queue and
makes them executable. The new threads will be placed at the head of the
run queue.
Parameters
Returns
The number of threads woken
Defined at line 414 of file ../../zircon/kernel/kernel/wait.cc
ktl::optional<bool> WakeOneLocked (zx_status_t wait_queue_error)
Locked versions of the wake calls. These calls are going to need to obtain
locks for each of the threads woken, which could result in needing to back
off and start the operation again. Each routine returns a
std::optional (bool or u32).
++ If the optional holds a value, then the value is the number of threads
which were woken, and the operation succeeded.
++ Otherwise, the operation failed with a Backoff error and the queue's
lock needs to be dropped before trying again.
It is assumed that forming a lock cycle should be impossible. If such a
cycle is detected (like, if the caller was holding the lock of one of the
thread's blocked in this queue at the time of the call) it will trigger a
DEBUG_ASSERT.
Either way, unlike the non-Locked versions of these routines, the wait
queue's lock is held for the duration of the operation, instead of being
release as soon as possible (during the call to SchedulerUnlock)
Defined at line 368 of file ../../zircon/kernel/kernel/wait.cc
bool IsEmpty ()
Whether the wait queue is currently empty.
Defined at line 445 of file ../../zircon/kernel/include/kernel/thread.h
uint32_t Count ()
Defined at line 446 of file ../../zircon/kernel/include/kernel/thread.h
uint32_t magic ()
OwnedWaitQueue needs to be able to call this on WaitQueues to
determine if they are base WaitQueues or the OwnedWaitQueue
subclass.
Defined at line 459 of file ../../zircon/kernel/include/kernel/thread.h
void ~WaitQueue ()
Tear down a wait queue
This panics if any threads were waiting on this queue, because that
would indicate a race condition for most uses of wait queues. If a
thread is currently waiting, it could have been scheduled later, in
which case it would have called Block() on an invalid wait
queue.
Defined at line 547 of file ../../zircon/kernel/kernel/wait.cc
ktl::optional<uint32_t> WakeAllLocked (zx_status_t wait_queue_error)
Defined at line 480 of file ../../zircon/kernel/kernel/wait.cc
void DequeueThread (Thread * t, zx_status_t wait_queue_error)
Dequeue the specified thread and set its blocked_status. Do not actually
schedule the thread to run.
Defined at line 510 of file ../../zircon/kernel/kernel/wait.cc
void UpdateBlockedThreadEffectiveProfile (Thread & t)
Recompute the effective profile of a thread which is known to be blocked in
this wait queue, reordering the thread in the queue collection as needed.
This method does not deal with the consequences of profile inheritance, and
should only ever be called from one of the OwnedWaitQueue's Propagate
methods (which will deal with the consequences)
Defined at line 614 of file ../../zircon/kernel/kernel/wait.cc
Protected Methods
zx_status_t BlockEtcPreamble (Thread * current_thread, const Deadline & deadline, uint signal_mask, ResourceOwnership reason, Interruptible interuptible)
Inline helpers (defined in wait_queue_internal.h) for
WaitQueue::BlockEtc and OwnedWaitQueue::BlockAndAssignOwner to
share.
Defined at line 50 of file ../../zircon/kernel/include/kernel/wait_queue_internal.h
zx_status_t BlockEtcPostamble (Thread * current_thread, const Deadline & deadline)
By the time we have made it to BlockEtcPostamble, we should have dropped
the wait_queue lock, and only be holding the lock for current thread (who
is about to block). We have already (successfully) added the thread to the
queue and set our blocked state. All we need to do now is set up our
timer, and finally descend into the scheduler in order to block and select
a new thread.
Defined at line 84 of file ../../zircon/kernel/include/kernel/wait_queue_internal.h
void WaitQueue (uint32_t magic)
Defined at line 462 of file ../../zircon/kernel/include/kernel/thread.h
void MoveThread (WaitQueue * source, WaitQueue * dest, Thread * t)
Move the specified thread from the source wait queue to the dest wait queue.
Defined at line 520 of file ../../zircon/kernel/kernel/wait.cc
Friends
class WaitQueueLockOps
class BrwLockOps
class OwnedWaitQueue