10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 Object subclass:#ProcessorScheduler |
13 Object subclass:#ProcessorScheduler |
14 instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
14 instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
15 currentPriority readFdArray readSemaphoreArray readCheckArray |
15 currentPriority readFdArray readSemaphoreArray readCheckArray |
16 writeFdArray writeSemaphoreArray timeoutArray timeoutActionArray |
16 writeFdArray writeSemaphoreArray timeoutArray timeoutActionArray |
17 timeoutProcessArray timeoutSemaphoreArray idleActions anyTimeouts |
17 timeoutProcessArray timeoutSemaphoreArray idleActions anyTimeouts |
18 dispatching interruptedProcess useIOInterrupts' |
18 dispatching interruptedProcess useIOInterrupts' |
19 classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
19 classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
20 UserSchedulingPriority UserInterruptPriority TimingPriority |
20 UserSchedulingPriority UserInterruptPriority TimingPriority |
21 HighestPriority SchedulingPriority MaxNumberOfProcesses' |
21 HighestPriority SchedulingPriority MaxNumberOfProcesses' |
22 poolDictionaries:'' |
22 poolDictionaries:'' |
23 category:'Kernel-Processes' |
23 category:'Kernel-Processes' |
24 ! |
24 ! |
25 |
25 |
26 !ProcessorScheduler class methodsFor:'documentation'! |
26 !ProcessorScheduler class methodsFor:'documentation'! |
1100 self resume:aProcess |
1100 self resume:aProcess |
1101 ! |
1101 ! |
1102 |
1102 |
1103 suspend:aProcess |
1103 suspend:aProcess |
1104 "remove the argument, aProcess from the list of runnable processes. |
1104 "remove the argument, aProcess from the list of runnable processes. |
1105 If the process is the current one, reschedule." |
1105 If the process is the current one, reschedule. |
|
1106 This method should only be called by Process>>suspend" |
1106 |
1107 |
1107 |pri l p wasBlocked| |
1108 |pri l p wasBlocked| |
1108 |
1109 |
1109 " |
1110 " |
1110 some debugging stuff |
1111 some debugging stuff |
1128 |
1129 |
1129 pri := aProcess priority. |
1130 pri := aProcess priority. |
1130 l := quiescentProcessLists at:pri. |
1131 l := quiescentProcessLists at:pri. |
1131 |
1132 |
1132 "notice: this is slightly faster than putting the if-code into |
1133 "notice: this is slightly faster than putting the if-code into |
1133 the ifAbsent block, because [] is a shared cheap block |
1134 the ifAbsent block, because [] is a shared cheap block, created at compile time |
1134 " |
1135 " |
1135 (l remove:aProcess ifAbsent:[]) isNil ifTrue:[ |
1136 (l remove:aProcess ifAbsent:[]) isNil ifTrue:[ |
1136 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1137 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1137 'bad suspend: not on run list' errorPrintNL. |
1138 'bad suspend: not on run list' errorPrintNL. |
1138 "/ MiniDebugger enterWithMessage:'bad suspend: not on run list'. |
1139 "/ MiniDebugger enterWithMessage:'bad suspend: not on run list'. |
1139 self threadSwitch:scheduler. |
1140 self threadSwitch:scheduler. |
1140 ^ self |
1141 ^ self |
1141 ]. |
1142 ]. |
1142 |
1143 |
1143 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1144 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1144 |
|
1145 " |
|
1146 this is a bit of a kludge: allow someone else to |
|
1147 set the state to something like #ioWait etc. |
|
1148 In this case, do not set to #suspend. |
|
1149 All of this to enhance the output of the process monitor ... |
|
1150 " |
|
1151 aProcess setStateTo:#suspended if:#active or:#run. |
|
1152 |
1145 |
1153 (aProcess == activeProcess) ifTrue:[ |
1146 (aProcess == activeProcess) ifTrue:[ |
1154 "we can immediately switch sometimes" |
1147 "we can immediately switch sometimes" |
1155 l notEmpty ifTrue:[ |
1148 l notEmpty ifTrue:[ |
1156 p := l first |
1149 p := l first |
1157 ] ifFalse:[ |
1150 ] ifFalse:[ |
1158 p := scheduler |
1151 p := scheduler |
1159 ]. |
1152 ]. |
1160 self threadSwitch:p |
1153 self threadSwitch:p |
1161 ]. |
1154 ]. |
|
1155 |
|
1156 "Modified: 13.12.1995 / 13:32:11 / stefan" |
1162 ! |
1157 ! |
1163 |
1158 |
1164 terminate:aProcess |
1159 terminate:aProcess |
1165 "terminate aProcess. This is donen by sending aProcess the terminateSignal, |
1160 "terminate aProcess. This is donen by sending aProcess the terminateSignal, |
1166 which will evaluate any unwind blocks and finally do a hard terminate." |
1161 which will evaluate any unwind blocks and finally do a hard terminate." |