summaryrefslogtreecommitdiff
path: root/lib/ultralib/src/os/getnextfaultthread.c
blob: 74c7bdca0902180b4ac6f185e4121f538bc46c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "PR/os_internal.h"
#include "PRinternal/osint.h"

OSThread* __osGetNextFaultedThread(OSThread* lastFault) {
    register int saveMask = __osDisableInt();
    register OSThread* fault;

    fault = lastFault == NULL ? __osActiveQueue : lastFault;

    while (fault->priority != -1) {
        if ((fault->flags & OS_FLAG_FAULT) != 0 && fault != lastFault) {
            break;
        }
        fault = fault->tlnext;
    }

    if (fault->priority == -1) {
        fault = NULL;
    }

    __osRestoreInt(saveMask);
    return fault;
}