From: John Hodge Date: Thu, 9 Sep 2010 01:27:15 +0000 (+0800) Subject: Per-CPU task switch disable, minor spiderscript changes X-Git-Tag: rel0.06~24 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=3ac178949c57e5cbd0cfe59915da9840ecefa68e;p=tpg%2Facess2.git Per-CPU task switch disable, minor spiderscript changes --- diff --git a/Kernel/arch/x86/include/arch.h b/Kernel/arch/x86/include/arch.h index 3ce91308..16a04022 100644 --- a/Kernel/arch/x86/include/arch.h +++ b/Kernel/arch/x86/include/arch.h @@ -166,16 +166,17 @@ typedef signed short Sint16; typedef signed long Sint32; typedef signed long long Sint64; typedef Uint size_t; +typedef char BOOL; typedef Uint64 tPAddr; typedef Uint32 tVAddr; typedef struct { - Uint gs, fs, es, ds; - Uint edi, esi, ebp, kesp; + Uint gs, fs, es, ds; + Uint edi, esi, ebp, kesp; Uint ebx, edx, ecx, eax; - Uint int_num, err_code; - Uint eip, cs; + Uint int_num, err_code; + Uint eip, cs; Uint eflags, esp, ss; } tRegs; diff --git a/Kernel/include/threads.h b/Kernel/include/threads.h index f1e4bb48..20d21f4f 100644 --- a/Kernel/include/threads.h +++ b/Kernel/include/threads.h @@ -7,14 +7,21 @@ #include #include +/** + * \brief IPC Message + */ typedef struct sMessage { - struct sMessage *Next; - Uint Source; - Uint Length; - Uint8 Data[]; -} tMsg; // sizeof = 12+ + struct sMessage *Next; //!< Next message in thread's inbox + tTID Source; //!< Source thread ID + Uint Length; //!< Length of message data in bytes + Uint8 Data[]; //!< Message data +} tMsg; +/** + * \brief Core threading structure + * + */ typedef struct sThread { // --- threads.c's @@ -84,6 +91,9 @@ enum eFaultNumbers #define GETMSG_IGNORE ((void*)-1) +// === GLOBALS === +extern BOOL gaThreads_NoTaskSwitch[MAX_CPUS]; + // === FUNCTIONS === extern tThread *Proc_GetCurThread(void); extern tThread *Threads_GetThread(Uint TID); diff --git a/Kernel/threads.c b/Kernel/threads.c index 5695955c..51cfbdfe 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -78,6 +78,7 @@ tThread *gActiveThreads = NULL; // Currently Running Threads tThread *gSleepingThreads = NULL; // Sleeping Threads tThread *gDeleteThreads = NULL; // Threads to delete int giNumCPUs = 1; // Number of CPUs +BOOL gaThreads_NoTaskSwitch[MAX_CPUS]; // Disables task switches for each core (Pseudo-IF) // === CODE === /** @@ -832,12 +833,17 @@ tThread *Threads_GetNextToRun(int CPU, tThread *Last) { tThread *thread; int ticket; - int number; + int number; // If this CPU has the lock, we must let it complete if( CPU_HAS_LOCK( &glThreadListLock ) ) return Last; + // Same if the current CPU has any lock + if( gaThreads_NoTaskSwitch[CPU] ) + return Last; + + // Lock thread list SHORTLOCK( &glThreadListLock ); diff --git a/Usermode/Libraries/libspiderscript.so_src/parse.c b/Usermode/Libraries/libspiderscript.so_src/parse.c index 3ad4081c..f32f876f 100644 --- a/Usermode/Libraries/libspiderscript.so_src/parse.c +++ b/Usermode/Libraries/libspiderscript.so_src/parse.c @@ -222,6 +222,7 @@ tAST_Node *Parse_DoBlockLine(tParser *Parser) ret = AST_NewIf(Parser, cond, true, false); } return ret; + case TOK_RWD_FOR: { tAST_Node *init=NULL, *cond=NULL, *inc=NULL, *code; @@ -245,6 +246,7 @@ tAST_Node *Parse_DoBlockLine(tParser *Parser) ret = AST_NewLoop(Parser, init, 0, cond, inc, code); } return ret; + case TOK_RWD_DO: case TOK_RWD_WHILE: TODO(Parser, "Implement do and while\n");