class OwnedWaitQueue
Defined at line 39 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
Owned wait queues are an extension of wait queues which adds the concept of
ownership for use when profile inheritance semantics are needed.
An owned wait queue maintains an unmanaged pointer to a Thread in order to
track who owns it at any point in time. In addition, it contains node state
which can be used by the owning thread in order to track the wait queues that
the thread is currently an owner of. This also makes use of unmanaged
pointer.
It should be an error for any thread to destruct while it owns an
OwnedWaitQueue. Likewise, it should be an error for any wait queue to
destruct while it has an owner. These invariants are enforced in the
destructor for OwnedWaitQueue and Thread. This enforcement is considered
to be the reasoning why holding unmanaged pointers is considered to be safe.
Public Members
static PropagateOpTag AddSingleEdgeOp
static PropagateOpTag RemoveSingleEdgeOp
static PropagateOpTag BaseProfileChangedOp
static const uint32_t kOwnedMagic
Public Methods
IWakeRequeueHook & default_wake_hooks ()
Defined at line 102 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
void ~OwnedWaitQueue ()
Defined at line 163 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
void DisownAllQueues (Thread * t)
Release ownership of all wait queues currently owned by |t| and update
bookkeeping as appropriate. This is meant to be called from the thread
itself and therefore it is assumed that the thread in question is not
blocked on any other wait queues.
Defined at line 169 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
void OwnedWaitQueue ()
Defined at line 176 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
void OwnedWaitQueue (const OwnedWaitQueue & )
No copy or move is permitted.
Defined at line 180 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
void OwnedWaitQueue (OwnedWaitQueue && )
No copy or move is permitted.
Defined at line 180 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
OwnedWaitQueue & operator= (const OwnedWaitQueue & )
No copy or move is permitted.
Defined at line 180 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
OwnedWaitQueue & operator= (OwnedWaitQueue && )
No copy or move is permitted.
Defined at line 180 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
ChainLock::Result LockPiChain (Thread & start)
Attempt to lock the rest of a PI chain, starting from the (already locked)
node given by |start|.
Defined at line 195 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
ChainLock::Result LockPiChain (WaitQueue & start)
Defined at line 208 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
WakeThreadsResult WakeThreadsLocked (Thread::UnblockList threads, IWakeRequeueHook & wake_hooks, WakeOption option, ForceInheritance force_inheritance)
Defined at line 215 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
Thread * owner ()
const accessor for the owner member.
Defined at line 220 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
void AssertNotOwned ()
Debug Assert wrapper which skips the thread analysis checks just to
assert that a specific queue is unowned. Used by FutexContext
Defined at line 224 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
SchedulerState::WaitQueueInheritedSchedulerState * inherited_scheduler_state_storage ()
Accessor used only by the scheduler's PiNodeAdapter to handle bookkeeping
during profile inheritance situations.
Defined at line 319 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
const SchedulerState::WaitQueueInheritedSchedulerState * inherited_scheduler_state_storage ()
Defined at line 324 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
const SchedulerState::WaitQueueInheritedSchedulerState * const_inherited_scheduler_state_storage ()
Defined at line 329 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
void SetThreadBaseProfileAndPropagate (Thread & thread, const SchedulerState::BaseProfile & profile)
Change a thread's base profile and deal with profile propagation side effects.
Defined at line 1590 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
zx_status_t AssignOwner (Thread * new_owner)
Assign ownership of this wait queue to |new_owner|, or explicitly release
ownership if |new_owner| is nullptr. No change is made to ownership if it
would result in a cycle in the inheritance graph.
Note, if the new owner exists, but is dead or dying, it will not be
permitted to become the new owner of the wait_queue. Any existing owner
will be replaced with no owner in this situation.
Returns ZX_ERR_BAD_STATE if a cycle would have been produced, and ZX_OK
otherwise.
Defined at line 1699 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
zx_status_t AssignOwnerLocked (Thread * new_owner)
Returns ZX_ERR_SHOULD_WAIT if a back-off is required, and ZX_OK otherwise.
Defined at line 1711 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
void ResetOwnerIfNoWaiters ()
Defined at line 1727 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
zx_status_t BlockAndAssignOwner (const Deadline & deadline, Thread * new_owner, ResourceOwnership resource_ownership, Interruptible interruptible)
Block the current thread on this wait queue, and re-assign ownership to
the specified thread (or remove ownership if new_owner is null); If a
cycle would have been produced by this operation, no changes are made and
ZX_ERR_BAD_STATE will be returned.
Note, if the new owner exists, but is dead or dying, it will not be
permitted to become the new owner of the wait_queue. Any existing owner
will be replaced with no owner in this situation.
Defined at line 1780 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
zx_status_t BlockAndAssignOwnerLocked (Thread * current_thread, const Deadline & deadline, const BAAOLockingDetails & details, ResourceOwnership resource_ownership, Interruptible interruptible, ForceInheritance force_inheritance)
Defined at line 1803 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
void CancelBAAOOperationLocked (Thread * current_thread, const BAAOLockingDetails & details)
Cancel a block and assign owner operation that we have already locked for.
Basically, just drop all of the locks and get out.
Defined at line 1970 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
bool LockForBAAOOperationOrBackoff (Thread * current_thread, Thread * new_owner, BAAOLockingDetails & details_out)
Obtain all of the locks needed for a BlockAndAssignOwner operation,
handling the special case of new+old owner which share a PI graph target.
Defined at line 900 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
bool TryLockForBAAOOperationLocked (Thread * current_thread, Thread * new_owner, BAAOLockingDetails & details_out)
Attempt to obtain all of the locks needed for a BAAO operation while
already holding this queue's lock. On success, the current thread's lock
will have been obtained in addition to any other locks in the PI chain
which are needed, and the details of the locking operation will be
returned. On failure, returns ktl::nullopt after dropping any locks which
had been obtained.
Defined at line 919 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
WakeThreadsResult WakeThreads (uint32_t wake_count, IWakeRequeueHook & wake_hooks)
Wake the up to specified number of threads from the wait queue, removing
any current queue owner in the process.
Defined at line 2011 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
WakeThreadsResult WakeThreadAndAssignOwner (IWakeRequeueHook & wake_hooks)
Attempt to wake exactly one thread, and assign ownership of the queue to
the woken thread (if any).
Defined at line 2031 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
bool LockForWakeOperationOrBackoff (uint32_t max_wake, IWakeRequeueHook & wake_hooks, Thread::UnblockList & unblock_list_out)
Obtain all of the locks needed for a WakeThreads operation.
Defined at line 671 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
ktl::optional<Thread::UnblockList> LockForWakeOperationLocked (uint32_t max_wake, IWakeRequeueHook & wake_hooks)
Defined at line 690 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
WakeThreadsResult WakeAndRequeue (OwnedWaitQueue & requeue_target, Thread * new_requeue_owner, uint32_t wake_count, uint32_t requeue_count, IWakeRequeueHook & wake_hooks, IWakeRequeueHook & requeue_hooks, WakeOption wake_option)
Defined at line 2050 of file ../../zircon/kernel/kernel/owned_wait_queue.cc
Enumerations
enum PropagateOp
| Name | Value |
|---|---|
| AddSingleEdge | 0 |
| RemoveSingleEdge | 1 |
| BaseProfileChanged | 2 |
A enum which determines the specific behavior of the Propagate method.
Defined at line 147 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
enum WakeOption
| Name | Value |
|---|---|
| None | 0 |
| AssignOwner | 1 |
Behavior control for wake/requeue operations
Defined at line 169 of file ../../zircon/kernel/include/kernel/owned_wait_queue.h
Records
Friends
class OwnedWaitQueueTopologyTests
zx_status_t OwnedWaitQueue (Thread * tzx_status_t wait_queue_error)