blob: 2ce15465c3f6cb511e86f921b818999ed741cb2a (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#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);
}
|