diff --git a/Kernel/arch/x86/include/arch.h b/Kernel/arch/x86/include/arch.h index 3ce9130806f52800c841fc6a34ca1434aa9401d2..16a04022a0bfb211e9dcfcf08cf230cba30643fc 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 f1e4bb48b9f03721abbca086dc2fdd9eef33b18c..20d21f4fbe0e555fbd5d1fee2cc2ee71d1cc3d05 100644 --- a/Kernel/include/threads.h +++ b/Kernel/include/threads.h @@ -7,14 +7,21 @@ #include <signal.h> #include <proc.h> +/** + * \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 5695955c696bed44db4ee0a57516e49ddbac3ac8..51cfbdfef3e9cfb70ed2c5d24cb27ef890fbe201 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 3ad4081c8e94ddd252842dcf2ecc5e452fb7b81b..f32f876fc3f0b612cca7352eae991c4778b1bef6 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");