Lines Matching refs:lock
56 * Mutex lock operations
68 @discussion 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.
69 @result Pointer to the allocated lock, or zero on failure. */
75 @discussion Frees a lock allocated with IOLockAlloc. Any blocked waiters will not be woken.
76 @param lock Pointer to the allocated lock. */
78 void IOLockFree( IOLock * lock);
83 @param lock Pointer to the allocated lock. */
85 lck_mtx_t * IOLockGetMachLock( IOLock * lock);
89 @discussion Lock 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.
90 @param lock Pointer to the allocated lock. */
95 void IOLockLock( IOLock * lock)
97 lck_mtx_lock(lock);
100 void IOLockLock( IOLock * lock);
103 void IOLockLock( IOLock * lock);
107 @abstract Attempt to lock a mutex.
108 @discussion Lock the mutex if it is currently unlocked, and return true. If the lock is held by any thread, return false.
109 @param lock Pointer to the allocated lock.
115 boolean_t IOLockTryLock( IOLock * lock)
117 return(lck_mtx_try_lock(lock));
120 boolean_t IOLockTryLock( IOLock * lock);
123 boolean_t IOLockTryLock( IOLock * lock);
128 @discussion Unlock the mutex and wake 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.
129 @param lock Pointer to the allocated lock. */
134 void IOLockUnlock( IOLock * lock)
136 lck_mtx_unlock(lock);
139 void IOLockUnlock( IOLock * lock);
142 void IOLockUnlock( IOLock * lock);
147 @discussion Prepare to sleep,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.
148 @param lock Pointer to the locked lock.
152 int IOLockSleep( IOLock * lock, void *event, UInt32 interType);
154 int IOLockSleepDeadline( IOLock * lock, void *event,
157 void IOLockWakeup(IOLock * lock, void *event, bool oneThread);
168 void IOLockInitWithState( IOLock * lock, IOLockState state);
171 static __inline__ void IOTakeLock( IOLock * lock) { IOLockLock(lock); }
172 static __inline__ boolean_t IOTryLock( IOLock * lock) { return(IOLockTryLock(lock)); }
173 static __inline__ void IOUnlock( IOLock * lock) { IOLockUnlock(lock); }
178 * Recursive lock operations
184 @abstract Allocates and initializes an recursive lock.
185 @discussion 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.
186 @result Pointer to the allocated lock, or zero on failure. */
191 @abstract Frees a recursive lock.
192 @discussion Frees a lock allocated with IORecursiveLockAlloc. Any blocked waiters will not be woken.
193 @param lock Pointer to the allocated lock. */
195 void IORecursiveLockFree( IORecursiveLock * lock);
200 @param lock Pointer to the allocated lock. */
202 lck_mtx_t * IORecursiveLockGetMachLock( IORecursiveLock * lock);
205 @abstract Lock a recursive lock.
206 @discussion Lock the recursive 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.
207 @param lock Pointer to the allocated lock. */
209 void IORecursiveLockLock( IORecursiveLock * lock);
212 @abstract Attempt to lock a recursive lock.
213 @discussion Lock the lock if it is currently unlocked, or held by the calling thread, and return true. If the lock is held by another thread, return false. Successful calls to IORecursiveLockTryLock should be balanced with calls to IORecursiveLockUnlock.
214 @param lock Pointer to the allocated lock.
215 @result True if the lock is now locked by the caller, otherwise false. */
217 boolean_t IORecursiveLockTryLock( IORecursiveLock * lock);
220 @abstract Unlock a recursive lock.
221 @discussion Undo 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.
222 @param lock Pointer to the allocated lock. */
224 void IORecursiveLockUnlock( IORecursiveLock * lock);
227 @abstract Check if a recursive lock is held by the calling thread.
228 @discussion If the lock is held by the calling thread, return true, otherwise the lock is unlocked, or held by another thread and false is returned.
229 @param lock Pointer to the allocated lock.
230 @result True if the calling thread holds the lock otherwise false. */
232 boolean_t IORecursiveLockHaveLock( const IORecursiveLock * lock);
240 * Complex (read/write) lock operations
250 @abstract Allocates and initializes a read/write lock.
251 @discussion 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.
252 @result Pointer to the allocated lock, or zero on failure. */
257 @abstract Frees a read/write lock.
258 @discussion Frees a lock allocated with IORWLockAlloc. Any blocked waiters will not be woken.
259 @param lock Pointer to the allocated lock. */
261 void IORWLockFree( IORWLock * lock);
264 @abstract Accessor to a Mach read/write lock.
265 @discussion Accessor to the Mach read/write lock.
266 @param lock Pointer to the allocated lock. */
268 lck_rw_t * IORWLockGetMachLock( IORWLock * lock);
271 @abstract Lock a read/write lock for read.
272 @discussion Lock 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.
273 @param lock Pointer to the allocated lock. */
278 void IORWLockRead( IORWLock * lock)
280 lck_rw_lock_shared( lock);
283 void IORWLockRead( IORWLock * lock);
286 void IORWLockRead( IORWLock * lock);
290 @abstract Lock a read/write lock for write.
291 @discussion Lock the lock for write, allowing one writer exlusive 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.
292 @param lock Pointer to the allocated lock. */
297 void IORWLockWrite( IORWLock * lock)
299 lck_rw_lock_exclusive( lock);
302 void IORWLockWrite( IORWLock * lock);
305 void IORWLockWrite( IORWLock * lock);
309 @abstract Unlock a read/write lock.
310 @discussion Undo 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.
311 @param lock Pointer to the allocated lock. */
316 void IORWLockUnlock( IORWLock * lock)
318 lck_rw_done( lock);
321 void IORWLockUnlock( IORWLock * lock);
324 void IORWLockUnlock( IORWLock * lock);
331 static __inline__ void IOReadLock( IORWLock * lock) { IORWLockRead(lock); }
332 static __inline__ void IOWriteLock( IORWLock * lock) { IORWLockWrite(lock); }
333 static __inline__ void IORWUnlock( IORWLock * lock) { IORWLockUnlock(lock); }
339 * Simple locks. Cannot block while holding a simple lock.
349 @abstract Allocates and initializes a spin lock.
350 @discussion Allocates an initializes a spin lock in general purpose memory, and initilizes 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.
351 @result Pointer to the allocated lock, or zero on failure. */
356 @abstract Frees a spin lock.
357 @discussion Frees a lock allocated with IOSimpleLockAlloc.
358 @param lock Pointer to the lock. */
360 void IOSimpleLockFree( IOSimpleLock * lock );
363 @abstract Accessor to a Mach spin lock.
364 @discussion Accessor to the Mach spin lock.
365 @param lock Pointer to the allocated lock. */
367 lck_spin_t * IOSimpleLockGetMachLock( IOSimpleLock * lock);
370 @abstract Initialize a spin lock.
371 @discussion Initialize an embedded spin lock, to the unlocked state.
372 @param lock Pointer to the lock. */
374 void IOSimpleLockInit( IOSimpleLock * lock );
377 @abstract Lock a spin lock.
378 @discussion Lock 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.
379 @param lock Pointer to the lock. */
384 void IOSimpleLockLock( IOSimpleLock * lock )
386 lck_spin_lock( lock );
389 void IOSimpleLockLock( IOSimpleLock * lock );
392 void IOSimpleLockLock( IOSimpleLock * lock );
396 @abstract Attempt to lock a spin lock.
397 @discussion Lock the spin lock if it is currently unlocked, and return true. If the lock is held, return false. Successful calls to IOSimpleLockTryLock should be balanced with calls to IOSimpleLockUnlock.
398 @param lock Pointer to the lock.
399 @result True if the lock was unlocked and is now locked by the caller, otherwise false. */
404 boolean_t IOSimpleLockTryLock( IOSimpleLock * lock )
406 return( lck_spin_try_lock( lock ) );
409 boolean_t IOSimpleLockTryLock( IOSimpleLock * lock );
412 boolean_t IOSimpleLockTryLock( IOSimpleLock * lock );
416 @abstract Unlock a spin lock.
417 @discussion Unlock the lock, and restore preemption. Results are undefined if the caller has not locked the lock.
418 @param lock Pointer to the lock. */
423 void IOSimpleLockUnlock( IOSimpleLock * lock )
425 lck_spin_unlock( lock );
428 void IOSimpleLockUnlock( IOSimpleLock * lock );
431 void IOSimpleLockUnlock( IOSimpleLock * lock );
437 @abstract Lock a spin lock.
438 @discussion Lock the spin lock. 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() will do both. Locking the lock recursively from one thread will result in deadlock.
439 @param lock Pointer to the lock. */
442 IOInterruptState IOSimpleLockLockDisableInterrupt( IOSimpleLock * lock )
445 IOSimpleLockLock( lock );
450 @abstract Unlock a spin lock, and restore interrupt state.
451 @discussion Unlock the lock, and restore preemption and interrupts to the state as they were when the lock was taken. Results are undefined if the caller has not locked the lock.
452 @param lock Pointer to the lock.
456 void IOSimpleLockUnlockEnableInterrupt( IOSimpleLock * lock,
459 IOSimpleLockUnlock( lock );