--- a/ProcessorScheduler.st Thu Dec 21 13:50:16 1995 +0100
+++ b/ProcessorScheduler.st Thu Dec 21 17:56:47 1995 +0100
@@ -10,12 +10,14 @@
hereby transferred.
"
+'From Smalltalk/X, Version:2.10.8 on 21-dec-1995 at 16:28:28' !
+
Object subclass:#ProcessorScheduler
instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess
currentPriority readFdArray readSemaphoreArray readCheckArray
writeFdArray writeSemaphoreArray timeoutArray timeoutActionArray
timeoutProcessArray timeoutSemaphoreArray idleActions anyTimeouts
- dispatching interruptedProcess useIOInterrupts'
+ dispatching interruptedProcess useIOInterrupts gotIOInterrupt'
classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven
UserSchedulingPriority UserInterruptPriority TimingPriority
HighestPriority SchedulingPriority MaxNumberOfProcesses'
@@ -500,7 +502,7 @@
handle all timeout actions
"
anyTimeouts ifTrue:[
- self evaluateTimeouts
+ self evaluateTimeouts
].
"first do a quick check for semaphores using checkActions - this is needed for
@@ -510,26 +512,26 @@
any := false.
nActions := readCheckArray size.
1 to:nActions do:[:index |
- |checkBlock sema|
+ |checkBlock sema|
- checkBlock := readCheckArray at:index.
- (checkBlock notNil and:[checkBlock value]) ifTrue:[
- sema := readSemaphoreArray at:index.
- sema notNil ifTrue:[
- sema signalOnce.
- ].
- any := true.
- ]
+ checkBlock := readCheckArray at:index.
+ (checkBlock notNil and:[checkBlock value]) ifTrue:[
+ sema := readSemaphoreArray at:index.
+ sema notNil ifTrue:[
+ sema signalOnce.
+ ].
+ any := true.
+ ]
].
"now, someone might be runnable ..."
p := self highestPriorityRunnableProcess.
p isNil ifTrue:[
- "no one runnable, hard wait for event or timeout"
+ "no one runnable, hard wait for event or timeout"
- self waitForEventOrTimeout.
- ^ self
+ self waitForEventOrTimeout.
+ ^ self
].
pri := p priority.
@@ -560,10 +562,10 @@
"
pri < TimingPriority ifTrue:[
- anyTimeouts ifTrue:[
- millis := self timeToNextTimeout.
- millis == 0 ifTrue:[^ self].
- ]
+ anyTimeouts ifTrue:[
+ millis := self timeToNextTimeout.
+ millis == 0 ifTrue:[^ self].
+ ]
].
"
@@ -576,30 +578,30 @@
pri < UserInterruptPriority ifTrue:[
"comment out this if above is uncommented"
- anyTimeouts ifTrue:[
- millis := self timeToNextTimeout.
- millis == 0 ifTrue:[^ self].
- ].
+ anyTimeouts ifTrue:[
+ millis := self timeToNextTimeout.
+ millis == 0 ifTrue:[^ self].
+ ].
"---"
- useIOInterrupts ifTrue:[
- readFdArray do:[:fd |
- fd notNil ifTrue:[
- OperatingSystem enableIOInterruptsOn:fd
- ].
- ].
- ] ifFalse:[
- millis notNil ifTrue:[
- millis := millis min:50
- ] ifFalse:[
- millis := 50
- ]
- ]
+ useIOInterrupts ifTrue:[
+ readFdArray do:[:fd |
+ fd notNil ifTrue:[
+ OperatingSystem enableIOInterruptsOn:fd
+ ].
+ ].
+ ] ifFalse:[
+ millis notNil ifTrue:[
+ millis := millis min:50
+ ] ifFalse:[
+ millis := 50
+ ]
+ ]
].
millis notNil ifTrue:[
- "schedule a clock interrupt after millis milliseconds"
- OperatingSystem enableTimer:millis rounded.
+ "schedule a clock interrupt after millis milliseconds"
+ OperatingSystem enableTimer:millis rounded.
].
"
@@ -608,16 +610,22 @@
"
self threadSwitch:p.
- "... when we arrive here, we are back on stage"
+ "... when we arrive here, we are back on stage.
+ Either by an ALARM or IO signal, or by a suspend of another process
+ "
millis notNil ifTrue:[
- OperatingSystem disableTimer.
- useIOInterrupts ifFalse:[
- self checkForInputWithTimeout:0.
- ]
+ OperatingSystem disableTimer.
+ ].
+
+ "/ check for new input
+
+ (gotIOInterrupt or:[useIOInterrupts not]) ifTrue:[
+ gotIOInterrupt := false.
+ self checkForInputWithTimeout:0.
]
- "Modified: 14.12.1995 / 14:45:13 / stefan"
+ "Modified: 21.12.1995 / 16:21:54 / stefan"
!
dispatchLoop
@@ -796,9 +804,9 @@
l p|
KnownProcesses isNil ifTrue:[
- KnownProcesses := WeakArray new:10.
- KnownProcesses watcher:self class.
- KnownProcessIds := OrderedCollection new.
+ KnownProcesses := WeakArray new:10.
+ KnownProcesses watcher:self class.
+ KnownProcessIds := OrderedCollection new.
].
"
@@ -807,7 +815,7 @@
nPrios := SchedulingPriority.
quiescentProcessLists := Array new:nPrios.
1 to:nPrios do:[:pri |
- quiescentProcessLists at:pri put:(LinkedList new)
+ quiescentProcessLists at:pri put:(LinkedList new)
].
readFdArray := Array with:nil.
@@ -822,6 +830,7 @@
anyTimeouts := false.
dispatching := false.
useIOInterrupts := OperatingSystem supportsIOInterrupts.
+ gotIOInterrupt := false.
"
handcraft the first (dispatcher-) process - this one will never
@@ -844,6 +853,8 @@
"
ObjectMemory ioInterruptHandler:self.
ObjectMemory timerInterruptHandler:self.
+
+ "Modified: 21.12.1995 / 16:18:36 / stefan"
!
reinitialize
@@ -1641,8 +1652,11 @@
"data arrived while waiting - switch to scheduler process which will decide
what to do now."
+ gotIOInterrupt := true.
interruptedProcess := activeProcess.
self threadSwitch:scheduler
+
+ "Modified: 21.12.1995 / 16:17:40 / stefan"
!
schedulerInterrupt
@@ -1761,6 +1775,6 @@
!ProcessorScheduler class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.59 1995-12-18 14:18:32 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.60 1995-12-21 16:56:47 stefan Exp $'
! !
ProcessorScheduler initialize!