void OSCancelThread(OSThread *thread) { bool reschedule = false; OSLockScheduler(); if (thread->requestFlag == OSThreadRequest::Suspend) { OSWakeupThreadWaitForSuspensionNoLock(&thread->suspendQueue, -1); reschedule = true; } if (thread->suspendCounter != 0) { if (thread->cancelState == 0) { OSResumeThreadNoLock(thread, thread->suspendCounter); reschedule = true; } } if (reschedule) { OSRescheduleNoLock(); } thread->suspendCounter = 0; thread->needSuspend = 0; thread->requestFlag = OSThreadRequest::Cancel; OSUnlockScheduler(); if (OSGetCurrentThread() == thread) { OSExitThread(-1); } }
void testThreadCancelNoLock() { auto thread = OSGetCurrentThread(); if (thread->cancelState) { if (thread->requestFlag == OSThreadRequest::Suspend) { suspendThreadNoLock(thread); rescheduleAllCoreNoLock(); } else if (thread->requestFlag == OSThreadRequest::Cancel) { unlockScheduler(); OSExitThread(-1); } } }
// Entry point of new fibers void Processor::fiberEntryPoint(Fiber *fiber) { cpu::executeSub(&fiber->state); OSExitThread(ppctypes::getResult<int>(&fiber->state)); }
void Processor::fiberEntryPoint(Fiber *fiber) { gInterpreter.execute(&fiber->state, fiber->state.cia); OSExitThread(fiber->state.gpr[3]); }