Lines Matching refs:lock
49 void IOLockInitWithState( IOLock * lock, IOLockState state)
52 lck_mtx_lock( lock);
60 void IOLockFree( IOLock * lock)
62 lck_mtx_free( lock, IOLockGroup);
65 lck_mtx_t * IOLockGetMachLock( IOLock * lock)
67 return( (lck_mtx_t *)lock);
70 int IOLockSleep( IOLock * lock, void *event, UInt32 interType)
72 return (int) lck_mtx_sleep(lock, LCK_SLEEP_DEFAULT, (event_t) event, (wait_interrupt_t) interType);
75 int IOLockSleepDeadline( IOLock * lock, void *event,
78 return (int) lck_mtx_sleep_deadline(lock, LCK_SLEEP_DEFAULT, (event_t) event,
82 void IOLockWakeup(IOLock * lock, void *event, bool oneThread)
97 _IORecursiveLock * lock;
102 lock = IONew( _IORecursiveLock, 1 );
103 if( !lock )
106 lock->mutex = lck_mtx_alloc_init( lockGroup, LCK_ATTR_NULL );
107 if( lock->mutex ) {
108 lock->group = lockGroup;
109 lock->thread = 0;
110 lock->count = 0;
112 IODelete( lock, _IORecursiveLock, 1 );
113 lock = 0;
116 return( (IORecursiveLock *) lock );
127 _IORecursiveLock * lock = (_IORecursiveLock *)_lock;
129 lck_mtx_free( lock->mutex, lock->group );
130 IODelete( lock, _IORecursiveLock, 1 );
133 lck_mtx_t * IORecursiveLockGetMachLock( IORecursiveLock * lock )
135 return( lock->mutex );
140 _IORecursiveLock * lock = (_IORecursiveLock *)_lock;
142 if( lock->thread == IOThreadSelf())
143 lock->count++;
145 lck_mtx_lock( lock->mutex );
146 assert( lock->thread == 0 );
147 assert( lock->count == 0 );
148 lock->thread = IOThreadSelf();
149 lock->count = 1;
155 _IORecursiveLock * lock = (_IORecursiveLock *)_lock;
157 if( lock->thread == IOThreadSelf()) {
158 lock->count++;
161 if( lck_mtx_try_lock( lock->mutex )) {
162 assert( lock->thread == 0 );
163 assert( lock->count == 0 );
164 lock->thread = IOThreadSelf();
165 lock->count = 1;
174 _IORecursiveLock * lock = (_IORecursiveLock *)_lock;
176 assert( lock->thread == IOThreadSelf() );
178 if( 0 == (--lock->count)) {
179 lock->thread = 0;
180 lck_mtx_unlock( lock->mutex );
186 _IORecursiveLock * lock = (_IORecursiveLock *)_lock;
188 return( lock->thread == IOThreadSelf());
193 _IORecursiveLock * lock = (_IORecursiveLock *)_lock;
194 UInt32 count = lock->count;
197 assert(lock->thread == IOThreadSelf());
198 assert(lock->count == 1 || interType == THREAD_UNINT);
200 lock->count = 0;
201 lock->thread = 0;
202 res = lck_mtx_sleep(lock->mutex, LCK_SLEEP_DEFAULT, (event_t) event, (wait_interrupt_t) interType);
204 // Must re-establish the recursive lock no matter why we woke up
206 assert(lock->thread == 0);
207 assert(lock->count == 0);
208 lock->thread = IOThreadSelf();
209 lock->count = count;
219 * Complex (read/write) lock operations
227 void IORWLockFree( IORWLock * lock)
229 lck_rw_free( lock, IOLockGroup);
232 lck_rw_t * IORWLockGetMachLock( IORWLock * lock)
234 return( (lck_rw_t *)lock);
247 void IOSimpleLockInit( IOSimpleLock * lock)
249 lck_spin_init( lock, IOLockGroup, LCK_ATTR_NULL);
252 void IOSimpleLockFree( IOSimpleLock * lock )
254 lck_spin_free( lock, IOLockGroup);
257 lck_spin_t * IOSimpleLockGetMachLock( IOSimpleLock * lock)
259 return( (lck_spin_t *)lock);