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

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