Kernel - Fixed threads entering EVENTSLEEP with event pending
authorJohn Hodge <[email protected]>
Mon, 18 Nov 2013 06:45:36 +0000 (14:45 +0800)
committerJohn Hodge <[email protected]>
Mon, 18 Nov 2013 06:45:36 +0000 (14:45 +0800)
KernelLand/Kernel/events.c

index 2b39714..b0225ef 100644 (file)
@@ -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;

UCC git Repository :: git.ucc.asn.au