From: John Hodge (sonata) Date: Wed, 28 Nov 2012 14:26:12 +0000 (+0800) Subject: Kernel - Debugging hard locks X-Git-Tag: rel0.15~637 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ca2cf2eb7207fb9c76e6d060e885d2e9e09762ec;p=tpg%2Facess2.git Kernel - Debugging hard locks --- 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