b55fe0e066a8498afadcc9c8a263d3c5be9ea13d
[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
9 typedef struct sMessage
10 {
11         struct sMessage *Next;
12         Uint    Source;
13         Uint    Length;
14         Uint8   Data[];
15 } tMsg; // sizeof = 12+
16
17 typedef struct sThread
18 {
19         // --- threads.c's
20         struct sThread  *Next;  //!< Next thread in list
21         tSpinlock       IsLocked;       //!< Thread's spinlock
22         volatile int    Status;         //!< Thread Status
23          int    RetStatus;      //!< Return Status
24         
25         Uint    TID;    //!< Thread ID
26         Uint    TGID;   //!< Thread Group (Process)
27         Uint    PTID;   //!< Parent Thread ID
28         Uint    UID, GID;       //!< User and Group
29         char    *ThreadName;    //!< Name of thread
30         
31         // --- arch/proc.c's responsibility
32         //! Kernel Stack Base
33         tVAddr  KernelStack;
34         
35         //! Memory Manager State
36         tMemoryState    MemState;
37         
38         //! State on task switch
39         tTaskState      SavedState;
40         
41         // --- threads.c's
42          int    CurSignal;      //!< Signal currently being handled (0 for none)
43         tVAddr  SignalHandlers[NSIG];   //!< Signal Handler List
44         tTaskState      SignalState;    //!< Saved state for signal handler
45         
46         tMsg * volatile Messages;       //!< Message Queue
47         tMsg    *LastMessage;   //!< Last Message (speeds up insertion)
48         
49          int    Quantum, Remaining;     //!< Quantum Size and remaining timesteps
50          int    NumTickets;     //!< Priority - Chance of gaining CPU
51         
52         Uint    Config[NUM_CFG_ENTRIES];        //!< Per-process configuration
53 } tThread;
54
55
56 enum {
57         THREAD_STAT_NULL,
58         THREAD_STAT_ACTIVE,
59         THREAD_STAT_SLEEPING,
60         THREAD_STAT_WAITING,
61         THREAD_STAT_ZOMBIE,
62         THREAD_STAT_DEAD
63 };
64
65 // === FUNCTIONS ===
66 extern tThread  *Proc_GetCurThread();
67 extern tThread  *Threads_GetThread(Uint TID);
68 extern void     Threads_Wake(tThread *Thread);
69 extern void     Threads_AddActive(tThread *Thread);
70
71 #endif

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