ProcessorScheduler.st
changeset 7493 5c67c45b11cb
parent 7264 cf619b9f31b6
child 7495 e5d970001d01
--- a/ProcessorScheduler.st	Fri Jul 11 19:36:54 2003 +0200
+++ b/ProcessorScheduler.st	Fri Jul 11 19:52:44 2003 +0200
@@ -2913,78 +2913,85 @@
     "this is called, when there is absolutely nothing to do;
      hard wait for either input to arrive or a timeout to occur."
 
-    |fd index sema action wasBlocked err|
+    |nSelected index sema action wasBlocked err resultFdArray newProcessMaybeReady|
 
     "/ must enable interrupts, to be able to get out of a
     "/ long wait (especially, to handle sigChild in the meantime)
 
     (wasBlocked := OperatingSystem interruptsBlocked) ifTrue:[
-	OperatingSystem unblockInterrupts.
+        OperatingSystem unblockInterrupts.
     ].
 
-    fd := OperatingSystem 
-	      selectOnAnyReadable:readFdArray 
-			 writable:writeFdArray
-			exception:nil 
-		      withTimeOut:millis.
+    newProcessMaybeReady := false.
+    resultFdArray := Array new:40.
+    nSelected := OperatingSystem 
+              selectOnAnyReadable:readFdArray 
+                         writable:writeFdArray
+                        exception:nil
+                             into:resultFdArray
+                      withTimeOut:millis.
 
     wasBlocked ifTrue:[
-	OperatingSystem blockInterrupts.
+        OperatingSystem blockInterrupts.
     ].
 
-    fd isNil ifTrue:[
-	"/ either still nothing to do,
-	"/ or error (which should not happen)
-
-	(err := OperatingSystem lastErrorSymbol) notNil ifTrue:[
-	    err == #EBADF ifTrue:[
-
-		"/ mhmh - one of the fd's given to me is corrupt.
-		"/ find out which one .... and remove it
-
-		'Processor [info]: obsolete FD in select - clearing' infoPrintCR.
-		OperatingSystem clearLastErrorNumber.
-		self removeCorruptedFds
-	    ] ifFalse:[
-		err == #ENOENT ifTrue:[
-		    'Processor [warning]: ENOENT in select; rd=' infoPrint.
-		    readFdArray infoPrint.
-		    ' wr=' infoPrint.
-		    writeFdArray infoPrintCR.
-		] ifFalse:[
-		    'Processor [warning]: error in select: ' infoPrint. err infoPrintCR.
-		]
-	    ].
-	]
+    nSelected == 0 ifTrue:[
+        "/ either still nothing to do,
+        "/ or error (which should not happen)
+
+        (err := OperatingSystem lastErrorSymbol) notNil ifTrue:[
+            err == #EBADF ifTrue:[
+
+                "/ mhmh - one of the fd's given to me is corrupt.
+                "/ find out which one .... and remove it
+
+                'Processor [info]: obsolete FD in select - clearing' infoPrintCR.
+                OperatingSystem clearLastErrorNumber.
+                self removeCorruptedFds
+            ] ifFalse:[
+                err == #ENOENT ifTrue:[
+                    'Processor [warning]: ENOENT in select; rd=' infoPrint.
+                    readFdArray infoPrint.
+                    ' wr=' infoPrint.
+                    writeFdArray infoPrintCR.
+                ] ifFalse:[
+                    'Processor [warning]: error in select: ' infoPrint. err infoPrintCR.
+                ]
+            ].
+        ]
     ] ifFalse:[
-	index := readFdArray identityIndexOf:fd.
-	index ~~ 0 ifTrue:[
-	    sema := readSemaphoreArray at:index.
-	    sema notNil ifTrue:[
-		sema signalOnce.
-		^ true
-	    ].
-	    action := readCheckArray at:index.
-	    action notNil ifTrue:[
-		action value.
-		 ^ true
-	    ]
-	].
-	index := writeFdArray identityIndexOf:fd.
-	index ~~ 0 ifTrue:[
-	    sema := writeSemaphoreArray at:index.
-	    sema notNil ifTrue:[
-		sema signalOnce.
-		 ^ true
-	    ].
-	    action := writeCheckArray at:index.
-	    action notNil ifTrue:[
-		action value.
-		 ^ true
-	    ]
-	]
+        1 to:nSelected do:[:fdIndex| |fd|
+            fd := resultFdArray at:fdIndex.
+
+            index := readFdArray identityIndexOf:fd.
+            index ~~ 0 ifTrue:[
+                sema := readSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                    newProcessMaybeReady := true
+                ].
+                action := readCheckArray at:index.
+                action notNil ifTrue:[
+                    action value.
+                    newProcessMaybeReady := true
+                ]
+            ].
+            index := writeFdArray identityIndexOf:fd.
+            index ~~ 0 ifTrue:[
+                sema := writeSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                    newProcessMaybeReady := true
+                ].
+                action := writeCheckArray at:index.
+                action notNil ifTrue:[
+                    action value.
+                    newProcessMaybeReady := true
+                ]
+            ].
+        ].
     ].
-    ^ false
+    ^ newProcessMaybeReady
 
     "Modified: / 12.4.1996 / 09:31:22 / stefan"
     "Modified: / 14.6.1998 / 17:31:51 / cg"
@@ -3229,7 +3236,7 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.209 2003-05-07 14:44:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.210 2003-07-11 17:52:44 stefan Exp $'
 ! !
 
 ProcessorScheduler initialize!