osGetCurrFaultedThread.3p
2.15 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
56
57
58
59
60
61
62
63
64
.TH __osGetCurrFaultedThread 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
__osGetCurrFaultedThread,
__osGetNextFaultedThread \- internal routines to access faulted thread
.SH SYNOPSIS
.nf
\f3
.Op c
#include <ultra64.h>
#include <os_internal.h>
.sp .8v
OSThread * __osGetCurrFaultedThread(void);
.sp .8v
OSThread * __osGetNextFaultedThread(OSThread *last);
.Op
\f1
.fi
.SH DESCRIPTION
The Nintendo64 operating system contains some internal routines to access
threads that have faulted due to various exceptions such as TLB misses.
Sine these routines were originally designed for internal use only, their
names have a "__" prefix notation. Internally, there exists a
thread queue containing all the active threads created in the system. This
queue is used mainly by
.I rmon
for debugging purpose.
.PP
Currently, when a thread hits a CPU exception
such as a TLB exception on an instruction fetch, the exception handler
saves all the appropriate registers to the thread context, stops the thread
from execution, marks it for the debugger, sends a message to any registered
thread waiting for the OS_EVENT_FAULT event, and dispatches the next runnable
thread from the run queue. If
.I rmon
is running, it registers to receives the OS_EVENT_FAULT event, receives the
faulted message, sends the faulted thread context to
.I gload
running on the host, and causes
.I gload
to print the thread context (mainly registers) to the screen.
If desired,
developers can use the routines below in a thread that registers for the
OS_EVENT_FAULT to handle CPU fault. Please see the sample application "fault"
on how to use these routines.
.PP
__osGetCurrFaultedThread returns the most recent faulted thread or NULL,
if there is no faulted thread.
.PP
Based on the
.I last
thread, __osGetNextFaultedThread returns the next faulted thread from the
active thread queue. If
.I last
is NULL, this routine performs a sequential search from the beginning of the
queue. Otherwise, it starts the search from the
.I last
thread. If no faulted thread is found, NULL is returned.
.SH "SEE ALSO"
.IR osInitialize (3P),
.IR osCreateThread (3P),
.IR osStartThread (3P),
.IR osStopThread (3P),
.IR osDestroyThread (3P)