--- a/ProcessorScheduler.st Sat Aug 05 16:05:36 1995 +0200
+++ b/ProcessorScheduler.st Tue Aug 08 02:49:43 1995 +0200
@@ -35,7 +35,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.44 1995-08-05 14:05:36 claus Exp $
+$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.45 1995-08-08 00:48:18 claus Exp $
'!
Smalltalk at:#Processor put:nil!
@@ -58,7 +58,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.44 1995-08-05 14:05:36 claus Exp $
+$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.45 1995-08-08 00:48:18 claus Exp $
"
!
@@ -495,7 +495,8 @@
initialize
"initialize the one-and-only ProcessorScheduler"
- |nPrios l p|
+ |nPrios "{ Class: SmallInteger }"
+ l p|
KnownProcesses isNil ifTrue:[
KnownProcesses := WeakArray new:10.
@@ -508,6 +509,9 @@
"
nPrios := SchedulingPriority.
quiescentProcessLists := Array new:nPrios.
+ 1 to:nPrios do:[:pri |
+ quiescentProcessLists at:pri put:(LinkedList new)
+ ].
readFdArray := Array with:nil.
readCheckArray := Array with:nil.
@@ -534,11 +538,9 @@
p setPriority:currentPriority.
p name:'scheduler'.
- l := LinkedList new.
- l add:p.
scheduler := activeProcess := p.
- quiescentProcessLists at:currentPriority put:l.
+ (quiescentProcessLists at:currentPriority) add:p.
"
let me handle IO and timer interrupts
@@ -715,11 +717,6 @@
"
debugging consistency checks - will be removed later
"
- l isNil ifTrue:[
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
- 'oops - nil runnable list' errorPrintNL.
- ^ self
- ].
l isEmpty ifTrue:[
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
'oops - empty runnable list' errorPrintNL.
@@ -773,18 +770,6 @@
pri := aProcess priority.
l := quiescentProcessLists at:pri.
- "
- debugging consisteny checks - will be removed later
- "
- l isNil ifTrue:[
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-
- 'bad suspend: empty run list' errorPrintNL.
- "/ MiniDebugger enterWithMessage:'bad suspend: empty run list'.
- self threadSwitch:scheduler.
- ^ self
- ].
-
"notice: this is slightly faster than putting the if-code into
the ifAbsent block, because [] is a shared cheap block
"
@@ -796,10 +781,6 @@
^ self
].
- l isEmpty ifTrue:[
- quiescentProcessLists at:pri put:nil.
- l := nil
- ].
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
"
@@ -812,7 +793,7 @@
(aProcess == activeProcess) ifTrue:[
"we can immediately switch sometimes"
- l notNil ifTrue:[
+ l notEmpty ifTrue:[
p := l first
] ifFalse:[
p := scheduler
@@ -837,15 +818,10 @@
pri := aProcess priority.
l := quiescentProcessLists at:pri.
- l isNil ifTrue:[
- l := LinkedList new.
- quiescentProcessLists at:pri put:l
- ] ifFalse:[
- "if already running, ignore"
- (l identityIndexOf:aProcess) ~~ 0 ifTrue:[
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
- ^ self
- ]
+ "if already running, ignore"
+ (l identityIndexOf:aProcess) ~~ 0 ifTrue:[
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ^ self
].
l addLast:aProcess.
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -896,9 +872,8 @@
pri := aProcess priority.
l := quiescentProcessLists at:pri.
- (l notNil and:[(l identityIndexOf:aProcess) ~~ 0]) ifTrue:[
+ (l identityIndexOf:aProcess) ~~ 0 ifTrue:[
l remove:aProcess.
- l isEmpty ifTrue:[quiescentProcessLists at:pri put:nil].
].
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -986,19 +961,14 @@
aProcess setPriority:newPrio.
oldList := quiescentProcessLists at:oldPrio.
- (oldList isNil or:[(oldList identityIndexOf:aProcess) ==0]) ifTrue:[
+ (oldList identityIndexOf:aProcess) == 0 ifTrue:[
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
^ self
].
oldList remove:aProcess.
- oldList isEmpty ifTrue:[quiescentProcessLists at:oldPrio put:nil].
newList := quiescentProcessLists at:newPrio.
- newList isNil ifTrue:[
- newList := LinkedList new.
- quiescentProcessLists at:newPrio put:newList
- ].
newList addLast:aProcess.
"if its the current process lowering its prio
@@ -1059,24 +1029,17 @@
listArray := quiescentProcessLists.
[prio >= 1] whileTrue:[
l := listArray at:prio.
- l notNil ifTrue:[
- l isEmpty ifTrue:[
- "
- on the fly clear out empty lists
- "
- listArray at:prio put:nil
- ] ifFalse:[
- p := l first.
- "
- if it got corrupted somehow ...
- "
- p id isNil ifTrue:[
- 'process with nil id removed' errorPrintNL.
- l removeFirst.
- ^ nil.
- ].
- ^ p
+ 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
].