1 " |
1 " |
2 COPYRIGHT (c) 1993 by Claus Gittinger |
2 COPYRIGHT (c) 1993 by Claus Gittinger |
|
3 COPYRIGHT (c) 2016-2017 Jan Vrany |
3 All Rights Reserved |
4 All Rights Reserved |
4 |
5 |
5 This software is furnished under a license and may be used |
6 This software is furnished under a license and may be used |
6 only in accordance with the terms of that license and with the |
7 only in accordance with the terms of that license and with the |
7 inclusion of the above copyright notice. This software may not |
8 inclusion of the above copyright notice. This software may not |
29 timedActionCounter' |
30 timedActionCounter' |
30 classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
31 classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
31 UserSchedulingPriority UserInterruptPriority TimingPriority |
32 UserSchedulingPriority UserInterruptPriority TimingPriority |
32 HighestPriority SchedulingPriority MaxNumberOfProcesses |
33 HighestPriority SchedulingPriority MaxNumberOfProcesses |
33 InvalidProcessSignal TimeSlicingPriorityLimit TimeSliceInterval |
34 InvalidProcessSignal TimeSlicingPriorityLimit TimeSliceInterval |
34 EventPollingInterval MaxProcessId' |
35 EventPollingInterval MinProcessId MaxProcessId SysProcessId' |
35 poolDictionaries:'' |
36 poolDictionaries:'' |
36 category:'Kernel-Processes' |
37 category:'Kernel-Processes' |
37 ! |
38 ! |
38 |
39 |
39 !ProcessorScheduler class methodsFor:'documentation'! |
40 !ProcessorScheduler class methodsFor:'documentation'! |
40 |
41 |
41 copyright |
42 copyright |
42 " |
43 " |
43 COPYRIGHT (c) 1993 by Claus Gittinger |
44 COPYRIGHT (c) 1993 by Claus Gittinger |
|
45 COPYRIGHT (c) 2016-2017 Jan Vrany |
44 All Rights Reserved |
46 All Rights Reserved |
45 |
47 |
46 This software is furnished under a license and may be used |
48 This software is furnished under a license and may be used |
47 only in accordance with the terms of that license and with the |
49 only in accordance with the terms of that license and with the |
48 inclusion of the above copyright notice. This software may not |
50 inclusion of the above copyright notice. This software may not |
261 TimingPriority := 16. |
263 TimingPriority := 16. |
262 TimeSlicingPriorityLimit := 26. |
264 TimeSlicingPriorityLimit := 26. |
263 HighestPriority := 30. |
265 HighestPriority := 30. |
264 SchedulingPriority := 31. |
266 SchedulingPriority := 31. |
265 |
267 |
|
268 self initializeVMProcessIdConstants. |
|
269 |
266 InvalidProcessSignal isNil ifTrue:[ |
270 InvalidProcessSignal isNil ifTrue:[ |
267 InvalidProcessSignal := Error newSignalMayProceed:true. |
271 InvalidProcessSignal := Error newSignalMayProceed:true. |
268 InvalidProcessSignal nameClass:self message:#invalidProcessSignal. |
272 InvalidProcessSignal nameClass:self message:#invalidProcessSignal. |
269 InvalidProcessSignal notifierString:'invalid process'. |
273 InvalidProcessSignal notifierString:'invalid process'. |
270 ]. |
274 ]. |
281 " |
285 " |
282 PureEventDriven := self threadsAvailable not. |
286 PureEventDriven := self threadsAvailable not. |
283 PureEventDriven ifTrue:[ |
287 PureEventDriven ifTrue:[ |
284 'Processor [error]: no process support - running event driven' errorPrintCR |
288 'Processor [error]: no process support - running event driven' errorPrintCR |
285 ]. |
289 ]. |
286 self initializeVMMaxProcessId |
290 |
287 |
291 |
288 "Modified: / 23-09-1996 / 14:24:50 / stefan" |
292 "Modified: / 23-09-1996 / 14:24:50 / stefan" |
289 "Modified: / 10-01-1997 / 18:03:03 / cg" |
293 "Modified: / 10-01-1997 / 18:03:03 / cg" |
290 "Modified: / 19-09-2014 / 12:47:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
294 "Modified: / 19-09-2014 / 12:47:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
291 ! |
295 ! |
292 |
296 |
293 initializeVMMaxProcessId |
297 initializeVMProcessIdConstants |
294 |
298 |
295 "/ for java locks, the VM may reserve some bits |
299 "/ for java locks, the VM may reserve some bits |
296 "/ and reduce the maximum processID to be able to |
300 "/ and reduce the maximum processID to be able to |
297 "/ encode the id in an object's header field. |
301 "/ encode the id in an object's header field. |
298 %{ |
302 %{ |
299 #ifndef __SCHTEAM__ |
303 #ifndef __SCHTEAM__ |
300 |
304 @global(ProcessorScheduler:MinProcessId) = __MKSMALLINT(MIN_PROCESS_ID); |
301 # ifndef MAX_PROCESS_ID |
|
302 # define MAX_PROCESS_ID _MAX_INT |
|
303 # endif |
|
304 |
|
305 @global(ProcessorScheduler:MaxProcessId) = __MKSMALLINT(MAX_PROCESS_ID); |
305 @global(ProcessorScheduler:MaxProcessId) = __MKSMALLINT(MAX_PROCESS_ID); |
|
306 @global(ProcessorScheduler:SysProcessId) = __MKSMALLINT(SYS_PROCESS_ID); |
306 RETURN (self); |
307 RETURN (self); |
307 #endif /* not SCHTEAM */ |
308 #endif /* not SCHTEAM */ |
308 %}. |
309 %}. |
309 MaxProcessId := SmallInteger maxVal. |
310 self primitiveFailed |
310 ! ! |
311 ! ! |
311 |
312 |
312 !ProcessorScheduler class methodsFor:'instance creation'! |
313 !ProcessorScheduler class methodsFor:'instance creation'! |
313 |
314 |
314 new |
315 new |
965 for a runnable process. |
966 for a runnable process. |
966 " |
967 " |
967 currentPriority := SchedulingPriority. |
968 currentPriority := SchedulingPriority. |
968 p := Process basicNew. |
969 p := Process basicNew. |
969 p |
970 p |
970 setId:0 state:#run; |
971 setId:SysProcessId state:#run; |
971 setPriority:currentPriority; |
972 setPriority:currentPriority; |
972 name:'scheduler'; |
973 name:'scheduler'; |
973 beSystemProcess. |
974 beSystemProcess. |
974 |
975 |
975 scheduler := activeProcess := p. |
976 scheduler := activeProcess := p. |
976 activeProcessId := 0. |
977 activeProcessId := SysProcessId. |
977 |
978 |
978 quiescentProcessLists at:currentPriority put:(l := LinkedList new). |
979 quiescentProcessLists at:currentPriority put:(l := LinkedList new). |
979 l add:p. |
980 l add:p. |
980 |
981 |
981 " |
982 " |
1326 (VM switches back to scheduler) |
1327 (VM switches back to scheduler) |
1327 - a halted process cannot execute its interrupt |
1328 - a halted process cannot execute its interrupt |
1328 actions (win32 only) |
1329 actions (win32 only) |
1329 " |
1330 " |
1330 id := p id. |
1331 id := p id. |
1331 (id ~~ 0 and:[id notNil]) ifTrue:[ |
1332 (id ~~ SysProcessId and:[id notNil]) ifTrue:[ |
1332 'Processor [warning]: problem with process ' errorPrint. |
1333 'Processor [warning]: problem with process ' errorPrint. |
1333 id errorPrint. |
1334 id errorPrint. |
1334 (nm := p name) notNil ifTrue:[ |
1335 (nm := p name) notNil ifTrue:[ |
1335 ' (' errorPrint. nm errorPrint. ')' errorPrint. |
1336 ' (' errorPrint. nm errorPrint. ')' errorPrint. |
1336 ]. |
1337 ]. |