OSUninterruptibleSpinLock_Release

Syntax

#include <cafe/os.h>

BOOL OSUninterruptibleSpinLock_Release(OSSpinLock* inSpinlock);

Parameters

inSpinlock Pointer to uninterruptible spinlock to be released.

Return Values

Returns TRUE if the lock was released, or FALSE otherwise.

Description

WARNING:
Threads MUST NOT mix regular OSSpinLocks with OSUninterruptibleSpinLocks.

OSUninterruptibleSpinLock_Release releases the per-thread OSSpinLock. After this OS function returns and the recursion count drops to zero, any other threads currently waiting to acquire the OSUninterruptibleSpinLock may acquire it. Upon releasing the OSUninterruptibleSpinLock, interrupts are restored to their previous enable-state (enabled or disabled) when the OSUninterruptibleSpinLock was acquired.

An OSUninterruptibleSpinLock is approximately 5X faster to acquire and release than a regular OSSpinLock and creates no contention for internal COS locks. The major condition is that between acquiring and releasing the OSUninterruptibleSpinLock, interrupts are disabled and must remain disabled until the corresponding OSUninterruptibleSpinLock_Release is called.

OSUninterruptibleSpinLock_Acquire and OSUninterruptibleSpinLock_Release purposely have the same parameter lists and same-sized data structures as the OSSpinLock Acquire and Release functions. This is so that OSUninterruptibleSpinLock can serve as a drop-in replacement for regular OSSpinLock in many situations.

OSUninterruptibleSpinLocks do not participate in the thread canceling mechanism. If a thread wishes to benefit from both the faster OSUninterruptibleSpinLock and from the ability to cross-thread cancel a thread, OSTestThreadCancel should be called before OSUninterruptibleSpinLock_Acquire and after OSUninterruptibleSpinLock_Release.

Do Not Call From

None.

See Also

OSAcquireSpinLock
OSTryAcquireSpinLock
OSTryAcquireSpinLockWithTimeout
OSInitSpinLock
OSUninterruptibleSpinLock_Acquire
OSUninterruptibleSpinLock_TryAcquire
OSUninterruptibleSpinLock_TryAcquireWithTimeout
OSDisableInterrupts
OSEnableInterrupts
OSRestoreInterrupts
OSIsInterruptEnabled

Revision History

2013/06/21 Clarify the return value.
2013/05/08 Automated cleanup pass.
2012/08/01 Cleanup Pass.
2011/04/21 Initial version.


CONFIDENTIAL