It's been too long since I committed
[tpg/acess2.git] / Kernel / include / threads.h
1 /*
2  */
3 #ifndef _THREADS_H_
4 #define _THREADS_H_
5
6 #include <arch.h>
7 #include <signal.h>
8 #include <proc.h>
9
10 typedef struct sMessage
11 {
12         struct sMessage *Next;
13         Uint    Source;
14         Uint    Length;
15         Uint8   Data[];
16 } tMsg; // sizeof = 12+
17
18 typedef struct sThread
19 {
20         // --- threads.c's
21         //  0
22         struct sThread  *Next;  //!< Next thread in list
23         tSpinlock       IsLocked;       //!< Thread's spinlock
24         volatile int    Status;         //!< Thread Status
25          int    RetStatus;      //!< Return Status
26         
27         // 16
28         Uint    TID;    //!< Thread ID
29         Uint    TGID;   //!< Thread Group (Process)
30         Uint    PTID;   //!< Parent Thread ID
31         Uint    UID, GID;       //!< User and Group
32         char    *ThreadName;    //!< Name of thread
33         
34         // --- arch/proc.c's responsibility
35         // 40
36         //! Kernel Stack Base
37         tVAddr  KernelStack;
38         
39         // 44 (x86)
40         //! Memory Manager State
41         tMemoryState    MemState;
42         
43         // 48 (x86)
44         //! State on task switch
45         tTaskState      SavedState;
46         
47         // --- threads.c's
48         // 60
49          int    CurFaultNum;    //!< Current fault number, 0: none
50         tVAddr  FaultHandler;   //!< Fault Handler
51         
52         tMsg * volatile Messages;       //!< Message Queue
53         tMsg    *LastMessage;   //!< Last Message (speeds up insertion)
54         
55          int    Quantum, Remaining;     //!< Quantum Size and remaining timesteps
56          int    NumTickets;     //!< Priority - Chance of gaining CPU
57         
58         Uint    Config[NUM_CFG_ENTRIES];        //!< Per-process configuration
59 } tThread;
60
61
62 enum {
63         THREAD_STAT_NULL,
64         THREAD_STAT_ACTIVE,
65         THREAD_STAT_SLEEPING,
66         THREAD_STAT_WAITING,
67         THREAD_STAT_ZOMBIE,
68         THREAD_STAT_DEAD
69 };
70
71 enum eFaultNumbers
72 {
73         FAULT_MISC,
74         FAULT_PAGE,
75         FAULT_ACCESS,
76         FAULT_DIV0,
77         FAULT_OPCODE,
78         FAULT_FLOAT
79 };
80
81 #define GETMSG_IGNORE   ((void*)-1)
82
83 // === FUNCTIONS ===
84 extern tThread  *Proc_GetCurThread(void);
85 extern tThread  *Threads_GetThread(Uint TID);
86 extern void     Threads_Wake(tThread *Thread);
87 extern void     Threads_AddActive(tThread *Thread);
88
89 #endif

UCC git Repository :: git.ucc.asn.au