MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / OSCancelThread

Function OSCancelThread

src/dolphin/src/os/OSThread.c:356–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354}
355
356void OSCancelThread(OSThread* thread)
357{
358 BOOL enabled;
359
360 enabled = OSDisableInterrupts();
361
362 switch (thread->state)
363 {
364 case OS_THREAD_STATE_READY:
365 if (!(0 < thread->suspend))
366 {
367 UnsetRun(thread);
368 }
369 break;
370 case OS_THREAD_STATE_RUNNING:
371 RunQueueHint = TRUE;
372 break;
373 case OS_THREAD_STATE_WAITING:
374 RemoveItem(thread->queue, thread, link);
375 thread->queue = NULL;
376 if (!(0 < thread->suspend) && thread->mutex)
377 {
378 UpdatePriority(thread->mutex->thread);
379 }
380 break;
381 default:
382 OSRestoreInterrupts(enabled);
383 return;
384 }
385
386 OSClearContext(&thread->context);
387 if (thread->attr & OS_THREAD_ATTR_DETACH)
388 {
389 RemoveItem(&__OSActiveThreadQueue, thread, linkActive);
390 thread->state = 0;
391 }
392 else
393 {
394 thread->state = OS_THREAD_STATE_MORIBUND;
395 }
396
397 __OSUnlockAllMutex(thread);
398
399 OSWakeupThread(&thread->queueJoin);
400
401 __OSReschedule();
402 OSRestoreInterrupts(enabled);
403
404 return;
405}
406
407s32 OSResumeThread(OSThread* thread)
408{

Callers 1

KillThreadsFunction · 0.85

Calls 6

OSDisableInterruptsFunction · 0.85
UnsetRunFunction · 0.85
UpdatePriorityFunction · 0.85
__OSUnlockAllMutexFunction · 0.85
OSWakeupThreadFunction · 0.85
__OSRescheduleFunction · 0.85

Tested by

no test coverage detected