Example #1
0
void
OSTestThreadCancel()
{
   OSLockScheduler();
   OSTestThreadCancelNoLock();
   OSUnlockScheduler();
}
Example #2
0
void
OSUnlockMutex(OSMutex *mutex)
{
   OSLockScheduler();
   OSUnlockMutexNoLock(mutex);
   OSTestThreadCancelNoLock();
   OSUnlockScheduler();
}
Example #3
0
BOOL
OSTryLockMutex(OSMutex *mutex)
{
   auto thread = OSGetCurrentThread();
   OSLockScheduler();
   OSTestThreadCancelNoLock();

   if (mutex->owner && mutex->owner != thread) {
      // Someone else owns this mutex
      OSUnlockScheduler();
      return FALSE;
   }

   if (mutex->owner != thread) {
      // Add to mutex queue
      OSAppendQueue(&thread->mutexQueue, mutex);
   }

   mutex->owner = thread;
   mutex->count++;
   OSUnlockScheduler();

   return TRUE;
}