ProcessorScheduler.st
changeset 27 d98f9dd437f7
parent 25 e34a6267c79b
child 32 ee1a621c696c
--- a/ProcessorScheduler.st	Mon Dec 20 02:27:42 1993 +0100
+++ b/ProcessorScheduler.st	Mon Dec 20 18:32:29 1993 +0100
@@ -17,7 +17,7 @@
                                 readFds readSemaphores readChecks
                                 writeFds writeSemaphores writeChecks
                                 timeouts timeoutActions timeoutSemaphores
-                                idleActions nTimeouts dispatching'
+                                idleActions anyTimeouts dispatching'
          classVariableNames:'KnownProcesses KnownProcessIds
                              PureEventDriven
                              UserSchedulingPriority TimingPriority'
@@ -30,7 +30,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.7 1993-12-19 23:40:17 claus Exp $
+$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.8 1993-12-20 17:32:24 claus Exp $
 '!
 
 Smalltalk at:#Processor put:nil!
@@ -316,7 +316,7 @@
     timeouts := Array with:nil.
     timeoutSemaphores := Array with:nil.
     timeoutActions := Array with:nil.
-    nTimeouts := 0.
+    anyTimeouts := false.
     dispatching := false.
 
     "handcraft the first (dispatcher-) process - this one will never
@@ -708,7 +708,7 @@
     |any millis pri p nActions "{ Class: SmallInteger }" |
 
     "handle all timeout actions"
-    nTimeouts ~~ 0 ifTrue:[
+    anyTimeouts ifTrue:[
         self evaluateTimeouts
     ].
 
@@ -762,7 +762,7 @@
 
 "
     pri < TimingPriority ifTrue:[
-        (nTimeouts ~~ 0) ifTrue:[
+        anyTimeouts ifTrue:[
             millis := self timeToNextTimeout.
             millis == 0 ifTrue:[^ self].
         ]
@@ -771,7 +771,7 @@
     pri < UserSchedulingPriority ifTrue:[
 
         "comment out this if above is uncommented"
-        (nTimeouts ~~ 0) ifTrue:[
+        anyTimeouts ifTrue:[
             millis := self timeToNextTimeout.
             millis == 0 ifTrue:[^ self].
         ].
@@ -857,7 +857,7 @@
 
     doingGC := true.
     [doingGC] whileTrue:[
-        (nTimeouts ~~ 0) ifTrue:[
+        anyTimeouts ifTrue:[
             millis := self timeToNextTimeout.
             (millis notNil and:[millis <= 0]) ifTrue:[
                 ^ self    "oops - hurry up checking"
@@ -932,7 +932,7 @@
 
     |now aTime block blocksToEvaluate n "{ Class: SmallInteger }"|
 
-    nTimeouts == 0 ifTrue:[ ^ self].
+    anyTimeouts ifFalse:[ ^ self].
 
     "have to collect the blocks first, then evaluate them. This avoids
      problems due to newly inserted blocks."
@@ -940,6 +940,7 @@
     now := OperatingSystem getMillisecondTime.
     blocksToEvaluate := nil.
     n := timeouts size.
+    anyTimeouts := false.
     1 to:n do:[:index |
         aTime := timeouts at:index.
         aTime notNil ifTrue:[
@@ -962,8 +963,9 @@
                     ]
                 ].
                 timeouts at:index put:nil.
-                nTimeouts := nTimeouts - 1
-            ]
+            ] ifTrue:[
+		anyTimeouts := true
+	    ]
         ]
     ].
 
@@ -1014,7 +1016,6 @@
         timeouts at:idx put:nil.
         timeoutSemaphores at:idx put:nil.
         timeoutActions at:idx put:nil.
-        nTimeouts := nTimeouts - 1.
     ].
     OperatingSystem unblockInterrupts.
 !
@@ -1044,8 +1045,8 @@
             timeouts := timeouts copyWith:then.
             timeoutActions := timeoutActions copyWith:nil.
         ].
-        nTimeouts := nTimeouts + 1.
     ].
+    anyTimeouts := true.
     OperatingSystem unblockInterrupts.
 ! !
 
@@ -1130,8 +1131,8 @@
             timeouts := timeouts copyWith:then.
             timeoutSemaphores := timeoutSemaphores copyWith:nil.
         ].
-        nTimeouts := nTimeouts + 1.
     ].
+    anyTimeouts := true.
     OperatingSystem unblockInterrupts.
 !
 
@@ -1146,7 +1147,6 @@
         timeoutActions at:index put:nil. 
         timeouts at:index put:nil.
         timeoutSemaphores at:index put:nil.
-        nTimeouts := nTimeouts - 1.
     ].
     OperatingSystem unblockInterrupts.
 ! !