From 745b0dcc28d1d7765fe4d3beb0090acd75dfec50 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 7 Sep 2010 09:14:35 +0800 Subject: [PATCH] More thread issue fixing, still not working --- Kernel/arch/x86/include/arch.h | 1 + Kernel/threads.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Kernel/arch/x86/include/arch.h b/Kernel/arch/x86/include/arch.h index 0126be31..3ce91308 100644 --- a/Kernel/arch/x86/include/arch.h +++ b/Kernel/arch/x86/include/arch.h @@ -74,6 +74,7 @@ static inline int CPU_HAS_LOCK(struct sShortSpinlock *Lock) { * \note This type of lock halts interrupts, so ensure that no timing * functions are called while it is held. As a matter of fact, spend as * little time as possible with this lock held + * \note If \a STACKED_LOCKS is set, this type of spinlock can be nested */ static inline void SHORTLOCK(struct sShortSpinlock *Lock) { int v = 1; diff --git a/Kernel/threads.c b/Kernel/threads.c index aa550ab7..5695955c 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -437,6 +437,14 @@ void Threads_Kill(tThread *Thread, int Status) // Lock thread (stop us recieving messages) SHORTLOCK( &Thread->IsLocked ); + // Clear Message Queue + while( Thread->Messages ) + { + msg = Thread->Messages->Next; + free( Thread->Messages ); + Thread->Messages = msg; + } + // Lock thread list SHORTLOCK( &glThreadListLock ); @@ -449,14 +457,6 @@ void Threads_Kill(tThread *Thread, int Status) return; } - // Clear Message Queue - while( Thread->Messages ) - { - msg = Thread->Messages->Next; - free( Thread->Messages ); // BIG NO-NO - Thread->Messages = msg; - } - // Ensure that we are not rescheduled Thread->Remaining = 0; // Clear Remaining Quantum Thread->Quantum = 0; // Clear Quantum to indicate dead thread -- 2.20.1