blob: 66c6039e0221eeb7e15e19be65ee8b33725661dc (
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
|
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PRinternal/osint.h"
void osSetThreadPri(OSThread* t, OSPri pri) {
register u32 saveMask;
#ifdef _DEBUG
if ((pri < OS_PRIORITY_IDLE) || (pri > OS_PRIORITY_MAX)) {
__osError(ERR_OSSETTHREADPRI, 1, pri);
return;
}
#endif
saveMask = __osDisableInt();
if (t == NULL) {
t = __osRunningThread;
}
if (t->priority != pri) {
t->priority = pri;
if (t != __osRunningThread && t->state != OS_STATE_STOPPED) {
__osDequeueThread(t->queue, t);
__osEnqueueThread(t->queue, t);
}
if (__osRunningThread->priority < __osRunQueue->priority) {
__osRunningThread->state = OS_STATE_RUNNABLE;
__osEnqueueAndYield(&__osRunQueue);
}
}
__osRestoreInt(saveMask);
}
|