10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 "{ Package: 'stx:libbasic' }" |
12 "{ Package: 'stx:libbasic' }" |
13 |
13 |
14 Object subclass:#ProcessorScheduler |
14 Object subclass:#ProcessorScheduler |
15 instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
15 instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
16 activeProcessId currentPriority readFdArray readSemaphoreArray |
16 activeProcessId currentPriority readFdArray readSemaphoreArray |
17 readCheckArray writeFdArray writeSemaphoreArray writeCheckArray |
17 readCheckArray writeFdArray writeSemaphoreArray writeCheckArray |
18 timeoutArray timeoutActionArray timeoutProcessArray |
18 timeoutArray timeoutActionArray timeoutProcessArray |
19 timeoutSemaphoreArray idleActions anyTimeouts dispatching |
19 timeoutSemaphoreArray idleActions anyTimeouts dispatching |
20 interruptedProcess useIOInterrupts gotIOInterrupt |
20 interruptedProcess useIOInterrupts gotIOInterrupt |
21 osChildExitActions gotChildSignalInterrupt |
21 osChildExitActions gotChildSignalInterrupt |
22 exitWhenNoMoreUserProcesses suspendScheduler timeSliceProcess |
22 exitWhenNoMoreUserProcesses suspendScheduler timeSliceProcess |
23 supportDynamicPriorities timeSliceNeededSemaphore |
23 supportDynamicPriorities timeSliceNeededSemaphore |
24 scheduledProcesses preWaitActions timeoutHandlerProcess |
24 scheduledProcesses preWaitActions timeoutHandlerProcess |
25 readableResultFdArray writableResultFdArray' |
25 readableResultFdArray writableResultFdArray' |
26 classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
26 classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
27 UserSchedulingPriority UserInterruptPriority TimingPriority |
27 UserSchedulingPriority UserInterruptPriority TimingPriority |
28 HighestPriority SchedulingPriority MaxNumberOfProcesses |
28 HighestPriority SchedulingPriority MaxNumberOfProcesses |
29 InvalidProcessSignal TimeSlicingPriorityLimit TimeSliceInterval |
29 InvalidProcessSignal TimeSlicingPriorityLimit TimeSliceInterval |
30 EventPollingInterval' |
30 EventPollingInterval' |
31 poolDictionaries:'' |
31 poolDictionaries:'' |
32 category:'Kernel-Processes' |
32 category:'Kernel-Processes' |
33 ! |
33 ! |
34 |
34 |
35 !ProcessorScheduler class methodsFor:'documentation'! |
35 !ProcessorScheduler class methodsFor:'documentation'! |
36 |
36 |
37 copyright |
37 copyright |
2191 |
2191 |
2192 timeSliceNeededSemaphore := Semaphore new name:'timeSlice needed'. |
2192 timeSliceNeededSemaphore := Semaphore new name:'timeSlice needed'. |
2193 |
2193 |
2194 timeSliceProcess := [ |
2194 timeSliceProcess := [ |
2195 [ |
2195 [ |
2196 |myDelay t flipFlop| |
2196 self timeSlicingLoop. |
2197 |
|
2198 myDelay := Delay forMilliseconds:(t := TimeSliceInterval). |
|
2199 flipFlop := true. |
|
2200 |
|
2201 'Processor [info]: timeslicer started' infoPrintCR. |
|
2202 [true] whileTrue: [ |
|
2203 t ~~ TimeSliceInterval ifTrue:[ |
|
2204 "/ interval changed -> need a new delay |
|
2205 myDelay delay:(t := TimeSliceInterval). |
|
2206 ]. |
|
2207 myDelay wait. |
|
2208 self slice. |
|
2209 |
|
2210 "/ every other tick, recompute priorities. |
|
2211 flipFlop := flipFlop not. |
|
2212 flipFlop ifTrue:[ |
|
2213 scheduledProcesses notNil ifTrue:[ |
|
2214 supportDynamicPriorities == true ifTrue:[ |
|
2215 self recomputeDynamicPriorities. |
|
2216 ]. |
|
2217 scheduledProcesses removeAll. |
|
2218 ]. |
|
2219 scheduledProcesses := IdentitySet new. |
|
2220 ]. |
|
2221 ] |
|
2222 ] ifCurtailed:[ |
2197 ] ifCurtailed:[ |
2223 timeSliceProcess := nil. |
2198 timeSliceProcess := nil. |
2224 'Processor [info]: timeslicer finished' infoPrintCR. |
2199 'Processor [info]: timeslicer finished' infoPrintCR. |
2225 ] |
2200 ] |
2226 ] newProcess. |
2201 ] newProcess. |
2275 Processor supportDynamicPriorities:true |
2250 Processor supportDynamicPriorities:true |
2276 Processor supportDynamicPriorities:false |
2251 Processor supportDynamicPriorities:false |
2277 " |
2252 " |
2278 |
2253 |
2279 "Modified: / 3.8.1998 / 22:54:52 / cg" |
2254 "Modified: / 3.8.1998 / 22:54:52 / cg" |
|
2255 ! |
|
2256 |
|
2257 timeSlicingLoop |
|
2258 |myDelay t flipFlop| |
|
2259 |
|
2260 myDelay := Delay forMilliseconds:(t := TimeSliceInterval). |
|
2261 flipFlop := true. |
|
2262 |
|
2263 'Processor [info]: timeslicer started' infoPrintCR. |
|
2264 [true] whileTrue: [ |
|
2265 t ~~ TimeSliceInterval ifTrue:[ |
|
2266 "/ interval changed -> need a new delay |
|
2267 myDelay delay:(t := TimeSliceInterval). |
|
2268 ]. |
|
2269 myDelay wait. |
|
2270 self slice. |
|
2271 |
|
2272 "/ every other tick, recompute priorities. |
|
2273 flipFlop := flipFlop not. |
|
2274 flipFlop ifTrue:[ |
|
2275 scheduledProcesses notNil ifTrue:[ |
|
2276 supportDynamicPriorities == true ifTrue:[ |
|
2277 self recomputeDynamicPriorities. |
|
2278 ]. |
|
2279 scheduledProcesses removeAll. |
|
2280 ]. |
|
2281 scheduledProcesses := IdentitySet new. |
|
2282 ]. |
|
2283 ] |
2280 ! ! |
2284 ! ! |
2281 |
2285 |
2282 !ProcessorScheduler methodsFor:'semaphore signalling'! |
2286 !ProcessorScheduler methodsFor:'semaphore signalling'! |
2283 |
2287 |
2284 disableSemaphore:aSemaphore |
2288 disableSemaphore:aSemaphore |
3397 ! ! |
3401 ! ! |
3398 |
3402 |
3399 !ProcessorScheduler class methodsFor:'documentation'! |
3403 !ProcessorScheduler class methodsFor:'documentation'! |
3400 |
3404 |
3401 version |
3405 version |
3402 ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.276 2013-08-20 13:56:31 cg Exp $' |
3406 ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.277 2013-08-23 11:23:28 cg Exp $' |
3403 ! |
3407 ! |
3404 |
3408 |
3405 version_CVS |
3409 version_CVS |
3406 ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.276 2013-08-20 13:56:31 cg Exp $' |
3410 ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.277 2013-08-23 11:23:28 cg Exp $' |
3407 ! ! |
3411 ! ! |
3408 |
3412 |
3409 |
3413 |
3410 ProcessorScheduler initialize! |
3414 ProcessorScheduler initialize! |