mirror of
https://github.com/zeldaret/oot.git
synced 2025-02-23 15:55:47 +00:00
* message queues, threads, and surroundings cleanup * Format, make the formatter prefer clang-format-11 if found * Fix __osThreadTail type * Q -> Queue, thread defines renamed * Reformat, add missing NULL * Suggested changes and further casting cleanup * Reformat * padmgr name fixes
33 lines
1 KiB
C
33 lines
1 KiB
C
#include "global.h"
|
|
|
|
void osStartThread(OSThread* thread) {
|
|
register u32 prevInt = __osDisableInt();
|
|
|
|
switch (thread->state) {
|
|
case OS_STATE_WAITING:
|
|
thread->state = OS_STATE_RUNNABLE;
|
|
__osEnqueueThread(&__osRunQueue, thread);
|
|
break;
|
|
case OS_STATE_STOPPED:
|
|
if (thread->queue == NULL || thread->queue == &__osRunQueue) {
|
|
thread->state = OS_STATE_RUNNABLE;
|
|
__osEnqueueThread(&__osRunQueue, thread);
|
|
} else {
|
|
thread->state = OS_STATE_WAITING;
|
|
__osEnqueueThread(thread->queue, thread);
|
|
__osEnqueueThread(&__osRunQueue, __osPopThread(thread->queue));
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (__osRunningThread == NULL) {
|
|
__osDispatchThread();
|
|
} else {
|
|
if (__osRunningThread->priority < __osRunQueue->priority) {
|
|
__osRunningThread->state = OS_STATE_RUNNABLE;
|
|
__osEnqueueAndYield(&__osRunQueue);
|
|
}
|
|
}
|
|
|
|
__osRestoreInt(prevInt);
|
|
}
|