ProcessorScheduler.st
branchjv
changeset 17814 b75a7f0c346b
parent 17807 06cc6c49e291
child 17834 04ff72c5039a
--- a/ProcessorScheduler.st	Tue Nov 30 15:53:23 2010 +0000
+++ b/ProcessorScheduler.st	Mon Dec 20 07:13:27 2010 +0000
@@ -1033,19 +1033,19 @@
     |pri l newState|
 
     OperatingSystem interruptsBlocked ifFalse:[
-	MiniDebugger
-	    enterWithMessage:'immediateInterrupt with no interruptsBlocked'
-	    mayProceed:true.
+        MiniDebugger
+            enterWithMessage:'immediateInterrupt with no interruptsBlocked'
+            mayProceed:true.
     ].
 
     (whyCode == 2) ifTrue:[
-	 newState := #wrapWait.
+         newState := #wrapWait.
     ] ifFalse:[
-	(whyCode == 3) ifTrue:[
-	    newState := #osWait.
-	] ifFalse:[
-	    newState := #stopped.
-	].
+        (whyCode == 3) ifTrue:[
+            newState := #osWait.
+        ] ifFalse:[
+            newState := #stopped.
+        ].
     ].
     activeProcess setStateTo:newState if:#active.
 
@@ -1055,10 +1055,10 @@
     "notice: this is slightly faster than putting the if-code into
      the ifAbsent block, because [] is a shared cheap block, created at compile time
     "
-    (l isNil or:[(l remove:activeProcess ifAbsent:nil) isNil]) ifTrue:[
-	"/ 'Processor [warning]: bad vmSuspendInterrupt: not on run list' errorPrintCR.
-	MiniDebugger enterWithMessage:'bad vmSuspendInterrupt: not on run list' mayProceed:true.
-	^ self
+    (l isNil or:[(l removeIdentical:activeProcess ifAbsent:nil) isNil]) ifTrue:[
+        "/ 'Processor [warning]: bad vmSuspendInterrupt: not on run list' errorPrintCR.
+        MiniDebugger enterWithMessage:'bad vmSuspendInterrupt: not on run list' mayProceed:true.
+        ^ self
     ].
 ! !
 
@@ -1673,7 +1673,7 @@
 
         oldList := quiescentProcessLists at:oldPrio.
         oldList notNil ifTrue:[
-            (oldList remove:aProcess ifAbsent:nil) notNil ifTrue:[
+            (oldList removeIdentical:aProcess ifAbsent:nil) notNil ifTrue:[
                 newList := quiescentProcessLists at:newPrio.
                 newList isNil ifTrue:[
                     quiescentProcessLists at:newPrio put:(newList := LinkedList new).
@@ -1772,9 +1772,9 @@
         quiescentProcessLists at:pri put:l.
     ].
     l addLast:aProcess.
+    aProcess state:#run.
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 
-    aProcess state:#run.
 
     timeSliceNeededSemaphore notNil ifTrue:[
         "/ tell timeslicer, that some work might be needed...
@@ -1847,7 +1847,6 @@
         quiescentProcessLists at:pri put:l.
     ].
     l addLast:aProcess.
-    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 
     (pri > currentPriority) ifTrue:[
         "
@@ -1863,7 +1862,8 @@
             "/ tell timeslicer, that some work might be needed...
             timeSliceNeededSemaphore signalIf.
         ]
-    ]
+    ].
+    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 
     "Modified: / 24-08-1998 / 18:28:42 / cg"
     "Modified: / 03-08-2004 / 19:01:47 / stefan"
@@ -1885,8 +1885,8 @@
      If the process is the current one, reschedule.
 
      Notice:
-	 This method should only be called by Process>>suspend or
-	 Process>>suspendWithState:"
+         This method should only be called by Process>>suspend or
+         Process>>suspendWithState:"
 
     |pri l p wasBlocked|
 
@@ -1894,30 +1894,30 @@
      some debugging stuff
     "
     aProcess isNil ifTrue:[
-	InvalidProcessSignal raiseRequestWith:aProcess errorString:'nil suspend'.
-	^ self
+        InvalidProcessSignal raiseRequestWith:aProcess errorString:'nil suspend'.
+        ^ self
     ].
     aProcess id isNil ifTrue:[
-	InvalidProcessSignal raiseRequestWith:aProcess errorString:'bad suspend: already dead'.
-	self threadSwitch:scheduler.
-	^ self
+        InvalidProcessSignal raiseRequestWith:aProcess errorString:'bad suspend: already dead'.
+        self threadSwitch:scheduler.
+        ^ self
     ].
     aProcess == scheduler ifTrue:[
-	"only the scheduler may suspend itself"
-	activeProcess == scheduler ifTrue:[
-	    suspendScheduler := true.
-	    [suspendScheduler] whileTrue:[
-		self dispatch.
-	    ].
-	    ^ self
-	].
-
-	InvalidProcessSignal raiseRequestWith:aProcess errorString:'attempt to suspend scheduler'.
-	^ self
+        "only the scheduler may suspend itself"
+        activeProcess == scheduler ifTrue:[
+            suspendScheduler := true.
+            [suspendScheduler] whileTrue:[
+                self dispatch.
+            ].
+            ^ self
+        ].
+
+        InvalidProcessSignal raiseRequestWith:aProcess errorString:'attempt to suspend scheduler'.
+        ^ self
     ].
 
     aProcess hasInterruptActions ifTrue:[
-	aProcess interrupt.
+        aProcess interrupt.
     ].
 
     wasBlocked := OperatingSystem blockInterrupts.
@@ -1928,24 +1928,24 @@
     "notice: this is slightly faster than putting the if-code into
      the ifAbsent block, because [] is a shared cheap block, created at compile time
     "
-    (l isNil or:[(l remove:aProcess ifAbsent:nil) isNil]) ifTrue:[
-	"/ 'Processor [warning]: bad suspend: process is not running' errorPrintCR.
-	"/ MiniDebugger enterWithMessage:'bad suspend: process is not running'.
-	aProcess == activeProcess ifTrue:[
-	    self threadSwitch:scheduler.
-	].
-	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	^ self
+    (l isNil or:[(l removeIdentical:aProcess ifAbsent:nil) isNil]) ifTrue:[
+        "/ 'Processor [warning]: bad suspend: process is not running' errorPrintCR.
+        "/ MiniDebugger enterWithMessage:'bad suspend: process is not running'.
+        aProcess == activeProcess ifTrue:[
+            self threadSwitch:scheduler.
+        ].
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        ^ self
     ].
 
     (aProcess == activeProcess) ifTrue:[
-	"we can immediately switch sometimes"
-	l isEmpty ifFalse:[
-	    p := l first
-	] ifTrue:[
-	    p := scheduler
-	].
-	self threadSwitch:p
+        "we can immediately switch sometimes"
+        l isEmpty ifTrue:[
+            p := scheduler
+        ] ifFalse:[
+            p := l first
+        ].
+        self threadSwitch:p
     ].
 
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -1992,16 +1992,16 @@
 
     aProcess isNil ifTrue:[^ self].
     aProcess == scheduler ifTrue:[
-	InvalidProcessSignal raiseWith:aProcess errorString:'attempt to terminate scheduler'.
-	^ self
+        InvalidProcessSignal raiseWith:aProcess errorString:'attempt to terminate scheduler'.
+        ^ self
     ].
 
     wasBlocked := OperatingSystem blockInterrupts.
 
     id := aProcess id.
     id isNil ifTrue:[   "already dead"
-	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	^ self
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        ^ self
     ].
 
     aProcess setId:nil state:#dead.
@@ -2011,31 +2011,31 @@
     pri := aProcess priority.
     l := quiescentProcessLists at:pri.
     l notNil ifTrue:[
-	(l remove:aProcess ifAbsent:nil) notNil ifTrue:[
-	    l isEmpty ifTrue:[
-		quiescentProcessLists at:pri put:nil
-	    ]
-	].
+        (l removeIdentical:aProcess ifAbsent:nil) "notNil ifTrue:[
+            l isEmpty ifTrue:[
+                quiescentProcessLists at:pri put:nil
+            ]
+        ]."
     ].
 
     aProcess == activeProcess ifTrue:[
-	"
-	 hard case - its the currently running process
-	 we must have the next active process destroy this one
-	 (we cannot destroy the chair we are sitting on ... :-)
-	"
-	zombie notNil ifTrue:[
-	    self error:'active process is zombie' mayProceed:true.
-	    self class threadDestroy:zombie.
-	].
-
-	self unRemember:aProcess.
-	zombie := id.
-
-	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	self threadSwitch:scheduler.
-	"not reached"
-	^ self
+        "
+         hard case - its the currently running process
+         we must have the next active process destroy this one
+         (we cannot destroy the chair we are sitting on ... :-)
+        "
+        zombie notNil ifTrue:[
+            self error:'active process is zombie' mayProceed:true.
+            self class threadDestroy:zombie.
+        ].
+
+        self unRemember:aProcess.
+        zombie := id.
+
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        self threadSwitch:scheduler.
+        "not reached"
+        ^ self
     ].
 
     self unRemember:aProcess.
@@ -3378,15 +3378,15 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Id: ProcessorScheduler.st 10590 2010-11-09 16:24:28Z vranyj1 $'
+    ^ '$Id: ProcessorScheduler.st 10602 2010-12-20 07:13:27Z vranyj1 $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.255 2010-08-02 11:36:55 cg Exp '
+    ^ 'Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.257 2010/12/08 15:09:24 stefan Exp '
 !
 
 version_SVN
-    ^ '$Id: ProcessorScheduler.st 10590 2010-11-09 16:24:28Z vranyj1 $'
+    ^ '$Id: ProcessorScheduler.st 10602 2010-12-20 07:13:27Z vranyj1 $'
 ! !
 
 ProcessorScheduler initialize!
@@ -3395,3 +3395,4 @@
 
 
 
+