Semaphore.st
changeset 3836 318f7d6f242b
parent 3669 59baacaab0a8
child 4437 212260fce312
--- a/Semaphore.st	Mon Sep 14 11:56:00 1998 +0200
+++ b/Semaphore.st	Mon Sep 14 11:58:08 1998 +0200
@@ -366,15 +366,15 @@
 
     wasBlocked := OperatingSystem blockInterrupts.
     [
-	|p|
+        |p|
 
-	count := count + 1.
-	waitingProcesses notEmpty ifTrue:[
-	    p := waitingProcesses removeFirst.
-	    Processor resume:p.
-	].
+        count := count + 1.
+        p := waitingProcesses removeFirstIfAbsent:nil.
+        p notNil ifTrue:[
+            Processor resume:p.
+        ].
     ] valueNowOrOnUnwindDo:[
-	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
     ]
 
     "Modified: / 4.2.1998 / 21:01:07 / cg"
@@ -442,14 +442,20 @@
     |wasBlocked|
 
     count == 0 ifTrue:[
-	wasBlocked := OperatingSystem blockInterrupts.
-	[
-	    count == 0 ifTrue:[
-		self signal
-	    ].
-	] valueNowOrOnUnwindDo:[
-	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	]
+        wasBlocked := OperatingSystem blockInterrupts.
+        [
+            |p|
+
+            count == 0 ifTrue:[
+                count := 1.
+                p := waitingProcesses removeFirstIfAbsent:nil.
+                p notNil ifTrue:[
+                    Processor resume:p.
+                ].
+            ].
+        ] valueNowOrOnUnwindDo:[
+            wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        ]
     ]
 
     "Modified: 28.2.1996 / 21:24:08 / cg"
@@ -655,5 +661,5 @@
 !Semaphore class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Semaphore.st,v 1.52 1998-07-21 15:45:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Semaphore.st,v 1.53 1998-09-14 09:58:08 cg Exp $'
 ! !