class PreemptionState
Defined at line 557 of file ../../zircon/kernel/include/kernel/thread.h
Public Members
static const uint32_t kMaxCountValue
static const uint32_t kPreemptDisableMask
static const uint32_t kEagerReschedDisableShift
static const uint32_t kEagerReschedDisableMask
static const uint32_t kTimesliceExtensionFlagsShift
static const uint32_t kTimesliceExtensionFlagsMask
Public Methods
cpu_mask_t preempts_pending ()
Defined at line 577 of file ../../zircon/kernel/include/kernel/thread.h
void preempts_pending_clear ()
Defined at line 578 of file ../../zircon/kernel/include/kernel/thread.h
void preempts_pending_add (cpu_mask_t mask)
Defined at line 579 of file ../../zircon/kernel/include/kernel/thread.h
bool PreemptIsEnabled ()
Defined at line 581 of file ../../zircon/kernel/include/kernel/thread.h
uint32_t PreemptDisableCount ()
Defined at line 587 of file ../../zircon/kernel/include/kernel/thread.h
uint32_t EagerReschedDisableCount ()
Defined at line 588 of file ../../zircon/kernel/include/kernel/thread.h
void PreemptDisable ()
PreemptDisable() increments the preempt disable counter for the current
thread. While preempt disable is non-zero, preemption of the thread is
disabled, including preemption from interrupt handlers. During this time,
any call to Reschedule() will only record that a reschedule is pending, and
won't do a context switch.
Note that this does not disallow blocking operations (e.g.
mutex.Acquire()). Disabling preemption does not prevent switching away from
the current thread if it blocks.
A call to PreemptDisable() must be matched by a later call to
PreemptReenable() to decrement the preempt disable counter.
Defined at line 602 of file ../../zircon/kernel/include/kernel/thread.h
void PreemptReenable ()
PreemptReenable() decrements the preempt disable counter and flushes any
pending local preemption operation. Callers must ensure that they are
calling from a context where blocking is allowed, as the call may result in
the immediate preemption of the calling thread.
Defined at line 611 of file ../../zircon/kernel/include/kernel/thread.h
void PreemptDisableAnnotated ()
Defined at line 649 of file ../../zircon/kernel/include/kernel/thread.h
void PreemptReenableAnnotated ()
Defined at line 654 of file ../../zircon/kernel/include/kernel/thread.h
void AssertPreemptionDisabled ()
Defined at line 659 of file ../../zircon/kernel/include/kernel/thread.h
bool PreemptReenableDelayFlush ()
PreemptReenableDelayFlush() decrements the preempt disable counter, but
deliberately does _not_ flush any pending local preemption operation.
Instead, if local preemption has become enabled again after the count
drops, and the local pending bit is set, the method will clear the bit and
return true. Otherwise, it will return false.
This method may only be called when interrupts are disabled and blocking is
not allowed.
Callers of this method are "taking" ownership of the responsibility to
ensure that preemption on the local CPU takes place in the near future
after the call if the method returns true.
Use of this method is strongly discouraged outside of top-level interrupt
glue and early threading setup.
TODO(johngro): Consider replacing the bool return type with a move-only
RAII type which wraps the bool, and ensures that preemption event _must_
happen, either by having the user call a method on the object to manually
force the preemption event, or when the object destructs.
Defined at line 683 of file ../../zircon/kernel/include/kernel/thread.h
void EagerReschedDisable ()
EagerReschedDisable() increments the eager resched disable counter for the
current thread. When early resched disable is non-zero, issuing local and
remote preemptions is disabled, including from interrupt handlers. During
this time, any call to Reschedule() or other scheduler entry points that
imply a reschedule will only record the pending reschedule for the affected
CPU, but will not perform reschedule IPIs or a local context switch.
As with PreemptDisable, blocking operations are still allowed while
eager resched disable is non-zero.
A call to EagerReschedDisable() must be matched by a later call to
EagerReschedReenable() to decrement the eager resched disable counter.
Defined at line 735 of file ../../zircon/kernel/include/kernel/thread.h
void EagerReschedReenable ()
EagerReschedReenable() decrements the eager resched disable counter and
flushes pending local and/or remote preemptions if enabled, respectively.
Defined at line 742 of file ../../zircon/kernel/include/kernel/thread.h
void EagerReschedDisableAnnotated ()
Defined at line 785 of file ../../zircon/kernel/include/kernel/thread.h
void EagerReschedReenableAnnotated ()
Defined at line 790 of file ../../zircon/kernel/include/kernel/thread.h
bool SetTimesliceExtension (zx_duration_mono_t extension_duration)
Sets a timeslice extension if one is not already set.
This method should only be called in normal thread context.
Returns false if a timeslice extension was already present or if the
supplied duration is
<
= 0.
Note: It OK to call this from a context where preemption is (hard)
disabled. If preemption is requested while the preempt disable count is
non-zero and a timeslice extension is in place, the extension will be
activated, but preemption will not occur until the count has dropped to
zero and the extension has expired or has been clear.
Defined at line 807 of file ../../zircon/kernel/include/kernel/thread.h
void ClearTimesliceExtension ()
Unconditionally clears any timeslice extension.
This method must be called in normal thread context because it may trigger
local preemption.
Defined at line 829 of file ../../zircon/kernel/include/kernel/thread.h
void PreemptSetPending (cpu_mask_t reschedule_mask)
PreemptSetPending() marks a pending preemption for the given CPUs.
This is similar to Reschedule(), except that it may only be used inside an
interrupt handler while interrupts and preemption are disabled, between
PreemptDisable() and PreemptReenable(). It is similar to Reschedule(),
except that it does not need to be called with thread's lock held.
Defined at line 844 of file ../../zircon/kernel/include/kernel/thread.h
bool EvaluateTimesliceExtension ()
Evaluate the thread's timeslice extension (if present), activating or
expiring it as necessary.
Returns whether preemption is enabled.
Defined at line 864 of file ../../zircon/kernel/include/kernel/thread.h
void Reset ()
Resets the preemption state. This should only be called when reviving an
idle/power thread that halted while taking a CPU offline.
Defined at line 908 of file ../../zircon/kernel/include/kernel/thread.h
Enumerations
enum TimesliceExtensionFlags
| Name | Value |
|---|---|
| Present | 0b01 << kTimesliceExtensionFlagsShift |
| Active | 0b10 << kTimesliceExtensionFlagsShift |
Defined at line 570 of file ../../zircon/kernel/include/kernel/thread.h
Friends
class CapabilityToken
class PreemptDisableTestAccess