class WaitQueue
Defined at line 354 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,uintsignal_mask,ResourceOwnershipreason,Interruptibleinterruptible)
Block on a wait queue, ignoring existing signals in |signal_mask|.
The returned status is whatever the caller of WaitQueue::Wake_*() specifies, or
ZX_ERR_TIMED_OUT if the deadline has elapsed or is in the past.
This will never timeout when called with a deadline of Deadline::infinite().
Defined at line 253 of file ../../zircon/kernel/kernel/wait.cc
bool WakeOne (zx_status_t wait_queue_error)
Release one or more threads from the wait queue.
wait_queue_error = what WaitQueue::Block() should return for the blocking thread.
Returns true if a thread was woken, and false otherwise.
Defined at line 297 of file ../../zircon/kernel/kernel/wait.cc
void WaitQueue ()
Defined at line 356 of file ../../zircon/kernel/include/kernel/thread.h
void WaitQueue (WaitQueue & )
Defined at line 359 of file ../../zircon/kernel/include/kernel/thread.h
void WaitQueue (WaitQueue && )
Defined at line 360 of file ../../zircon/kernel/include/kernel/thread.h
WaitQueue & operator= (WaitQueue & )
Defined at line 361 of file ../../zircon/kernel/include/kernel/thread.h
WaitQueue & operator= (WaitQueue && )
Defined at line 362 of file ../../zircon/kernel/include/kernel/thread.h
zx_status_t Block (Thread *constcurrent_thread,const Deadline &deadline,Interruptibleinterruptible)
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 384 of file ../../zircon/kernel/include/kernel/thread.h
zx_status_t Block (Thread *constcurrent_thread,zx_instant_mono_tdeadline,Interruptibleinterruptible)
Block on a wait queue with a zx_instant_mono_t-typed deadline.
Defined at line 391 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 408 of file ../../zircon/kernel/include/kernel/thread.h
const Thread * PeekFront ()
Defined at line 409 of file ../../zircon/kernel/include/kernel/thread.h
zx_status_t UnblockThread (Thread * t, zx_status_t wait_queue_error)
Remove a specific thread out of the wait queue it's blocked on, and deal
with any PI side effects. Note: when calling this function:
1) The thread |t| must be actively blocked in the WaitQueue instance
indicated by |this|.
2) In addition to |t|'s lock, all of the ChainLocks downstream of |t|
(starting from |t| and ending at the target of |t|'s PI graph) must be
held. Note that we are only able to statically assert that the first
two of these locks; |t|'s lock, and the lock of the wait queue |t| is
currently blocked in.
3) During the call UnblockThread, all of the locks identified in #2 (above)
will be released.
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 447 of file ../../zircon/kernel/include/kernel/thread.h
uint32_t Count ()
Defined at line 448 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 461 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,uintsignal_mask,ResourceOwnershipreason,Interruptibleinteruptible)
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 464 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