void OSTestThreadCancel() { OSLockScheduler(); OSTestThreadCancelNoLock(); OSUnlockScheduler(); }
void OSUnlockMutex(OSMutex *mutex) { OSLockScheduler(); OSUnlockMutexNoLock(mutex); OSTestThreadCancelNoLock(); OSUnlockScheduler(); }
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; }