mirror of
https://github.com/HarbourMasters/Starship
synced 2026-06-18 23:56:53 -04:00
902dc0b829
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg * Fixed libultra compilation flags * Matched viblack * Matched virepeatline, visetmode, visetspecial and viswapbuf * Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread * Fixed bss bs * Matched even more libultra stuff * Matched even more * __osRdbSend * Decompiled most of the functions of libultra <3 * Matched last functions * Added a separation to libultra macros * Removed ARRLEN from controller.h * Fix libultra warnings --------- Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#include "PR/os_internal.h"
|
|
#include "PR/ultraerror.h"
|
|
#include "osint.h"
|
|
|
|
void osStartThread(OSThread* t) {
|
|
register u32 saveMask = __osDisableInt();
|
|
|
|
switch (t->state) {
|
|
case OS_STATE_WAITING:
|
|
t->state = OS_STATE_RUNNABLE;
|
|
__osEnqueueThread(&__osRunQueue, t);
|
|
break;
|
|
case OS_STATE_STOPPED:
|
|
if (t->queue == NULL || t->queue == &__osRunQueue) {
|
|
t->state = OS_STATE_RUNNABLE;
|
|
__osEnqueueThread(&__osRunQueue, t);
|
|
} else {
|
|
t->state = OS_STATE_WAITING;
|
|
__osEnqueueThread(t->queue, t);
|
|
__osEnqueueThread(&__osRunQueue, __osPopThread(t->queue));
|
|
}
|
|
break;
|
|
#ifdef _DEBUG
|
|
default:
|
|
__osError(ERR_OSSTARTTHREAD, 0);
|
|
__osRestoreInt(saveMask);
|
|
return;
|
|
#endif
|
|
}
|
|
|
|
if (__osRunningThread == NULL) {
|
|
__osDispatchThread();
|
|
} else if (__osRunningThread->priority < __osRunQueue->priority) {
|
|
__osRunningThread->state = OS_STATE_RUNNABLE;
|
|
__osEnqueueAndYield(&__osRunQueue);
|
|
}
|
|
|
|
__osRestoreInt(saveMask);
|
|
}
|