ProcessorScheduler.st
changeset 1086 7b0641a2e1ef
parent 1061 61012b7bed9c
child 1092 2a8acc60f5b5
--- a/ProcessorScheduler.st	Thu Mar 07 19:00:58 1996 +0100
+++ b/ProcessorScheduler.st	Thu Mar 07 19:32:41 1996 +0100
@@ -131,9 +131,9 @@
     HighestPriority := 30.
 
     Processor isNil ifTrue:[
-	"create the one and only processor"
+        "create the one and only processor"
 
-	Processor := self basicNew initialize.
+        Processor := self basicNew initialize.
     ].
 
     "
@@ -141,8 +141,10 @@
     "
     PureEventDriven := self threadsAvailable not.
     PureEventDriven ifTrue:[
-	'no process support - running event driven' errorPrintNL
+        'PROCESSOR: no process support - running event driven' errorPrintNL
     ].
+
+    "Modified: 7.3.1996 / 19:22:49 / cg"
 ! !
 
 !ProcessorScheduler class methodsFor:'instance creation'!
@@ -805,9 +807,9 @@
     extern OBJ ___threadSwitch();
 
     if (__isSmallInteger(id)) {
-	ok = ___threadSwitch(__context, _intVal(id), (singleStep == true) ? 1 : 0);
+        ok = ___threadSwitch(__context, _intVal(id), (singleStep == true) ? 1 : 0);
     } else {
-	ok = false;
+        ok = false;
     }
 %}.
     "time passes spent in some other process ...
@@ -818,24 +820,24 @@
     currentPriority := oldProcess priority.
 
     ok ifFalse:[
-	"
-	 switch failed for some reason -
-	 destroy the bad process
-	"
-	p id ~~ 0 ifTrue:[
-	    'SCHEDULER: problem with process ' errorPrint. 
-		p id errorPrint. 
-		p name notNil ifTrue:[
-		    ' (' errorPrint. p name errorPrint. ')' errorPrint.
-		].
-		'; hard-terminate it.' errorPrintNL.
-	    p state:#suspended.
-	    self terminateNoSignal:p.
-	]
+        "
+         switch failed for some reason -
+         destroy the bad process
+        "
+        p id ~~ 0 ifTrue:[
+            'PROCESSOR: problem with process ' errorPrint. 
+                p id errorPrint. 
+                p name notNil ifTrue:[
+                    ' (' errorPrint. p name errorPrint. ')' errorPrint.
+                ].
+                '; hard-terminate it.' errorPrintNL.
+            p state:#suspended.
+            self terminateNoSignal:p.
+        ]
     ].
     zombie notNil ifTrue:[
-	self class threadDestroy:zombie.
-	zombie := nil
+        self class threadDestroy:zombie.
+        zombie := nil
     ].
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 ! !
@@ -1084,22 +1086,24 @@
     prio := HighestPriority.
     listArray := quiescentProcessLists.
     [prio >= 1] whileTrue:[
-	l := listArray at:prio.
-	l notEmpty ifTrue:[
-	    p := l first.
-	    "
-	     if it got corrupted somehow ...
-	    "
-	    p id isNil ifTrue:[
-		'process with nil id removed' errorPrintNL.
-		l removeFirst.
-		^ nil.
-	    ].
-	    ^ p
-	].
-	prio := prio - 1
+        l := listArray at:prio.
+        l notEmpty ifTrue:[
+            p := l first.
+            "
+             if it got corrupted somehow ...
+            "
+            p id isNil ifTrue:[
+                'PROCESSOR: process with nil id removed' errorPrintNL.
+                l removeFirst.
+                ^ nil.
+            ].
+            ^ p
+        ].
+        prio := prio - 1
     ].
     ^ nil
+
+    "Modified: 7.3.1996 / 19:22:05 / cg"
 !
 
 isSystemProcess:aProcess
@@ -1391,8 +1395,8 @@
      debugging consistency check - will be removed later
     "
     activeProcess priority ~~ currentPriority ifTrue:[
-	'oops process changed priority' errorPrintNL.
-	currentPriority := activeProcess priority.
+        'PROCESSOR: oops - process changed priority' errorPrintNL.
+        currentPriority := activeProcess priority.
     ].
 
     l := quiescentProcessLists at:currentPriority.
@@ -1401,27 +1405,29 @@
      debugging consistency checks - will be removed later
     "
     l isEmpty ifTrue:[
-	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-	'oops - empty runnable list' errorPrintNL.
-	^ self
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+        'PROCESSOR: oops - empty runnable list' errorPrintNL.
+        ^ self
     ].
 
     "
      check if the running process is not the only one
     "
     l size ~~ 1 ifTrue:[
-	"
-	 bring running process to the end
-	"
-	l removeFirst.
-	l addLast:activeProcess.
+        "
+         bring running process to the end
+        "
+        l removeFirst.
+        l addLast:activeProcess.
 
-	"
-	 and switch to first in the list
-	"
-	self threadSwitch:(l first).
+        "
+         and switch to first in the list
+        "
+        self threadSwitch:(l first).
     ].
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+
+    "Modified: 7.3.1996 / 19:22:43 / cg"
 ! !
 
 !ProcessorScheduler methodsFor:'semaphore signalling'!
@@ -1752,46 +1758,6 @@
 
 !ProcessorScheduler methodsFor:'waiting'!
 
-removeCorruptedFds
-    "this is sent when select returns an error due to some invalid 
-     fileDescriptor. May happens, if someone does a readWait/writeWait on a 
-     connection, which somehow gets corrupted.
-     Without special care, all following selects would immediately return with 
-     an #EBADF error, leading to high-frequency polling and a locked up system.
-     (you could still fix things by interrupting on the console and fixing the
-      readFdArray/writeFdArray in the debugger)"
-
-    readFdArray keysAndValuesDo:[:idx :fd |
-        |rslt|
-
-        rslt := OperatingSystem
-                    selectOnAnyReadable:(Array with:fd)
-                               writable:nil
-                              exception:nil
-                            withTimeOut:0.
-
-        (rslt isNil and:[OperatingSystem lastErrorSymbol == #EBADF]) ifTrue:[
-            ('PROCESSOR: remove invalid read fileDescriptor: ' , fd printString) errorPrintNL.
-            readFdArray at:idx put:nil
-        ]
-    ].
-
-    writeFdArray keysAndValuesDo:[:idx :fd |
-        |rslt|
-
-        rslt := OperatingSystem
-                    selectOnAnyReadable:nil
-                               writable:(Array with:fd)
-                              exception:nil
-                            withTimeOut:0.
-
-        (rslt isNil and:[OperatingSystem lastErrorSymbol == #EBADF]) ifTrue:[
-            ('PROCESSOR: removing invalid write fileDescriptor: ' , fd printString) errorPrintNL.
-            writeFdArray at:idx put:nil
-        ]
-    ].
-!
-
 checkForInputWithTimeout:millis
     "this is called, when there is absolutely nothing to do;
      hard wait for either input to arrive or a timeout to occur."
@@ -1842,6 +1808,46 @@
     "Modified: 21.12.1995 / 16:17:40 / stefan"
 !
 
+removeCorruptedFds
+    "this is sent when select returns an error due to some invalid 
+     fileDescriptor. May happens, if someone does a readWait/writeWait on a 
+     connection, which somehow gets corrupted.
+     Without special care, all following selects would immediately return with 
+     an #EBADF error, leading to high-frequency polling and a locked up system.
+     (you could still fix things by interrupting on the console and fixing the
+      readFdArray/writeFdArray in the debugger)"
+
+    readFdArray keysAndValuesDo:[:idx :fd |
+        |rslt|
+
+        rslt := OperatingSystem
+                    selectOnAnyReadable:(Array with:fd)
+                               writable:nil
+                              exception:nil
+                            withTimeOut:0.
+
+        (rslt isNil and:[OperatingSystem lastErrorSymbol == #EBADF]) ifTrue:[
+            ('PROCESSOR: remove invalid read fileDescriptor: ' , fd printString) errorPrintNL.
+            readFdArray at:idx put:nil
+        ]
+    ].
+
+    writeFdArray keysAndValuesDo:[:idx :fd |
+        |rslt|
+
+        rslt := OperatingSystem
+                    selectOnAnyReadable:nil
+                               writable:(Array with:fd)
+                              exception:nil
+                            withTimeOut:0.
+
+        (rslt isNil and:[OperatingSystem lastErrorSymbol == #EBADF]) ifTrue:[
+            ('PROCESSOR: removing invalid write fileDescriptor: ' , fd printString) errorPrintNL.
+            writeFdArray at:idx put:nil
+        ]
+    ].
+!
+
 schedulerInterrupt
     "forced reschedule - switch to scheduler process which will decide
      what to do now."
@@ -1976,6 +1982,6 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.71 1996-03-02 12:47:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.72 1996-03-07 18:31:41 cg Exp $'
 ! !
 ProcessorScheduler initialize!