critical was critical (deadlock with timeouts)
authorClaus Gittinger <cg@exept.de>
Thu, 18 Apr 1996 21:12:03 +0200
changeset 1216 d7cbc6eb8dd4
parent 1215 43e8e17fd9f5
child 1217 4f7099eb007c
critical was critical (deadlock with timeouts)
RecursionLock.st
--- a/RecursionLock.st	Thu Apr 18 18:19:04 1996 +0200
+++ b/RecursionLock.st	Thu Apr 18 21:12:03 1996 +0200
@@ -101,27 +101,48 @@
     "evaluate aBlock as a critical region, but do not block,
      if this lock is already held by the current process."
 
-    |active|
+    |active wasBlocked|
 
     active := Processor activeProcess.
     process == active ifTrue:[
         aBlock value
     ] ifFalse:[
+        "/
+        "/ sema wait & process := active
+        "/ and:
+        "/ proces := nil & sema signal
+        "/ must both be done atomic
+        "/ Scenario:
+        "/   ... recLock critical
+        "/         got lock
+        "/         evaluated
+        "/         set process to nil
+        "/         -> timer interrupt
+        "/              recLock critical in timeOut action
+        "/              process isNil
+        "/                 sema wait !!!!!! DEADLOCK
+        "/
+        wasBlocked := OperatingSystem blockInterrupts.
         sema critical:[
             [
                 process := active.
-                aBlock value
-            ] valueNowOrOnUnwindDo:[
+                wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+                aBlock value.
+                OperatingSystem blockInterrupts.
+            ] valueOnUnwindDo:[
                 process := nil.
             ]
-        ]
+        ].
+        process := nil.
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
     ].
 
     "Modified: 13.4.1996 / 00:19:31 / stefan"
+    "Modified: 18.4.1996 / 21:09:39 / cg"
 ! !
 
 !RecursionLock class methodsFor:'documentation'!
 
-version 
-    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.9 1996-04-18 16:19:04 cg Exp $'
+version
+    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.10 1996-04-18 19:12:03 cg Exp $'
 ! !