Lines Matching refs:mutex
21 void OSi_UnlockMutexCore(OSMutex *mutex, u32 type);
23 void OSi_EnqueueTail(OSThread *thread, OSMutex *mutex);
24 void OSi_DequeueItem(OSThread *thread, OSMutex *mutex);
37 void OS_InitMutex(OSMutex *mutex) in OS_InitMutex() argument
39 SDK_ASSERT(mutex); in OS_InitMutex()
41 OS_InitThreadQueue(&mutex->queue); in OS_InitMutex()
42 mutex->thread = NULL; in OS_InitMutex()
43 OS_SetMutexCount( mutex, 0 ); in OS_InitMutex()
44 OS_SetMutexType( mutex, OS_MUTEX_TYPE_NONE ); in OS_InitMutex()
56 void OS_LockMutex(OSMutex *mutex) in OS_LockMutex() argument
64 if ( OS_TryLockMutex(mutex) ) in OS_LockMutex()
69 currentThread->mutex = mutex; in OS_LockMutex()
70 OS_SleepThread(&mutex->queue); in OS_LockMutex()
71 currentThread->mutex = NULL; in OS_LockMutex()
86 void OS_UnlockMutex(OSMutex *mutex) in OS_UnlockMutex() argument
88 OSi_UnlockMutexCore(mutex, OS_MUTEX_TYPE_STD); in OS_UnlockMutex()
102 OSMutex *mutex; in OSi_UnlockAllMutex() local
109 mutex = OSi_DequeueHead(thread); in OSi_UnlockAllMutex()
110 SDK_ASSERT(mutex->thread == thread); in OSi_UnlockAllMutex()
112 OS_SetMutexCount( mutex, 0 ); in OSi_UnlockAllMutex()
113 mutex->thread = NULL; in OSi_UnlockAllMutex()
114 OS_SetMutexType( mutex, OS_MUTEX_TYPE_NONE ); in OSi_UnlockAllMutex()
115 OS_WakeupThread(&(mutex->queue)); in OSi_UnlockAllMutex()
120 mutex = OSi_RemoveMutexLinkFromQueue(&thread->mutexQueue); in OSi_UnlockAllMutex()
121 SDK_ASSERT(mutex->thread == thread); in OSi_UnlockAllMutex()
123 OS_SetMutexCount( mutex, 0 ); in OSi_UnlockAllMutex()
124 mutex->thread = NULL; in OSi_UnlockAllMutex()
125 OS_SetMutexType( mutex, OS_MUTEX_TYPE_NONE ); in OSi_UnlockAllMutex()
126 OS_WakeupThread(&mutex->queue); in OSi_UnlockAllMutex()
140 BOOL OS_TryLockMutex(OSMutex *mutex) in OS_TryLockMutex() argument
146 SDK_ASSERT(mutex); in OS_TryLockMutex()
149 if (mutex->thread == NULL) in OS_TryLockMutex()
151 mutex->thread = currentThread; in OS_TryLockMutex()
152 OS_SetMutexType( mutex, OS_MUTEX_TYPE_STD ); in OS_TryLockMutex()
153 OS_IncreaseMutexCount(mutex); in OS_TryLockMutex()
154 OSi_EnqueueTail(currentThread, mutex); in OS_TryLockMutex()
158 else if (mutex->thread == currentThread) in OS_TryLockMutex()
160 OS_IncreaseMutexCount(mutex); in OS_TryLockMutex()
185 void OS_LockMutexR(OSMutex *mutex) in OS_LockMutexR() argument
193 if ( OS_TryLockMutexR(mutex) ) in OS_LockMutexR()
198 currentThread->mutex = mutex; in OS_LockMutexR()
199 OS_SleepThread(&mutex->queue); in OS_LockMutexR()
200 currentThread->mutex = NULL; in OS_LockMutexR()
215 void OS_LockMutexW(OSMutex *mutex) in OS_LockMutexW() argument
223 if ( OS_TryLockMutexW(mutex) ) in OS_LockMutexW()
228 currentThread->mutex = mutex; in OS_LockMutexW()
229 OS_SleepThread(&mutex->queue); in OS_LockMutexW()
230 currentThread->mutex = NULL; in OS_LockMutexW()
245 BOOL OS_TryLockMutexR(OSMutex *mutex) in OS_TryLockMutexR() argument
251 switch( OS_GetMutexType(mutex) ) in OS_TryLockMutexR()
254 mutex->thread = currentThread; in OS_TryLockMutexR()
255 OS_SetMutexType( mutex, OS_MUTEX_TYPE_R ); in OS_TryLockMutexR()
256 OS_SetMutexCount( mutex, 1 ); in OS_TryLockMutexR()
257 OSi_EnqueueTail(currentThread, mutex); in OS_TryLockMutexR()
262 OS_IncreaseMutexCount(mutex); in OS_TryLockMutexR()
284 BOOL OS_TryLockMutexW(OSMutex *mutex) in OS_TryLockMutexW() argument
290 switch( OS_GetMutexType(mutex) ) in OS_TryLockMutexW()
293 mutex->thread = currentThread; in OS_TryLockMutexW()
294 OS_SetMutexType( mutex, OS_MUTEX_TYPE_W ); in OS_TryLockMutexW()
295 OS_SetMutexCount( mutex, 1 ); in OS_TryLockMutexW()
296 OSi_EnqueueTail(currentThread, mutex); in OS_TryLockMutexW()
301 if ( mutex->thread == currentThread ) in OS_TryLockMutexW()
303 OS_IncreaseMutexCount(mutex); in OS_TryLockMutexW()
331 void OSi_UnlockMutexCore(OSMutex *mutex, u32 type ) in OSi_UnlockMutexCore() argument
337 SDK_ASSERT(mutex); in OSi_UnlockMutexCore()
340 if ( type != OS_MUTEX_TYPE_NONE && type != OS_GetMutexType(mutex) ) in OSi_UnlockMutexCore()
348 switch( OS_GetMutexType(mutex) ) in OSi_UnlockMutexCore()
352 if ( mutex->thread == currentThread ) in OSi_UnlockMutexCore()
354 OS_DecreaseMutexCount(mutex); in OSi_UnlockMutexCore()
355 if ( OS_GetMutexCount(mutex) == 0 ) in OSi_UnlockMutexCore()
363 OS_DecreaseMutexCount(mutex); in OSi_UnlockMutexCore()
364 if ( OS_GetMutexCount(mutex) == 0 ) in OSi_UnlockMutexCore()
381 OSi_DequeueItem(currentThread, mutex); in OSi_UnlockMutexCore()
382 mutex->thread = NULL; in OSi_UnlockMutexCore()
383 OS_SetMutexType( mutex, OS_MUTEX_TYPE_NONE ); in OSi_UnlockMutexCore()
384 OS_WakeupThread(&mutex->queue); in OSi_UnlockMutexCore()
399 void OS_UnlockMutexR(OSMutex *mutex) in OS_UnlockMutexR() argument
401 OSi_UnlockMutexCore( mutex, OS_MUTEX_TYPE_R ); in OS_UnlockMutexR()
413 void OS_UnlockMutexW(OSMutex *mutex) in OS_UnlockMutexW() argument
415 OSi_UnlockMutexCore( mutex, OS_MUTEX_TYPE_W ); in OS_UnlockMutexW()
427 void OS_UnlockMutexRW(OSMutex *mutex) in OS_UnlockMutexRW() argument
429 OSi_UnlockMutexCore( mutex, OS_MUTEX_TYPE_NONE ); in OS_UnlockMutexRW()
442 void OS_LockMutexFromRToW(OSMutex *mutex) in OS_LockMutexFromRToW() argument
449 if ( OS_TryLockMutexFromRToW(mutex) ) in OS_LockMutexFromRToW()
454 currentThread->mutex = mutex; in OS_LockMutexFromRToW()
455 OS_SleepThread(&mutex->queue); in OS_LockMutexFromRToW()
456 currentThread->mutex = NULL; in OS_LockMutexFromRToW()
471 BOOL OS_TryLockMutexFromRToW(OSMutex *mutex) in OS_TryLockMutexFromRToW() argument
477 …if ( OS_GetMutexCount(mutex) == 1 && mutex->queue.head == NULL && OS_GetMutexType(mutex) == OS_MUT… in OS_TryLockMutexFromRToW()
479 OS_SetMutexType( mutex, OS_MUTEX_TYPE_W ); in OS_TryLockMutexFromRToW()
497 void OS_LockMutexFromWToR(OSMutex *mutex) in OS_LockMutexFromWToR() argument
504 if ( OS_TryLockMutexFromWToR(mutex) ) in OS_LockMutexFromWToR()
509 currentThread->mutex = mutex; in OS_LockMutexFromWToR()
510 OS_SleepThread(&mutex->queue); in OS_LockMutexFromWToR()
511 currentThread->mutex = NULL; in OS_LockMutexFromWToR()
526 BOOL OS_TryLockMutexFromWToR(OSMutex *mutex) in OS_TryLockMutexFromWToR() argument
532 …if ( OS_GetMutexCount(mutex) == 1 && mutex->queue.head == NULL && OS_GetMutexType(mutex) == OS_MUT… in OS_TryLockMutexFromWToR()
534 OS_SetMutexType( mutex, OS_MUTEX_TYPE_R ); in OS_TryLockMutexFromWToR()
557 void OSi_EnqueueTail(OSThread *thread, OSMutex *mutex) in OSi_EnqueueTail() argument
562 SDK_ASSERT(thread && mutex); in OSi_EnqueueTail()
566 thread->mutexQueueHead = mutex; in OSi_EnqueueTail()
570 prev->next = mutex; in OSi_EnqueueTail()
573 mutex->prev = prev; in OSi_EnqueueTail()
574 mutex->next = NULL; in OSi_EnqueueTail()
575 thread->mutexQueueTail = mutex; in OSi_EnqueueTail()
579 SDK_ASSERT(thread && mutex); in OSi_EnqueueTail()
583 thread->mutexQueue.head = mutex; in OSi_EnqueueTail()
587 prev->link.next = mutex; in OSi_EnqueueTail()
590 mutex->link.prev = prev; in OSi_EnqueueTail()
591 mutex->link.next = NULL; in OSi_EnqueueTail()
592 thread->mutexQueue.tail = mutex; in OSi_EnqueueTail()
607 void OSi_DequeueItem(OSThread *thread, OSMutex *mutex) in OSi_DequeueItem() argument
610 OSMutex *next = mutex->next; in OSi_DequeueItem()
611 OSMutex *prev = mutex->prev; in OSi_DequeueItem()
613 SDK_ASSERT(thread && mutex); in OSi_DequeueItem()
633 OSMutex *next = mutex->link.next; in OSi_DequeueItem()
634 OSMutex *prev = mutex->link.prev; in OSi_DequeueItem()
636 SDK_ASSERT(thread && mutex); in OSi_DequeueItem()
670 OSMutex *mutex = thread->mutexQueueHead; in OSi_DequeueHead() local
671 OSMutex *next = mutex->next; in OSi_DequeueHead()
686 OSMutex *mutex = thread->mutexQueue.head; in OSi_DequeueHead()
687 OSMutex *next = mutex->link.next; in OSi_DequeueHead()
703 return mutex; in OSi_DequeueHead()