ProcessorScheduler.st
changeset 4002 341a896cb334
parent 3969 0f30268b10c3
child 4008 27a9c75eecdc
--- a/ProcessorScheduler.st	Thu Feb 25 20:17:28 1999 +0100
+++ b/ProcessorScheduler.st	Thu Feb 25 21:16:06 1999 +0100
@@ -1717,24 +1717,27 @@
     "set aProcess runnable - 
      if its prio is higher than the currently running prio, switch to it."
 
-    |l pri wasBlocked|
+    |l pri wasBlocked s|
 
     "ignore, if process is already dead"
     (aProcess isNil or:[aProcess id isNil]) ifTrue:[^ self].
 
-    aProcess state == #osWait ifTrue:[
-	'Processor [warning]: bad resume: state osWait' errorPrintCR.
-	"/ MiniDebugger enterWithMessage:'bad resume: state osWait'.
-	^ self.
+    (s := aProcess state) == #osWait ifTrue:[
+        'Processor [warning]: bad resume: #osWait' errorPrintCR.
+        "/ MiniDebugger enterWithMessage:'bad resume: state osWait'.
+        ^ self.
     ].
-
+    s == #stopped ifTrue:[
+        'Processor [warning]: bad resume: #stopped' errorPrintCR.
+        ^ self.
+    ].
 
     aProcess == activeProcess ifTrue:[
-	"special handling for waiting schedulers"
-	aProcess == scheduler ifTrue:[
-	    suspendScheduler := false.
-	].
-	^ self
+        "special handling for waiting schedulers"
+        aProcess == scheduler ifTrue:[
+            suspendScheduler := false.
+        ].
+        ^ self
     ].
 
     wasBlocked := OperatingSystem blockInterrupts.
@@ -1744,27 +1747,27 @@
     l := quiescentProcessLists at:pri.
     "if already running, ignore"
     l notNil ifTrue:[
-	(l identityIndexOf:aProcess) ~~ 0 ifTrue:[
-	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	    ^ self
-	]
+        (l identityIndexOf:aProcess) ~~ 0 ifTrue:[
+            wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+            ^ self
+        ]
     ] ifFalse:[
-	l := LinkedList new.
-	quiescentProcessLists at:pri put:l.
+        l := LinkedList new.
+        quiescentProcessLists at:pri put:l.
     ].
     l addLast:aProcess.
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 
     (pri > currentPriority) ifTrue:[
-	"
-	 its prio is higher; immediately transfer control to it
-	"
-	self threadSwitch:aProcess
+        "
+         its prio is higher; immediately transfer control to it
+        "
+        self threadSwitch:aProcess
     ] ifFalse:[
-	"
-	 its prio is lower; it will have to wait for a while ...
-	"
-	aProcess state:#run 
+        "
+         its prio is lower; it will have to wait for a while ...
+        "
+        aProcess state:#run 
     ]
 
     "Modified: / 24.8.1998 / 18:28:42 / cg"
@@ -1804,7 +1807,7 @@
         ^ self
     ].
     aProcess == scheduler ifTrue:[
-        "only scheduler may suspend itself"
+        "only the scheduler may suspend itself"
         activeProcess == scheduler ifTrue:[
             suspendScheduler := true.
             [suspendScheduler] whileTrue:[
@@ -1828,8 +1831,11 @@
     (l isNil or:[(l remove:aProcess ifAbsent:nil) isNil]) ifTrue:[
         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
         'Processor [warning]: bad suspend: not on run list' errorPrintCR.
+aProcess printCR.
         "/ MiniDebugger enterWithMessage:'bad suspend: not on run list'.
-        self threadSwitch:scheduler.
+        aProcess == activeProcess ifTrue:[
+            self threadSwitch:scheduler.
+        ].
         ^ self
     ].
 
@@ -2993,6 +2999,6 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.171 1999-02-08 12:33:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.172 1999-02-25 20:16:06 cg Exp $'
 ! !
 ProcessorScheduler initialize!