Fixing MultiCPU thread distribution (only tested in single-cpu)
[tpg/acess2.git] / Kernel / include / threads.h
index 377b6ac..715be8c 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <arch.h>
 #include <signal.h>
+#include <proc.h>
 
 typedef struct sMessage
 {
@@ -16,36 +17,48 @@ typedef struct sMessage
 
 typedef struct sThread
 {
+       // --- threads.c's
+       //  0
        struct sThread  *Next;  //!< Next thread in list
-        int    IsLocked;       //!< Thread's spinlock
-        int    Status;         //!< Thread Status
+       tSpinlock       IsLocked;       //!< Thread's spinlock
+       volatile int    Status;         //!< Thread Status
         int    RetStatus;      //!< Return Status
        
+       // 16
        Uint    TID;    //!< Thread ID
        Uint    TGID;   //!< Thread Group (Process)
        Uint    PTID;   //!< Parent Thread ID
        Uint    UID, GID;       //!< User and Group
        char    *ThreadName;    //!< Name of thread
        
-       tVAddr  KernelStack;    //!< Kernel Stack Base
+       // --- arch/proc.c's responsibility
+       // 40
+       //! Kernel Stack Base
+       tVAddr  KernelStack;
        
+       // 44 (x86)
        //! Memory Manager State
        tMemoryState    MemState;
        
+       // 48 (x86)
        //! State on task switch
        tTaskState      SavedState;
        
-        int    CurSignal;      //!< Signal currently being handled (0 for none)
-       tVAddr  SignalHandlers[NSIG];   //!< Signal Handler List
-       tTaskState      SignalState;    //!< Saved state for signal handler
+       // --- threads.c's
+       // 60
+        int    CurFaultNum;    //!< Current fault number, 0: none
+       tVAddr  FaultHandler;   //!< Fault Handler
        
-       tMsg    *Messages;      //!< Message Queue
+       tMsg * volatile Messages;       //!< Message Queue
        tMsg    *LastMessage;   //!< Last Message (speeds up insertion)
        
         int    Quantum, Remaining;     //!< Quantum Size and remaining timesteps
         int    NumTickets;     //!< Priority - Chance of gaining CPU
        
        Uint    Config[NUM_CFG_ENTRIES];        //!< Per-process configuration
+       
+       // --- proc.c's
+       volatile int    CurCPU;
 } tThread;
 
 
@@ -58,10 +71,23 @@ enum {
        THREAD_STAT_DEAD
 };
 
+enum eFaultNumbers
+{
+       FAULT_MISC,
+       FAULT_PAGE,
+       FAULT_ACCESS,
+       FAULT_DIV0,
+       FAULT_OPCODE,
+       FAULT_FLOAT
+};
+
+#define GETMSG_IGNORE  ((void*)-1)
+
 // === FUNCTIONS ===
-extern tThread *Proc_GetCurThread();
+extern tThread *Proc_GetCurThread(void);
 extern tThread *Threads_GetThread(Uint TID);
 extern void    Threads_Wake(tThread *Thread);
 extern void    Threads_AddActive(tThread *Thread);
+extern tThread *Threads_GetNextToRun(int CPU, tThread *Last);
 
 #endif

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