From: John Hodge Date: Mon, 18 Nov 2013 06:45:36 +0000 (+0800) Subject: Kernel - Fixed threads entering EVENTSLEEP with event pending X-Git-Tag: rel0.15~85 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=93ba8160b62a79f7d0823dec4972a498c9a3bcc6;p=tpg%2Facess2.git Kernel - Fixed threads entering EVENTSLEEP with event pending --- diff --git a/KernelLand/Kernel/events.c b/KernelLand/Kernel/events.c index 2b39714e..b0225efe 100644 --- a/KernelLand/Kernel/events.c +++ b/KernelLand/Kernel/events.c @@ -83,10 +83,13 @@ Uint32 Threads_WaitEvents(Uint32 EventMask) // Check if a wait is needed SHORTLOCK( &us->IsLocked ); LOG("Locked and preparing for wait"); - Threads_int_Sleep(THREAD_STAT_EVENTSLEEP, NULL, EventMask, - &us, NULL, &us->IsLocked); - // Woken when lock is acquired - SHORTLOCK( &us->IsLocked ); + if( (us->EventState & EventMask) == 0 ) + { + Threads_int_Sleep(THREAD_STAT_EVENTSLEEP, NULL, EventMask, + &us, NULL, &us->IsLocked); + // Woken when lock is acquired + SHORTLOCK( &us->IsLocked ); + } // Get return value and clear changed event bits rv = us->EventState & EventMask;