blob: 0f4c83cff81295b4ef850dc09424de9c6adb2a80 (
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
|
#include "global.h"
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) {
register u32 prevInt = __osDisableInt();
while (mq->validCount == 0) {
if (flag == OS_MESG_NOBLOCK) {
__osRestoreInt(prevInt);
return -1;
}
__osRunningThread->state = 8;
__osEnqueueAndYield((OSThread**)mq);
}
if (msg != NULL) {
*msg = mq->msg[mq->first];
}
mq->first = (mq->first + 1) % mq->msgCount;
mq->validCount--;
if (mq->fullqueue->next != NULL) {
osStartThread(__osPopThread(&mq->fullqueue));
}
__osRestoreInt(prevInt);
return 0;
}
|