|
ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IOLocks.h |
| Includes: |
<sys/appleapiopts.h> <IOKit/system.h> <IOKit/IOReturn.h> <IOKit/IOTypes.h> <libkern/locks.h> <machine/machine_routines.h> |
This header contains definitions of functions that implement various types of lock operations, such as mutex locks, recursive locks, and simple locks.
Allocates and initializes a mutex.
Frees a mutex.
Gets a Mach mutex.
Locks a mutex.
Sleeps with mutex unlocked and relocks on wakeup.
Sleeps with mutex unlocked and relocks on wakeup when the specified event occurs or the deadline passes.
Attempts to lock a mutex.
Unlocks a mutex.
Wakes up the thread holding the specified lock.
Allocates and initializes an recursive lock.
Frees a recursive lock.
Gets a Mach mutex.
Checks if a recursive lock is held by the calling thread.
Locks a recursive lock.
Sleeps with the recursive lock unlocked and relocks on wakeup.
Attempts to lock a recursive lock.
Unlocks a recursive lock.
Wakes up the thread holding the specified recursive lock.
Allocates and initializes a read/write lock.
Frees a read/write lock.
Gets a Mach read/write lock.
Locks a read/write lock for read.
Unlocks a read/write lock.
Locks a read/write lock for write.
Allocates and initializes a spin lock.
Frees a spin lock.
Gets a Mach spin lock.
Initializes a spin lock.
Locks a spin lock.
Locks a spin lock, disabling interrupts.
Attempts to lock a spin lock.
Unlocks a spin lock.
Unlocks a spin lock and restores interrupt state.
IOLockAlloc |
Allocates and initializes a mutex.
IOLock * IOLockAlloc( void );
Pointer to the allocated lock, or zero on failure.
Allocates a mutex in general purpose memory, and initilizes it. Mutexes are general purpose blocking mutual exclusion locks, supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held.
IOLockFree |
Frees a mutex.
void IOLockFree( IOLock *lock);
lockPointer to the allocated lock.
Frees a lock allocated with IOLockAlloc. Any blocked waiters will not be awakened.
IOLockGetMachLock |
Gets a Mach mutex.
lck_mtx_t * IOLockGetMachLock( IOLock *lock);
lockPointer to the allocated lock.
This is an accessor to a Mach mutex.
IOLockLock |
Locks a mutex.
void IOLockLock( IOLock *lock);
lockPointer to the allocated lock.
Locks the mutex. If the lock is held by any thread, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the mutex recursively from one thread will result in deadlock.
IOLockSleep |
Sleeps with mutex unlocked and relocks on wakeup.
int IOLockSleep( IOLock *lock, void *event, UInt32 interType);
lockPointer to the locked lock.
eventThe event to sleep on.
interTypeHow the sleep can be interrupted. Possible values are:
THREAD_UNINT Not interruptibleTHREAD_INTERRUPTIBLE Interruptible, but not guaranteed to be restartableTHREAD_ABORTSAFE Safely abortableThe wait-result value indicating how the thread was awakened. Possible values are:
THREAD_WAITING Thread is waitingTHREAD_AWAKENED Normal wakeupTHREAD_TIMED_OUT Timeout has expiredTHREAD_INTERRUPTED Thread has been interrupted or abortedTHREAD_RESTART Restart operation entirelyPrepare to sleep, unlocks the mutex, and re-acquires it on wakeup. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
IOLockSleepDeadline |
Sleeps with mutex unlocked and relocks on wakeup when the specified event occurs or the deadline passes.
int IOLockSleepDeadline( IOLock *lock, void *event, AbsoluteTime deadline, UInt32 interType);
lockPointer to the locked lock.
eventThe event to sleep on.
deadlineThe time by which to wake up.
interTypeHow the sleep can be interrupted. Possible values are:
THREAD_UNINT Not interruptibleTHREAD_INTERRUPTIBLE Interruptible, but not guaranteed to be restartableTHREAD_ABORTSAFE Safely abortableThe wait-result value indicating how the thread was awakened. Possible values are:
THREAD_WAITING Thread is waitingTHREAD_AWAKENED Normal wakeupTHREAD_TIMED_OUT Timeout has expiredTHREAD_INTERRUPTED Thread has been interrupted or abortedTHREAD_RESTART Restart operation entirelyPrepare to sleep until the event occurs or the deadline passes, unlock the mutex, and re-acquire it on wakeup. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
IOLockTryLock |
Attempts to lock a mutex.
boolean_t IOLockTryLock( IOLock *lock);
lockPointer to the allocated lock.
True if the mutex was unlocked and is now locked by the caller, otherwise false.
Locks the mutex if it is currently unlocked and returns true. If the lock is held by any thread, this function returns false.
IOLockUnlock |
Unlocks a mutex.
void IOLockUnlock( IOLock *lock);
lockPointer to the allocated lock.
Unlocks the mutex and wakes any blocked waiters. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
IOLockWakeup |
Wakes up the thread holding the specified lock.
void IOLockWakeup( IOLock *lock, void *event, bool oneThread);
lockPointer to the locked lock.
eventThe event being waited on.
oneThreadA Boolean value indicating whether only one thread should be awakened (true) or all (false).
Wakes up the thread holding the specified lock and waiting on the specified event.
IORecursiveLockAlloc |
Allocates and initializes an recursive lock.
IORecursiveLock * IORecursiveLockAlloc( void );
Pointer to the allocated lock, or zero on failure.
Allocates a recursive lock in general purpose memory, and initializes it. Recursive locks function identically to mutexes but allow one thread to lock more than once, with balanced unlocks.
IORecursiveLockFree |
Frees a recursive lock.
void IORecursiveLockFree( IORecursiveLock *lock);
lockPointer to the allocated lock.
Frees a lock allocated with IORecursiveLockAlloc. Any blocked waiters will not be awakened.
IORecursiveLockGetMachLock |
Gets a Mach mutex.
lck_mtx_t * IORecursiveLockGetMachLock( IORecursiveLock *lock);
lockPointer to the allocated lock.
Accessor to a Mach mutex.
IORecursiveLockHaveLock |
Checks if a recursive lock is held by the calling thread.
boolean_t IORecursiveLockHaveLock( const IORecursiveLock * lock);
lockPointer to the allocated lock.
True if the calling thread holds the lock, otherwise false.
If the lock is held by the calling thread returns true, otherwise the lock is unlocked or held by another thread and false is returned.
IORecursiveLockLock |
Locks a recursive lock.
void IORecursiveLockLock( IORecursiveLock *lock);
lockPointer to the allocated lock.
If the lock is held by another thread, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. The lock may be taken recursively by the same thread, with a balanced number of calls to IORecursiveLockUnlock.
IORecursiveLockSleep |
Sleeps with the recursive lock unlocked and relocks on wakeup.
extern int IORecursiveLockSleep( IORecursiveLock *lock, void *event, UInt32 interType);
lockPointer to the allocated lock.
eventThe event to sleep on.
interTypeHow the sleep can be interrupted. Possible values are:
THREAD_UNINT Not interruptibleTHREAD_INTERRUPTIBLE Interruptible, but not guaranteed to be restartableTHREAD_ABORTSAFE Safely abortableThe wait-result value indicating how the thread was awakened. Possible values are:
THREAD_WAITING Thread is waitingTHREAD_AWAKENED Normal wakeupTHREAD_TIMED_OUT Timeout has expiredTHREAD_INTERRUPTED Thread has been interrupted or abortedTHREAD_RESTART Restart operation entirelyPrepare to sleep, unlocks the lock, and re-establishes it on wakeup. Results are undefined if the caller has not locked the lock. This function may block and so should not be called from interrupt level or while a spin lock is held.
IORecursiveLockTryLock |
Attempts to lock a recursive lock.
boolean_t IORecursiveLockTryLock( IORecursiveLock *lock);
lockPointer to the allocated lock.
True if the lock is now locked by the caller, otherwise false.
Locks the lock if it is currently unlocked or held by the calling thread, and returns true. If the lock is held by another thread, this function returns false. Successful calls to IORecursiveLockTryLock should be balanced with calls to IORecursiveLockUnlock.
IORecursiveLockUnlock |
Unlocks a recursive lock.
void IORecursiveLockUnlock( IORecursiveLock *lock);
lockPointer to the allocated lock.
Undoes one call to IORecursiveLockLock; if the lock is now unlocked wake any blocked waiters. Results are undefined if the caller does not balance calls to IORecursiveLockLock with IORecursiveLockUnlock. This function may block and so should not be called from interrupt level or while a spin lock is held.
IORecursiveLockWakeup |
Wakes up the thread holding the specified recursive lock.
extern void IORecursiveLockWakeup( IORecursiveLock *lock, void *event, bool oneThread);
lockPointer to the allocated lock.
eventThe event being waited on.
oneThreadA Boolean value indicating whether only one thread should be awakened (true) or all (false).
Wakes up the thread holding the specified recursive lock and waiting on the specified event.
IORWLockAlloc |
Allocates and initializes a read/write lock.
IORWLock * IORWLockAlloc( void );
Pointer to the allocated lock, or zero on failure.
Allocates and initializes a read/write lock in general purpose memory, and initilizes it. Read/write locks provide for multiple readers, one exclusive writer, and are supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held.
IORWLockFree |
Frees a read/write lock.
void IORWLockFree( IORWLock *lock);
lockPointer to the allocated lock.
Frees a lock allocated with IORWLockAlloc. Any blocked waiters will not be awakened.
IORWLockGetMachLock |
Gets a Mach read/write lock.
lck_rw_t * IORWLockGetMachLock( IORWLock *lock);
lockPointer to the allocated lock.
This is an accessor to a Mach read/write lock.
IORWLockRead |
Locks a read/write lock for read.
void IORWLockRead( IORWLock *lock);
lockPointer to the allocated lock.
Locks the lock for read, allowing multiple readers when there are no writers. If the lock is held for write, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the lock recursively from one thread, for read or write, can result in deadlock.
IORWLockUnlock |
Unlocks a read/write lock.
void IORWLockUnlock( IORWLock *lock);
lockPointer to the allocated lock.
Undoes one call to IORWLockRead or IORWLockWrite. Results are undefined if the caller has not locked the lock. This function may block and so should not be called from interrupt level or while a spin lock is held.
IORWLockWrite |
Locks a read/write lock for write.
void IORWLockWrite( IORWLock *lock);
lockPointer to the allocated lock.
Locks the lock for write, allowing one writer exclusive access. If the lock is held for read or write, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the lock recursively from one thread, for read or write, can result in deadlock.
IOSimpleLockAlloc |
Allocates and initializes a spin lock.
IOSimpleLock * IOSimpleLockAlloc( void );
Pointer to the allocated lock, or zero on failure.
Allocates an initializes a spin lock in general purpose memory, and initializes it. Spin locks provide non-blocking mutual exclusion for synchronization between thread context and interrupt context, or for multiprocessor synchronization, and are supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held.
IOSimpleLockFree |
Frees a spin lock.
void IOSimpleLockFree( IOSimpleLock *lock );
lockPointer to the lock.
Frees a lock allocated with IOSimpleLockAlloc.
IOSimpleLockGetMachLock |
Gets a Mach spin lock.
lck_spin_t * IOSimpleLockGetMachLock( IOSimpleLock *lock);
lockPointer to the allocated lock.
This is an accessor to a Mach spin lock.
IOSimpleLockInit |
Initializes a spin lock.
void IOSimpleLockInit( IOSimpleLock *lock );
lockPointer to the lock.
Initializes an embedded spin lock, to the unlocked state.
IOSimpleLockLock |
Locks a spin lock.
void IOSimpleLockLock( IOSimpleLock *lock );
lockPointer to the lock.
Locks the spin lock. If the lock is held, spin waiting for its unlock. Spin locks disable preemption, cannot be held across any blocking operation, and should be held for very short periods. When used to synchronize between interrupt context and thread context they should be locked with interrupts disabled --- IOSimpleLockLockDisableInterrupt will do both. Locking the lock recursively from one thread will result in deadlock.
IOSimpleLockLockDisableInterrupt |
Locks a spin lock, disabling interrupts.
static __inline__ IOInterruptState IOSimpleLockLockDisableInterrupt( IOSimpleLock *lock )
lockPointer to the lock.
True if interrupts are enabled, false if interrupts are disabled.
Locks the spin lock, disabling interrupts. If the lock is held, spin waiting for its unlock. Simple locks disable preemption, cannot be held across any blocking operation, and should be held for very short periods. When used to synchronize between interrupt context and thread context they should be locked with interrupts disabled --- IOSimpleLockLockDisableInterrupt does both. Locking the lock recursively from one thread will result in deadlock.
IOSimpleLockTryLock |
Attempts to lock a spin lock.
boolean_t IOSimpleLockTryLock( IOSimpleLock *lock );
lockPointer to the lock.
True if the lock was unlocked and is now locked by the caller, otherwise false.
Locks the spin lock if it is currently unlocked, and returns true. If the lock is held, this function returns false. Successful calls to IOSimpleLockTryLock should be balanced with calls to IOSimpleLockUnlock.
IOSimpleLockUnlock |
Unlocks a spin lock.
void IOSimpleLockUnlock( IOSimpleLock *lock );
lockPointer to the lock.
Unlocks the lock, and restores preemption. Results are undefined if the caller has not locked the lock.
IOSimpleLockUnlockEnableInterrupt |
Unlocks a spin lock and restores interrupt state.
static __inline__ void IOSimpleLockUnlockEnableInterrupt( IOSimpleLock *lock, IOInterruptState state )
lockPointer to the lock.
stateThe interrupt state returned by IOSimpleLockLockDisableInterrupt.
Unlocks the lock, and restores preemption and interrupts to the state they were in when the lock was taken. Results are undefined if the caller has not locked the lock.
|
Last Updated: 2008-12-19