From ca2cf2eb7207fb9c76e6d060e885d2e9e09762ec Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Wed, 28 Nov 2012 22:26:12 +0800 Subject: [PATCH] Kernel - Debugging hard locks --- KernelLand/Kernel/arch/x86/lib.c | 2 ++ KernelLand/Kernel/semaphore.c | 2 -- KernelLand/Kernel/threads.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/KernelLand/Kernel/arch/x86/lib.c b/KernelLand/Kernel/arch/x86/lib.c index 6b3d7228..1b1a0c3f 100644 --- a/KernelLand/Kernel/arch/x86/lib.c +++ b/KernelLand/Kernel/arch/x86/lib.c @@ -85,6 +85,8 @@ void SHORTLOCK(struct sShortSpinlock *Lock) __ASM__ ("pushf;\n\tpop %0" : "=r"(IF)); IF &= 0x200; // AND out all but the interrupt flag + ASSERT( !CPU_HAS_LOCK(Lock) ); + #if TRACE_LOCKS if( TRACE_LOCK_COND ) { diff --git a/KernelLand/Kernel/semaphore.c b/KernelLand/Kernel/semaphore.c index e43547a2..2c9fc94b 100644 --- a/KernelLand/Kernel/semaphore.c +++ b/KernelLand/Kernel/semaphore.c @@ -127,10 +127,8 @@ int Semaphore_Wait(tSemaphore *Sem, int MaxToTake) toWake->RetStatus = given; // Wake the sleeper - SHORTLOCK( &glThreadListLock ); if( toWake->Status != THREAD_STAT_ACTIVE ) Threads_AddActive(toWake); - SHORTREL( &glThreadListLock ); } SHORTREL( &Sem->Protector ); diff --git a/KernelLand/Kernel/threads.c b/KernelLand/Kernel/threads.c index 2f76b78a..92a7a576 100644 --- a/KernelLand/Kernel/threads.c +++ b/KernelLand/Kernel/threads.c @@ -765,11 +765,11 @@ int Threads_Wake(tThread *Thread) return -EALREADY; case THREAD_STAT_SLEEPING: - SHORTLOCK( &glThreadListLock ); // Remove from sleeping queue + SHORTLOCK( &glThreadListLock ); Threads_int_DelFromQueue(&gSleepingThreads, Thread); - SHORTREL( &glThreadListLock ); + Threads_AddActive( Thread ); #if DEBUG_TRACE_STATE -- 2.20.1