class Mutex

Defined at line 31 of file ../../zircon/kernel/include/kernel/mutex.h

Kernel mutex support.

Public Members

static const zx_duration_t SPIN_MAX_DURATION
static const zx_duration_t DEFAULT_TIMESLICE_EXTENSION

Public Methods

void Mutex ()

Defined at line 36 of file ../../zircon/kernel/include/kernel/mutex.h

void Mutex (const fxt::InternedString & name_stringref)

Defined at line 37 of file ../../zircon/kernel/include/kernel/mutex.h

void Mutex (const Mutex & )

No moving or copying allowed.

Defined at line 43 of file ../../zircon/kernel/include/kernel/mutex.h

void Mutex (Mutex && )

No moving or copying allowed.

Defined at line 43 of file ../../zircon/kernel/include/kernel/mutex.h

Mutex & operator= (const Mutex & )

No moving or copying allowed.

Defined at line 43 of file ../../zircon/kernel/include/kernel/mutex.h

Mutex & operator= (Mutex && )

No moving or copying allowed.

Defined at line 43 of file ../../zircon/kernel/include/kernel/mutex.h

void Release ()

Release the mutex. Must be held by the current thread.

Note: that this simply thunks directly to ReleaseInternal, which does not

have any annotations. Methods of capability objects (see TA_CAP, above)

which are annotated with TA_ACQ/TA_REL effectively have static thread

analysis disabled for them. It is assumed that they will "do whatever it

takes" to either acquire or release the capability. By thunking to a

non-annotated method, we can guarantee that the implementation of the

release operation *is* subject to static analysis, helping to guarantee

that we are holding (or not holding) all of the proper capabilities when

interacting with things like threads, wait queues, and the scheduler.

Defined at line 70 of file ../../zircon/kernel/include/kernel/mutex.h

bool IsHeld ()

does the current thread hold the mutex?

Defined at line 73 of file ../../zircon/kernel/include/kernel/mutex.h

void AssertHeld ()

Panic unless the given lock is held.

Can be used when thread safety analysis can't prove you are holding

a lock. The asserts may be optimized away in release builds.

Defined at line 79 of file ../../zircon/kernel/include/kernel/mutex.h

void MarkReleased ()

<jedi

_mindtrick>This is not the method you are looking for.

</jedi

_mindtrick>

Defined at line 82 of file ../../zircon/kernel/include/kernel/mutex.h

bool IsContested ()

Is the mutex contested i.e. is at least one thread blocked waiting on it?

The contested flag does not track threads which are spin-waiting on the

Mutex and have yet to enter a blocking phase.

Defined at line 88 of file ../../zircon/kernel/include/kernel/mutex.h

void ~Mutex ()

Defined at line 124 of file ../../zircon/kernel/kernel/mutex.cc

void Acquire (zx_duration_t spin_max_duration)

Acquire the mutex.

Defined at line 184 of file ../../zircon/kernel/include/kernel/mutex.h

Protected Methods

template <bool TimesliceExtensionEnabled>
bool AcquireCommon (zx_duration_t spin_max_duration, TimesliceExtension<TimesliceExtensionEnabled> timeslice_extension)

By parametrizing on whether we're going to set a timeslice extension or not

we can shave a few cycles.

Defined at line 150 of file ../../zircon/kernel/kernel/mutex.cc

Records