Networking - Reworked route table management
[tpg/acess2.git] / Kernel / include / threads_int.h
index 64b2986..66bb8c1 100644 (file)
@@ -8,6 +8,9 @@
 #include <threads.h>
 #include <proc.h>
 
+
+typedef struct sProcess        tProcess;
+
 /**
  * \brief IPC Message
  */
@@ -19,11 +22,28 @@ typedef struct sMessage
        Uint8   Data[]; //!< Message data
 } tMsg;
 
+/**
+ * \brief Process state
+ */
+struct sProcess
+{
+       tPID    PID;
+        int    nThreads;
+       
+       tUID    UID;    //!< User ID
+       tGID    GID;    //!< User and Group
+       tMemoryState    MemState;
+
+        int    MaxFD;
+       char    *CurrentWorkingDir;
+       char    *RootDir;
+};
+
 /**
  * \brief Core threading structure
  * 
  */
-typedef struct sThread
+struct sThread
 {
        // --- threads.c's
        /**
@@ -38,19 +58,15 @@ typedef struct sThread
        void    *WaitPointer;   //!< What (Mutex/Thread/other) is the thread waiting on
         int    RetStatus;      //!< Return Status
        
-       Uint    TID;    //!< Thread ID
-       Uint    TGID;   //!< Thread Group (Process)
+       tTID    TID;    //!< Thread ID
+       struct sProcess *Process;       //!< Thread Group / Process
        struct sThread  *Parent;        //!< Parent Thread
-       Uint    UID, GID;       //!< User and Group
        char    *ThreadName;    //!< Name of thread
        
        // --- arch/proc.c's responsibility
        //! Kernel Stack Base
        tVAddr  KernelStack;
        
-       //! Memory Manager State
-       tMemoryState    MemState;
-       
        //! State on task switch
        tTaskState      SavedState;
        
@@ -64,12 +80,15 @@ typedef struct sThread
         int    Quantum, Remaining;     //!< Quantum Size and remaining timesteps
         int    Priority;       //!< Priority - 0: Realtime, higher means less time
        
-       Uint    Config[NUM_CFG_ENTRIES];        //!< Per-process configuration
+        int    _errno;
        
        volatile int    CurCPU;
        
-        int    bInstrTrace;
-} tThread;
+       bool    bInstrTrace;
+       
+       // --- event.c
+       Uint32  EventState;
+};
 
 
 enum {
@@ -78,6 +97,8 @@ enum {
        THREAD_STAT_SLEEPING,   // Message Sleep
        THREAD_STAT_MUTEXSLEEP, // Mutex Sleep
        THREAD_STAT_SEMAPHORESLEEP,     // Semaphore Sleep
+       THREAD_STAT_QUEUESLEEP, // Queue
+       THREAD_STAT_EVENTSLEEP, // Event sleep
        THREAD_STAT_WAITING,    // ??? (Waiting for a thread)
        THREAD_STAT_PREINIT,    // Being created
        THREAD_STAT_ZOMBIE,     // Died/Killed, but parent not informed
@@ -90,6 +111,8 @@ static const char * const casTHREAD_STAT[] = {
        "THREAD_STAT_SLEEPING",
        "THREAD_STAT_MUTEXSLEEP",
        "THREAD_STAT_SEMAPHORESLEEP",
+       "THREAD_STAT_QUEUESLEEP",
+       "THREAD_STAT_EVENTSLEEP",
        "THREAD_STAT_WAITING",
        "THREAD_STAT_PREINIT",
        "THREAD_STAT_ZOMBIE",
@@ -110,6 +133,7 @@ extern int  Threads_Wake(tThread *Thread);
 extern void    Threads_Kill(tThread *Thread, int Status);
 extern void    Threads_AddActive(tThread *Thread);
 extern tThread *Threads_RemActive(void);
+extern void    Threads_Delete(tThread *Thread);
 extern tThread *Threads_GetNextToRun(int CPU, tThread *Last);
 
 extern tThread *Threads_CloneTCB(Uint Flags);

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