13 typedef struct sMessage
15 struct sMessage *Next; //!< Next message in thread's inbox
16 tTID Source; //!< Source thread ID
17 Uint Length; //!< Length of message data in bytes
18 Uint8 Data[]; //!< Message data
22 * \brief Core threading structure
25 typedef struct sThread
29 * \brief Next thread in current list
30 * \note Required to be first for linked list hacks to work
33 struct sThread *GlobalNext; //!< Next thread in global list
34 struct sThread *GlobalPrev; //!< Previous thread in global list
35 tShortSpinlock IsLocked; //!< Thread's spinlock
36 volatile int Status; //!< Thread Status
37 int RetStatus; //!< Return Status
39 Uint TID; //!< Thread ID
40 Uint TGID; //!< Thread Group (Process)
41 struct sThread *Parent; //!< Parent Thread
42 Uint UID, GID; //!< User and Group
43 char *ThreadName; //!< Name of thread
45 // --- arch/proc.c's responsibility
49 //! Memory Manager State
50 tMemoryState MemState;
52 //! State on task switch
53 tTaskState SavedState;
56 int CurFaultNum; //!< Current fault number, 0: none
57 tVAddr FaultHandler; //!< Fault Handler
59 tMsg * volatile Messages; //!< Message Queue
60 tMsg *LastMessage; //!< Last Message (speeds up insertion)
62 int Quantum, Remaining; //!< Quantum Size and remaining timesteps
63 int Priority; //!< Priority - 0: Realtime, higher means less time
65 Uint Config[NUM_CFG_ENTRIES]; //!< Per-process configuration
72 THREAD_STAT_NULL, // Invalid process
73 THREAD_STAT_ACTIVE, // Running and schedulable process
74 THREAD_STAT_SLEEPING, // Message Sleep
75 THREAD_STAT_OFFSLEEP, // Mutex Sleep (or waiting on a thread)
76 THREAD_STAT_WAITING, // ???
77 THREAD_STAT_PREINIT, // Being created
78 THREAD_STAT_ZOMBIE, // Died, just not removed
79 THREAD_STAT_DEAD // Why do we care about these???
92 #define GETMSG_IGNORE ((void*)-1)
95 extern BOOL gaThreads_NoTaskSwitch[MAX_CPUS];
98 extern tThread *Proc_GetCurThread(void);
99 extern tThread *Threads_GetThread(Uint TID);
100 extern void Threads_SetPriority(tThread *Thread, int Pri);
101 extern int Threads_Wake(tThread *Thread);
102 extern void Threads_AddActive(tThread *Thread);
103 extern tThread *Threads_GetNextToRun(int CPU, tThread *Last);