getnextfaultthread.c
1.69 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include "osint.h"
/*
* __osGetNextFaultedThread(OSThread *lastFault)
*
* Finds and returns the next faulted thread from the active queue list (that
* doesn't match the last faulted thread). If lastFault is NULL, start
* the search from the beginning of the active list. Otherwise, start the
* search from lastFault. This routine returns NULL if it cannot find any
* faulted thread.
*/
OSThread *
__osGetNextFaultedThread(OSThread *lastFault)
{
register u32 saveMask;
register OSThread *fault;
/* Disable interrupts */
saveMask = __osDisableInt();
fault = (lastFault == (OSThread *)NULL) ? __osActiveQueue : lastFault;
while (fault->priority != -1) {
if ((fault->flags & OS_FLAG_FAULT) && (fault != lastFault)) {
/* This thread faulted */
break;
}
fault = fault->tlnext;
} /* while */
/* We can't find any faulted thread, set fault to NULL for return */
if (fault->priority == -1)
fault = (OSThread *)NULL;
/* Restore interrupts */
__osRestoreInt(saveMask);
return(fault);
}