2019-08-25 00:46:40 -04:00
|
|
|
#include "libultra_internal.h"
|
|
|
|
extern OSThread *D_803348A0;
|
|
|
|
extern OSThread *D_80334898;
|
|
|
|
void osStartThread(OSThread *thread) {
|
|
|
|
register u32 int_disabled;
|
2019-10-05 15:08:05 -04:00
|
|
|
register uintptr_t state;
|
2019-08-25 00:46:40 -04:00
|
|
|
int_disabled = __osDisableInt();
|
|
|
|
state = thread->state;
|
|
|
|
|
|
|
|
if (state != OS_STATE_STOPPED) {
|
|
|
|
if (state == OS_STATE_WAITING) {
|
|
|
|
do {
|
|
|
|
} while (0);
|
|
|
|
thread->state = OS_STATE_RUNNABLE;
|
|
|
|
__osEnqueueThread(&D_80334898, thread);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (thread->queue == NULL || thread->queue == &D_80334898) {
|
|
|
|
thread->state = OS_STATE_RUNNABLE;
|
|
|
|
|
|
|
|
__osEnqueueThread(&D_80334898, thread);
|
|
|
|
} else {
|
|
|
|
thread->state = OS_STATE_WAITING;
|
|
|
|
__osEnqueueThread(thread->queue, thread);
|
2019-10-05 15:08:05 -04:00
|
|
|
state = (uintptr_t) __osPopThread(thread->queue);
|
2019-08-25 00:46:40 -04:00
|
|
|
__osEnqueueThread(&D_80334898, (OSThread *) state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (D_803348A0 == NULL) {
|
|
|
|
__osDispatchThread();
|
|
|
|
} else {
|
|
|
|
if (D_803348A0->priority < D_80334898->priority) {
|
|
|
|
D_803348A0->state = OS_STATE_RUNNABLE;
|
|
|
|
__osEnqueueAndYield(&D_80334898);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__osRestoreInt(int_disabled);
|
|
|
|
}
|