summaryrefslogtreecommitdiff
path: root/soh/src/libultra/os/stopthread.c
blob: eebd8ce9b7cd6c69ccb253946c7898265c6f2308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "global.h"

void osStopThread(OSThread* thread) {
    register u32 prevInt = __osDisableInt();
    register u32 state;

    if (thread == NULL) {
        state = 4;
    } else {
        state = thread->state;
    }

    switch (state) {
        case 4:
            __osRunningThread->state = 1;
            __osEnqueueAndYield(NULL);
            break;
        case 2:
        case 8:
            thread->state = 1;
            __osDequeueThread(thread->queue, thread);
            break;
    }

    __osRestoreInt(prevInt);
}