__osGetCurrFaultedThread __osGetCurrFaultedThread (function)

__osGetCurrFaultedThread, __osGetNextFaultedThread

Internal routines that the N64 operating system uses to gain access to the faulted thread.


#include <ultra64.h>     /* ultra64.h */
#include <os_internal.h>
OSThread * __osGetCurrFaultedThread(void);
OSThread * __osGetNextFaultedThread(OSThread *last);


The __osGetCurrFaultedThread and __osGetNextFaultedThread functions are internal routines that the N64 operating system uses to gain access to the faulted thread.The Nintendo 64 operating system contains internal routines to gain access to threads that have faulted due to various exceptions such as TLB misses. These routines were designed for internal use only, so their names have a double-underscore (__) prefix notation. Internally, they exist in the thread queue containing all the active threads created in the system. This queue is used mainly by the rmon debugging program for debugging purpose.

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 the rmon debugging program is running, it registers to receive the OS_EVENT_FAULT event, records the faulted message, sends the faulted thread context to the gload tool running on the host, and causes the gload tool to print the thread context (mainly registers) to the screen. If necessary, developers can use the routines below in a thread that registers for the OS_EVENT_FAULT to handle CPU faults. Please see the "fault" sample application to learn how to use these routines.

The __osGetCurrFaultedThread routine returns the most recently faulted thread , or NULL if there is no faulted thread.

Based on the last thread, __osGetNextFaultedThread returns the next faulted thread from the active thread queue. If last is NULL, this routine performs a sequential search from the beginning of the queue. If last is not NULL, it starts the search from the last thread. If no faulted thread is found, NULL is returned.

See Also

osInitialize, osCreateThread, osStartThread, osStopThread, and osDestroyThread

Revision History

1999/04/30 Changed Format