author | Claus Gittinger <cg@exept.de> |
Fri, 10 Jan 1997 19:17:32 +0100 | |
changeset 2137 | 3e210d26d0d8 |
parent 2129 | e03cd7bc3475 |
child 2149 | 622f01b8ce2f |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
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 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Object subclass:#ProcessorScheduler |
|
768
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
14 |
instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
15 |
currentPriority readFdArray readSemaphoreArray readCheckArray |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
16 |
writeFdArray writeSemaphoreArray timeoutArray timeoutActionArray |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
17 |
timeoutProcessArray timeoutSemaphoreArray idleActions anyTimeouts |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
18 |
dispatching interruptedProcess useIOInterrupts gotIOInterrupt |
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
19 |
osChildExitActions gotChildSignalInterrupt |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
20 |
exitWhenNoMoreUserProcesses suspendScheduler' |
768
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
21 |
classVariableNames:'KnownProcesses KnownProcessIds PureEventDriven |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
22 |
UserSchedulingPriority UserInterruptPriority TimingPriority |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
23 |
HighestPriority SchedulingPriority MaxNumberOfProcesses |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
24 |
InvalidProcessSignal' |
768
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
25 |
poolDictionaries:'' |
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
26 |
category:'Kernel-Processes' |
1 | 27 |
! |
28 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
29 |
!ProcessorScheduler class methodsFor:'documentation'! |
88 | 30 |
|
31 |
copyright |
|
32 |
" |
|
33 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
159 | 34 |
All Rights Reserved |
88 | 35 |
|
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
! |
|
44 |
||
45 |
documentation |
|
46 |
" |
|
47 |
This class has only one instance, which is bound to the global |
|
48 |
'Processor'. It is responsible for scheduling among the smalltalk |
|
49 |
processes (threads; not to confuse with heavy weight unix processes). |
|
93 | 50 |
|
51 |
Scheduling is fully done in smalltalk (the always runnable scheduler- |
|
52 |
process, running at highest priority does this). |
|
231 | 53 |
The main VM primitive to support this is found in threadSwitch, which passes |
93 | 54 |
control to another process (usually selected by the scheduler). |
159 | 55 |
Thus it is possible to modify the schedulers policy and implementation |
56 |
at the smalltalk level. |
|
93 | 57 |
(To answer a frequently asked question: |
159 | 58 |
dont add preemptive round-robin here; this can be implemented without |
93 | 59 |
any need to change the scheduler. See goodies/timeslicing.st for how |
60 |
this is done in a very elegant way). |
|
61 |
||
62 |
Notice: Smalltalk/X can (still) be compiled & configured without |
|
63 |
process support. This non-process mode is called 'pureEventDriven' mode |
|
64 |
and is useful to quickly port ST/X to systems, where these facilities |
|
65 |
are either not needed (server applications), or are difficult to |
|
66 |
implement (threads require some assembler support functions). |
|
67 |
To allow pureEvent mode, kludges are built into some places in the |
|
68 |
system, where either a process is forked, or a timeout is used instead |
|
69 |
(for examples, see ProcessMonitor or MemoryMonitor). |
|
70 |
||
335 | 71 |
This pure-event mode may not be supported in the future |
72 |
(actually, it is no longer maintained in places where was present, so dont |
|
73 |
run the system without Processes). |
|
93 | 74 |
|
369 | 75 |
|
1273 | 76 |
[class variables:] |
93 | 77 |
|
1780
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
78 |
KnownProcesses <WeakArray> all known processes |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
79 |
KnownProcessIds <Collection> and their IDs |
241 | 80 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
81 |
PureEventDriven <Boolean> true, if no process support |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
82 |
is available |
241 | 83 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
84 |
UserSchedulingPriority <Integer> the priority at which normal |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
85 |
user interfaces run |
241 | 86 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
87 |
UserInterruptPriority the priority at which user- |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
88 |
interrupts (Cntl-C) processing |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
89 |
takes place. Processes with |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
90 |
a greater or equal priority are |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
91 |
not interruptable. |
241 | 92 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
93 |
TimingPriority the priority used for timing. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
94 |
Processes with a greater or |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
95 |
equal priority are not interrupted |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
96 |
by timers. |
241 | 97 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
98 |
HighestPriority The highest allowed prio for processes |
241 | 99 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
100 |
SchedulingPriority The priority of the scheduler (must |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
101 |
me higher than any other). |
93 | 102 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
103 |
MaxNumberOfProcesses if non-nil, no more than this |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
104 |
number of processes are allowed |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
105 |
(for debugging) |
93 | 106 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
107 |
most interesting methods: |
93 | 108 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
109 |
Processor>>suspend: (see also Process>>suspend) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
110 |
Processor>>resume: (see also Process>>resume) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
111 |
Processor>>terminate: (see also Process>>terminate) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
112 |
Processor>>yield |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
113 |
Processor>>changePriority:for: (see also Process>>priority: |
93 | 114 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
115 |
Processor>>signal:afterSeconds: (see also Delay>>forSeconds:) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
116 |
Processor>>signal:afterMilliseconds: (see also Delay>>forMilliseconds:) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
117 |
Processor>>signal:onInput: (see also ExternalStream>>readWait) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
118 |
Processor>>signal:onOutput: (see also ExternalStream>>writeWait) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
119 |
Processor>>disableSemaphore: |
1273 | 120 |
|
121 |
||
122 |
[see also:] |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
123 |
Process |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
124 |
Delay Semaphore SemaphoreSet SharedQueue |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
125 |
WindowGroup |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
126 |
(``Working with processes'': programming/processes.html) |
1294 | 127 |
|
128 |
[author:] |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
129 |
Claus Gittinger |
88 | 130 |
" |
131 |
! ! |
|
132 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
133 |
!ProcessorScheduler class methodsFor:'initialization'! |
1 | 134 |
|
135 |
initialize |
|
44 | 136 |
"class setup: create the one-and-only instance of myself and |
137 |
setup some priority values." |
|
138 |
||
93 | 139 |
UserSchedulingPriority := 8. |
140 |
UserInterruptPriority := 24. |
|
141 |
TimingPriority := 16. |
|
142 |
SchedulingPriority := 31. |
|
241 | 143 |
HighestPriority := 30. |
93 | 144 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
145 |
InvalidProcessSignal isNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
146 |
InvalidProcessSignal := ErrorSignal newSignalMayProceed:true. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
147 |
InvalidProcessSignal nameClass:self message:#invalidProcessSignal. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
148 |
InvalidProcessSignal notifierString:'invalid process'. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
149 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
150 |
|
159 | 151 |
Processor isNil ifTrue:[ |
1086 | 152 |
"create the one and only processor" |
1 | 153 |
|
1086 | 154 |
Processor := self basicNew initialize. |
10 | 155 |
]. |
77 | 156 |
|
157 |
" |
|
158 |
allow configurations without processes |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
159 |
(but such configurations are no longer distributed) |
77 | 160 |
" |
13 | 161 |
PureEventDriven := self threadsAvailable not. |
162 |
PureEventDriven ifTrue:[ |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
163 |
'Processor [error]: no process support - running event driven' errorPrintCR |
13 | 164 |
]. |
1086 | 165 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
166 |
"Modified: 23.9.1996 / 14:24:50 / stefan" |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
167 |
"Modified: 10.1.1997 / 18:03:03 / cg" |
1 | 168 |
! ! |
169 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
170 |
!ProcessorScheduler class methodsFor:'instance creation'! |
10 | 171 |
|
172 |
new |
|
173 |
"there is (currently) only one processor ..." |
|
174 |
||
159 | 175 |
self error:'only one processor is allowed in the system' |
10 | 176 |
! ! |
177 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
178 |
!ProcessorScheduler class methodsFor:'Signal constants'! |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
179 |
|
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
180 |
invalidProcessSignal |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
181 |
^ InvalidProcessSignal |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
182 |
|
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
183 |
"Created: 23.9.1996 / 13:44:57 / stefan" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
184 |
! ! |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
185 |
|
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
186 |
!ProcessorScheduler class methodsFor:'instance release'! |
10 | 187 |
|
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
188 |
update:something with:aParameter from:changedObject |
159 | 189 |
"some Process has been garbage collected |
335 | 190 |
- terminate the underlying thread. |
191 |
Usually this does not happen; instead, the process terminates itself |
|
192 |
by sending #terminate." |
|
10 | 193 |
|
194 |
|id sz "{ Class: SmallInteger }"| |
|
1 | 195 |
|
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
196 |
something == #ElementExpired ifTrue:[ |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
197 |
sz := KnownProcessIds size. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
198 |
1 to:sz do:[:index | |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
199 |
"/ (KnownProcesses at:index) isNil ifTrue:[ |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
200 |
(KnownProcesses at:index) == 0 ifTrue:[ |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
201 |
id := KnownProcessIds at:index. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
202 |
id notNil ifTrue:[ |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
203 |
'Processor [warning]: terminating thread ' errorPrint. |
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
204 |
id errorPrint. |
2137 | 205 |
' (no longer refd)' errorPrintCR. |
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
206 |
|
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
207 |
self threadDestroy:id. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
208 |
KnownProcessIds at:index put:nil. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
209 |
]. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
210 |
KnownProcesses at:index put:nil. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
211 |
] |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
212 |
] |
10 | 213 |
] |
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
214 |
|
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
215 |
"Created: 7.1.1997 / 16:45:42 / stefan" |
2137 | 216 |
"Modified: 10.1.1997 / 19:10:48 / cg" |
10 | 217 |
! ! |
218 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
219 |
!ProcessorScheduler class methodsFor:'primitive process primitives'! |
10 | 220 |
|
339 | 221 |
threadCreate:aProcess withId:id |
159 | 222 |
"physical creation of a process. |
10 | 223 |
(warning: low level entry, no administration done). |
339 | 224 |
This may raise an exception, if a VM process could not be created." |
13 | 225 |
|
369 | 226 |
MaxNumberOfProcesses notNil ifTrue:[ |
227 |
KnownProcessIds size >= MaxNumberOfProcesses ifTrue:[ |
|
228 |
(KnownProcessIds count:[:el | el notNil]) >= MaxNumberOfProcesses ifTrue:[ |
|
229 |
" |
|
230 |
the number of processes has reached the (soft) limit. |
|
231 |
This limit prevents runaway programs from creating too many |
|
232 |
processes. If you continue in the debugger, the process will be |
|
233 |
created as usual. If you dont want this, abort or terminate. |
|
234 |
" |
|
235 |
self error:'too many processes'. |
|
236 |
] |
|
237 |
] |
|
238 |
]. |
|
239 |
||
240 |
%{ |
|
1 | 241 |
int tid; |
242 |
extern int __threadCreate(); |
|
243 |
||
339 | 244 |
tid = __threadCreate(aProcess, |
245 |
0 /* stackSize: no longer needed */, |
|
1133 | 246 |
__isSmallInteger(id) ? __intVal(id) /* assign id */ |
339 | 247 |
: -1 /* let VM assign one */ ); |
248 |
if (tid) { |
|
1133 | 249 |
RETURN ( __MKSMALLINT(tid)); |
1 | 250 |
} |
251 |
%} |
|
13 | 252 |
. |
69 | 253 |
" |
254 |
arrive here, if creation of process in VM failed. |
|
159 | 255 |
This may happen, if the VM does not support more processes, |
256 |
or if it ran out of memory, when allocating internal data |
|
257 |
structures. |
|
69 | 258 |
" |
115 | 259 |
^ ObjectMemory allocationFailureSignal raise. |
1 | 260 |
! |
261 |
||
262 |
threadDestroy:id |
|
263 |
"physical destroy other process ... |
|
264 |
(warning: low level entry, no administration done)" |
|
265 |
||
13 | 266 |
%{ /* NOCONTEXT */ |
267 |
||
253 | 268 |
if (__isSmallInteger(id)) { |
1133 | 269 |
__threadDestroy(__intVal(id)); |
1 | 270 |
} |
271 |
%} |
|
699 | 272 |
! |
273 |
||
274 |
threadInterrupt:id |
|
275 |
"make the process evaluate an interrupt. This sets a flag in the VMs |
|
276 |
threadSwitcher, to let the process perform a #interrupt when its set to |
|
277 |
run the next time. The process itself can decide how to react on this |
|
278 |
interrupt (currently, it looks for interruptBlocks to evaluate)." |
|
279 |
||
280 |
%{ /* NOCONTEXT */ |
|
281 |
||
282 |
if (__isSmallInteger(id)) { |
|
1133 | 283 |
__threadInterrupt(__intVal(id)); |
699 | 284 |
} |
285 |
%} |
|
286 |
! |
|
287 |
||
288 |
threadsAvailable |
|
289 |
"return true, if the runtime system supports threads (i.e. processes); |
|
290 |
false otherwise." |
|
291 |
||
292 |
%{ /* NOCONTEXT */ |
|
293 |
RETURN (__threadsAvailable()); |
|
294 |
%} |
|
1 | 295 |
! ! |
296 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
297 |
!ProcessorScheduler class methodsFor:'queries'! |
699 | 298 |
|
299 |
isPureEventDriven |
|
300 |
"this is temporary - (maybe not :-). |
|
301 |
you can run ST/X either with or without processes. |
|
302 |
Without, there is conceptionally a single process handling all |
|
303 |
outside events and timeouts. This has some negative implications |
|
304 |
(Debugger is ugly), but allows a fully portable ST/X without any |
|
305 |
assembler support - i.e. quick portability. |
|
306 |
The PureEvent flag will automatically be set if the runtime system |
|
307 |
does not support threads - otherwise, it can be set manually |
|
308 |
(from rc-file). |
|
309 |
" |
|
310 |
||
311 |
^ PureEventDriven |
|
312 |
! |
|
313 |
||
314 |
knownProcesses |
|
315 |
"return a collection of all (living) processes in the system" |
|
316 |
||
1780
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
317 |
^ KnownProcesses select:[:p | p notNil and:[p ~~ 0]] |
699 | 318 |
! |
319 |
||
320 |
maxNumberOfProcesses |
|
321 |
"return the limit on the number of processes; |
|
322 |
the default is nil (i.e. unlimited)." |
|
323 |
||
324 |
^ MaxNumberOfProcesses |
|
325 |
! |
|
10 | 326 |
|
699 | 327 |
maxNumberOfProcesses:aNumber |
328 |
"set the limit on the number of processes. |
|
329 |
This helps if you have a program which (by error) creates countless |
|
330 |
subprocesses. Without this limit, you may have a hard time to find |
|
331 |
this error (and repairing it). If nil (the default), the number of |
|
332 |
processes is unlimited." |
|
333 |
||
334 |
MaxNumberOfProcesses := aNumber |
|
335 |
! |
|
336 |
||
337 |
processDriven |
|
338 |
"turn on process driven mode" |
|
10 | 339 |
|
699 | 340 |
PureEventDriven := false |
341 |
! |
|
342 |
||
343 |
pureEventDriven |
|
344 |
"turn on pure-event driven mode - no processes, single dispatch loop" |
|
345 |
||
346 |
PureEventDriven := true |
|
347 |
! ! |
|
1 | 348 |
|
699 | 349 |
!ProcessorScheduler methodsFor:'I/O event actions'! |
350 |
||
351 |
disableFd:aFileDescriptor |
|
352 |
"disable block events on aFileDescriptor. |
|
353 |
This is a leftover support for pure-event systems and may vanish." |
|
354 |
||
355 |
|idx "{Class: SmallInteger }" |
|
356 |
wasBlocked| |
|
1 | 357 |
|
93 | 358 |
wasBlocked := OperatingSystem blockInterrupts. |
699 | 359 |
idx := readFdArray identityIndexOf:aFileDescriptor startingAt:1. |
360 |
idx ~~ 0 ifTrue:[ |
|
361 |
readFdArray at:idx put:nil. |
|
362 |
readCheckArray at:idx put:nil. |
|
363 |
readSemaphoreArray at:idx put:nil |
|
93 | 364 |
]. |
365 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
24 | 366 |
! |
367 |
||
699 | 368 |
enableIOAction:aBlock onInput:aFileDescriptor |
369 |
"half-obsolete event support: arrange for aBlock to be |
|
370 |
evaluated when input on aFileDescriptor arrives. |
|
371 |
This is a leftover support for pure-event systems and may vanish." |
|
1 | 372 |
|
699 | 373 |
|idx "{Class: SmallInteger }" |
374 |
wasBlocked| |
|
10 | 375 |
|
93 | 376 |
wasBlocked := OperatingSystem blockInterrupts. |
699 | 377 |
(readFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
378 |
idx := readFdArray identityIndexOf:nil startingAt:1. |
|
379 |
idx ~~ 0 ifTrue:[ |
|
380 |
readFdArray at:idx put:aFileDescriptor. |
|
381 |
readCheckArray at:idx put:aBlock. |
|
382 |
readSemaphoreArray at:idx put:nil |
|
159 | 383 |
] ifFalse:[ |
699 | 384 |
readFdArray := readFdArray copyWith:aFileDescriptor. |
385 |
readCheckArray := readCheckArray copyWith:aBlock. |
|
386 |
readSemaphoreArray := readSemaphoreArray copyWith:nil. |
|
159 | 387 |
] |
93 | 388 |
]. |
389 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1 | 390 |
! ! |
391 |
||
392 |
!ProcessorScheduler methodsFor:'accessing'! |
|
393 |
||
69 | 394 |
activePriority |
395 |
"return the priority of the currently running process. |
|
159 | 396 |
GNU-ST & ST-80 compatibility; this is the same as currentPriority" |
69 | 397 |
|
398 |
^ currentPriority |
|
399 |
! |
|
400 |
||
25 | 401 |
activeProcess |
10 | 402 |
"return the currently running process" |
403 |
||
25 | 404 |
^ activeProcess |
1 | 405 |
|
25 | 406 |
"Processor activeProcess" |
181 | 407 |
! |
408 |
||
699 | 409 |
currentPriority |
410 |
"return the priority of the currently running process" |
|
411 |
||
412 |
^ currentPriority |
|
413 |
||
414 |
"Processor currentPriority" |
|
415 |
! |
|
416 |
||
181 | 417 |
interruptedProcess |
418 |
"returns the process which was interrupted by the active one" |
|
419 |
||
420 |
^ interruptedProcess |
|
10 | 421 |
! ! |
422 |
||
699 | 423 |
!ProcessorScheduler methodsFor:'background processing'! |
1 | 424 |
|
699 | 425 |
addIdleBlock:aBlock |
426 |
"add the argument, aBlock to the list of idle-actions. |
|
427 |
Idle blocks are evaluated whenever no other process is runnable, |
|
428 |
and no events are pending. |
|
429 |
Use of idle blocks is not recommended, use a low priority processes |
|
430 |
instead, which has the same effect. Idle blcoks are still included |
|
431 |
to support background actions in pure-event systems, where no processes |
|
432 |
are available. |
|
433 |
Support for idle-blocks may vanish." |
|
10 | 434 |
|
699 | 435 |
|wasBlocked| |
436 |
||
437 |
wasBlocked := OperatingSystem blockInterrupts. |
|
438 |
idleActions isNil ifTrue:[ |
|
439 |
idleActions := OrderedCollection new |
|
440 |
]. |
|
441 |
idleActions add:aBlock. |
|
442 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
443 |
! |
|
1 | 444 |
|
699 | 445 |
removeIdleBlock:aBlock |
446 |
"remove the argument, aBlock from the list of idle-blocks. |
|
447 |
Support for idle-blocks may vanish - use low prio processes instead." |
|
448 |
||
449 |
|wasBlocked| |
|
450 |
||
451 |
wasBlocked := OperatingSystem blockInterrupts. |
|
452 |
idleActions notNil ifTrue:[ |
|
1791 | 453 |
idleActions remove:aBlock ifAbsent:[] |
10 | 454 |
]. |
699 | 455 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
456 |
! ! |
|
457 |
||
10 | 458 |
!ProcessorScheduler methodsFor:'dispatching'! |
459 |
||
460 |
dispatch |
|
93 | 461 |
"It handles timeouts and switches to the highest prio runnable process" |
44 | 462 |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
463 |
|any millis pri p nActions "{ Class: SmallInteger }" |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
464 |
checkBlock sema| |
10 | 465 |
|
93 | 466 |
" |
467 |
handle all timeout actions |
|
468 |
" |
|
27 | 469 |
anyTimeouts ifTrue:[ |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
470 |
self evaluateTimeouts |
10 | 471 |
]. |
472 |
||
231 | 473 |
"first do a quick check for semaphores using checkActions - this is needed for |
302 | 474 |
devices like the X-connection, where some events might be in the event |
475 |
queue. Without these checks, a select might block even though there is work to do |
|
93 | 476 |
" |
10 | 477 |
any := false. |
231 | 478 |
nActions := readCheckArray size. |
10 | 479 |
1 to:nActions do:[:index | |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
480 |
checkBlock := readCheckArray at:index. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
481 |
(checkBlock notNil and:[checkBlock value]) ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
482 |
sema := readSemaphoreArray at:index. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
483 |
sema notNil ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
484 |
sema signalOnce. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
485 |
]. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
486 |
any := true. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
487 |
] |
10 | 488 |
]. |
489 |
||
231 | 490 |
"now, someone might be runnable ..." |
10 | 491 |
|
13 | 492 |
p := self highestPriorityRunnableProcess. |
10 | 493 |
p isNil ifTrue:[ |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
494 |
"/ no one runnable, hard wait for event or timeout |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
495 |
|
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
496 |
self waitForEventOrTimeout. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
497 |
|
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
498 |
"/ check for OS process termination |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
499 |
gotChildSignalInterrupt ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
500 |
gotChildSignalInterrupt := false. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
501 |
self handleChildSignalInterrupt |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
502 |
]. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
503 |
^ self |
10 | 504 |
]. |
505 |
||
13 | 506 |
pri := p priority. |
507 |
||
302 | 508 |
" |
509 |
want to give control to the process p. |
|
10 | 510 |
If the switched-to processes priority is lower than the |
511 |
userSchedulingPriority, we have to make certain, that the |
|
512 |
next input or timer will bring us back for a reschedule. |
|
513 |
This is done by enabling ioInterrupts for all file descriptors. |
|
302 | 514 |
If ioInterrupts are not available (OS does not support them), |
515 |
we schedule a timer interrupt to interrupt us after 1/20s of a second |
|
516 |
- effectively polling the filedescriptors 20 times a second. |
|
517 |
(which is bad, since low prio processes will be hurt in performance) |
|
518 |
Therefore, dont let benchmarks run with low prio ... |
|
519 |
||
231 | 520 |
Higher prio processes must be suspended, |
302 | 521 |
same prio ones must yield or suspend to get back control |
522 |
" |
|
10 | 523 |
|
93 | 524 |
" |
525 |
uncommenting this will make timeouts interrupt the current process |
|
526 |
(i.e. as if the interrupt runs at TimingPrio); |
|
527 |
if left commented, they are handled at UserSchedulingPrio. |
|
13 | 528 |
this will all change, when timeouts are removed and all is process driven |
231 | 529 |
(a future version will have a process running to handle a timeout queue) |
13 | 530 |
" |
531 |
||
532 |
" |
|
533 |
pri < TimingPriority ifTrue:[ |
|
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
534 |
anyTimeouts ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
535 |
millis := self timeToNextTimeout. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
536 |
millis == 0 ifTrue:[^ self]. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
537 |
] |
13 | 538 |
]. |
539 |
" |
|
540 |
||
93 | 541 |
" |
542 |
if the process to run has a lower than UserInterruptPriority, |
|
302 | 543 |
arrange for an interrupt to occur on I/O. |
231 | 544 |
This is done by enabling IO-signals (if the OS supports them) |
93 | 545 |
or by installing a poll-interrupt after 50ms (if the OS does not). |
546 |
" |
|
547 |
pri < UserInterruptPriority ifTrue:[ |
|
548 |
||
549 |
"comment out this if above is uncommented" |
|
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
550 |
anyTimeouts ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
551 |
millis := self timeToNextTimeout. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
552 |
millis == 0 ifTrue:[^ self]. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
553 |
]. |
93 | 554 |
"---" |
10 | 555 |
|
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
556 |
useIOInterrupts ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
557 |
readFdArray do:[:fd | |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
558 |
fd notNil ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
559 |
OperatingSystem enableIOInterruptsOn:fd |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
560 |
]. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
561 |
]. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
562 |
] ifFalse:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
563 |
millis notNil ifTrue:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
564 |
millis := millis min:50 |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
565 |
] ifFalse:[ |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
566 |
millis := 50 |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
567 |
] |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
568 |
] |
13 | 569 |
]. |
10 | 570 |
|
13 | 571 |
millis notNil ifTrue:[ |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
572 |
"schedule a clock interrupt after millis milliseconds" |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
573 |
OperatingSystem enableTimer:millis rounded. |
10 | 574 |
]. |
575 |
||
231 | 576 |
" |
577 |
now let the process run - will come back here by reschedule |
|
578 |
from ioInterrupt or timerInterrupt ... (running at max+1) |
|
579 |
" |
|
10 | 580 |
self threadSwitch:p. |
581 |
||
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
582 |
"... when we arrive here, we are back on stage. |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
583 |
Either by an ALARM or IO signal, or by a suspend of another process |
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
584 |
" |
10 | 585 |
|
586 |
millis notNil ifTrue:[ |
|
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
587 |
OperatingSystem disableTimer. |
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
588 |
]. |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
589 |
|
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
590 |
"/ check for OS process termination |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
591 |
gotChildSignalInterrupt ifTrue:[ |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
592 |
gotChildSignalInterrupt := false. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
593 |
self handleChildSignalInterrupt |
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
594 |
]. |
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
595 |
|
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
596 |
"/ check for new input |
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
597 |
|
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
598 |
(gotIOInterrupt or:[useIOInterrupts not]) ifTrue:[ |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
599 |
gotIOInterrupt := false. |
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
600 |
self checkForInputWithTimeout:0. |
10 | 601 |
] |
768
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
602 |
|
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
603 |
"Modified: 12.4.1996 / 10:14:18 / stefan" |
2111
dcef47118f0d
childSignal if no one runnable
Claus Gittinger <cg@exept.de>
parents:
2091
diff
changeset
|
604 |
"Modified: 9.1.1997 / 16:12:44 / cg" |
699 | 605 |
! |
606 |
||
607 |
dispatchLoop |
|
608 |
"central dispatch loop; the scheduler process is always staying in |
|
609 |
this method, looping forever." |
|
610 |
||
806
409a8c189e01
also handle termination of the scheduler process
Claus Gittinger <cg@exept.de>
parents:
804
diff
changeset
|
611 |
|dispatchAction handlerAction ignoredSignals| |
786 | 612 |
|
699 | 613 |
"avoid confusion if entered twice" |
614 |
||
615 |
dispatching == true ifTrue:[^ self]. |
|
616 |
dispatching := true. |
|
617 |
||
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
618 |
"/ create the relevant blocks & signalSet outside of the |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
619 |
"/ while-loop |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
620 |
"/ (thanks to stefans objectAllocation monitor, |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
621 |
"/ this safes a bit of memory allocation in the scheduler) |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
622 |
|
786 | 623 |
dispatchAction := [self dispatch]. |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
624 |
|
806
409a8c189e01
also handle termination of the scheduler process
Claus Gittinger <cg@exept.de>
parents:
804
diff
changeset
|
625 |
handlerAction := [:ex | |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
626 |
('Processor [info]: ignored signal (', ex signal printString, ')') infoPrintCR. |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
627 |
ex return |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
628 |
]. |
806
409a8c189e01
also handle termination of the scheduler process
Claus Gittinger <cg@exept.de>
parents:
804
diff
changeset
|
629 |
|
409a8c189e01
also handle termination of the scheduler process
Claus Gittinger <cg@exept.de>
parents:
804
diff
changeset
|
630 |
ignoredSignals := SignalSet |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
631 |
with:(Process terminateSignal) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
632 |
with:AbortSignal. |
786 | 633 |
|
634 |
"/ |
|
635 |
"/ I made this an extra call to dispatch; this allows recompilation |
|
636 |
"/ of the dispatch-handling code in the running system. |
|
637 |
"/ |
|
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
638 |
[dispatching] whileTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
639 |
ignoredSignals handle:handlerAction do:dispatchAction |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
640 |
]. |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
641 |
|
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
642 |
"/ we arrive here in standalone Apps, |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
643 |
"/ when the last process at or above UserSchedulingPriority process died. |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
644 |
"/ regular ST/X stays in above loop forever |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
645 |
|
2137 | 646 |
'Processor [info]: finish dispatch (no more processes)' infoPrintCR. |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
647 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
648 |
"Modified: 23.9.1996 / 14:19:56 / stefan" |
2137 | 649 |
"Modified: 10.1.1997 / 19:10:53 / cg" |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
650 |
! |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
651 |
|
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
652 |
exitWhenNoMoreUserProcesses:aBoolean |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
653 |
exitWhenNoMoreUserProcesses := aBoolean |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
654 |
! ! |
806
409a8c189e01
also handle termination of the scheduler process
Claus Gittinger <cg@exept.de>
parents:
804
diff
changeset
|
655 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
656 |
!ProcessorScheduler methodsFor:'os process handling'! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
657 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
658 |
childSignalInterrupt |
2116
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
659 |
"{ Pragma: +returnable }" |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
660 |
|
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
661 |
"child changed state - switch to scheduler process which will decide |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
662 |
what to do now." |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
663 |
|
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
664 |
gotChildSignalInterrupt := true. |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
665 |
interruptedProcess := activeProcess. |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
666 |
self threadSwitch:scheduler |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
667 |
|
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
668 |
"Modified: 12.4.1996 / 10:12:18 / stefan" |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
669 |
! |
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
670 |
|
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
671 |
handleChildSignalInterrupt |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
672 |
"child changed state - execute child termination blocks. |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
673 |
If child is no longer alive, remove action block." |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
674 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
675 |
|osProcessStatus blocking wasBlocked| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
676 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
677 |
blocking := OperatingSystem blockingChildProcessWait. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
678 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
679 |
"/ no interrupt processing, to avoid races with monitorPid |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
680 |
wasBlocked := OperatingSystem blockInterrupts. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
681 |
[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
682 |
[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
683 |
osProcessStatus := OperatingSystem childProcessWait:blocking. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
684 |
osProcessStatus notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
685 |
|pid action| |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
686 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
687 |
pid := osProcessStatus pid. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
688 |
osProcessStatus stillAlive ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
689 |
action := osChildExitActions at:pid ifAbsent:[]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
690 |
] ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
691 |
action := osChildExitActions removeKey:pid ifAbsent:[]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
692 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
693 |
action notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
694 |
action value:osProcessStatus |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
695 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
696 |
]. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
697 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
698 |
"/ if pollChildProcesses does block, poll only one status change. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
699 |
"/ we will get another SIGCHLD for other status changes. |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
700 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
701 |
osProcessStatus notNil and:[blocking not] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
702 |
] whileTrue. |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
703 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
704 |
"/ if there are no more waiters, disable SIGCHILD handler. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
705 |
"/ this helps us with synchronous waiters (e.g. pclose), |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
706 |
"/ But they should block SIGCHLD anyway. |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
707 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
708 |
osChildExitActions isEmpty ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
709 |
OperatingSystem disableChildSignalInterrupts. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
710 |
]. |
1032 | 711 |
] valueNowOrOnUnwindDo:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
712 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1032 | 713 |
] |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
714 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
715 |
"Modified: 5.1.1996 / 16:56:11 / stefan" |
1032 | 716 |
"Modified: 28.2.1996 / 21:36:31 / cg" |
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
717 |
"Created: 12.4.1996 / 10:08:21 / stefan" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
718 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
719 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
720 |
monitorPid:pid action:aBlock |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
721 |
"add a 1-arg-block that is called when the operating system child process |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
722 |
with pid pid changes state. |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
723 |
The argument for the block is an OSProcessStatus. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
724 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
725 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
726 |
OperatingSystem sigCHLD ~= 0 ifTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
727 |
"/ SIGCHLD is supported, |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
728 |
"/ aBlock will be evaluated, as soon as a SIGCHLD interrupt for pid has been received. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
729 |
OperatingSystem enableChildSignalInterrupts. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
730 |
osChildExitActions at:pid put:aBlock |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
731 |
] ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
732 |
|osProcessStatus| |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
733 |
"/ SIGCHLD is not supported, wait synchronously for the exit |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
734 |
"/ of pid. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
735 |
[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
736 |
osProcessStatus := OperatingSystem childProcessWait:true. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
737 |
osProcessStatus notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
738 |
(osProcessStatus pid = pid) ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
739 |
aBlock value:osProcessStatus. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
740 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
741 |
osProcessStatus stillAlive |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
742 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
743 |
] whileTrue. |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
744 |
]. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
745 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
746 |
"Created: 28.12.1995 / 14:22:10 / stefan" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
747 |
"Modified: 5.1.1996 / 22:01:06 / stefan" |
1166
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
748 |
! |
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
749 |
|
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
750 |
unmonitorPid:pid |
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
751 |
"remove a monitor for a child process" |
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
752 |
|
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
753 |
osChildExitActions removeKey:pid ifAbsent:[]. |
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
754 |
|
f5affd8cb289
added #unmonitorPid: - there still is trouble with zombie subchilds, if a process is killed via #killProcess:
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
755 |
"Created: 12.4.1996 / 19:01:59 / cg" |
699 | 756 |
! ! |
757 |
||
758 |
!ProcessorScheduler methodsFor:'primitive process primitives'! |
|
759 |
||
760 |
scheduleForInterrupt:aProcess |
|
761 |
"make aProcess evaluate its pushed interrupt block(s)" |
|
762 |
||
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
763 |
self scheduleInterruptActionsOf:aProcess. |
699 | 764 |
" |
765 |
and, make the process runnable |
|
766 |
" |
|
767 |
aProcess state ~~ #stopped ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
768 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
769 |
and, make the process runnable |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
770 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
771 |
self resume:aProcess |
699 | 772 |
] |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
773 |
|
1473 | 774 |
"Modified: 17.6.1996 / 14:40:52 / cg" |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
775 |
! |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
776 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
777 |
scheduleInterruptActionsOf:aProcess |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
778 |
"make aProcess evaluate its pushed interrupt block(s) |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
779 |
when resumed." |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
780 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
781 |
|id| |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
782 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
783 |
aProcess isNil ifTrue:[^ self]. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
784 |
aProcess == activeProcess ifTrue:[^ self]. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
785 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
786 |
id := aProcess id. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
787 |
self class threadInterrupt:id. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
788 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
789 |
"Created: 5.3.1996 / 17:25:55 / cg" |
699 | 790 |
! |
791 |
||
792 |
threadSwitch:aProcess |
|
793 |
"continue execution in aProcess. |
|
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
794 |
WARNING: this is a low level entry, no process administration is done here" |
699 | 795 |
|
796 |
|id pri ok oldProcess oldPri p singleStep wasBlocked| |
|
797 |
||
798 |
(aProcess isNil or:[aProcess == activeProcess]) ifTrue:[^ self]. |
|
799 |
||
800 |
wasBlocked := OperatingSystem blockInterrupts. |
|
801 |
||
802 |
oldProcess := activeProcess. |
|
803 |
oldPri := currentPriority. |
|
804 |
||
805 |
id := aProcess id. |
|
806 |
pri := aProcess priority. |
|
807 |
singleStep := aProcess isSingleStepping. |
|
808 |
aProcess state:#active. |
|
809 |
oldProcess setStateTo:#run if:#active. |
|
810 |
||
811 |
" |
|
812 |
no interrupts now - activeProcess has already been changed |
|
813 |
(dont add any message sends here) |
|
814 |
" |
|
815 |
activeProcess := aProcess. |
|
816 |
currentPriority := pri. |
|
817 |
%{ |
|
818 |
extern OBJ ___threadSwitch(); |
|
819 |
||
820 |
if (__isSmallInteger(id)) { |
|
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
821 |
ok = ___threadSwitch(__context, __intVal(id), (singleStep == true) ? 1 : 0); |
699 | 822 |
} else { |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
823 |
ok = false; |
699 | 824 |
} |
825 |
%}. |
|
826 |
"time passes spent in some other process ... |
|
827 |
... here again" |
|
828 |
||
829 |
p := activeProcess. |
|
830 |
activeProcess := oldProcess. |
|
831 |
currentPriority := oldProcess priority. |
|
832 |
||
833 |
ok ifFalse:[ |
|
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
834 |
" |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
835 |
switch failed for some reason - |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
836 |
destroy the bad process |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
837 |
" |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
838 |
p id ~~ 0 ifTrue:[ |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
839 |
'Processor [warning]: problem with process ' errorPrint. |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
840 |
p id errorPrint. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
841 |
p name notNil ifTrue:[ |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
842 |
' (' errorPrint. p name errorPrint. ')' errorPrint. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
843 |
]. |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
844 |
'; hard-terminate it.' errorPrintCR. |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
845 |
p state:#suspended. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
846 |
self terminateNoSignal:p. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
847 |
] |
699 | 848 |
]. |
849 |
zombie notNil ifTrue:[ |
|
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
850 |
self class threadDestroy:zombie. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
851 |
zombie := nil |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
852 |
]. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
853 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1787
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
854 |
! ! |
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
855 |
|
1981
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
856 |
!ProcessorScheduler methodsFor:'priority constants'! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
857 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
858 |
highIOPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
859 |
"not currently used - for ST80 compatibility only" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
860 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
861 |
^ 16 "claus: is this ok ?" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
862 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
863 |
"Created: 15.11.1996 / 11:42:39 / cg" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
864 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
865 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
866 |
highestPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
867 |
"return the highest priority value (normal) processes can have." |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
868 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
869 |
"must be below schedulingPriority - |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
870 |
otherwise scheduler could be blocked ... |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
871 |
" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
872 |
^ HighestPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
873 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
874 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
875 |
lowIOPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
876 |
"not currently used - for ST80 compatibility only" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
877 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
878 |
^ 2 "claus: is this ok ?" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
879 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
880 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
881 |
lowestPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
882 |
"return the lowest priority value" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
883 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
884 |
^ 1 "do not change this - its not variable" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
885 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
886 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
887 |
schedulingPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
888 |
"return the priority at which the scheduler runs." |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
889 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
890 |
"must be above highestPriority - |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
891 |
otherwise scheduler could be blocked ... |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
892 |
" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
893 |
^ SchedulingPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
894 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
895 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
896 |
systemBackgroundPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
897 |
"return the priority, at which background system processing |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
898 |
should take place. |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
899 |
Not currently used - for ST80 compatibility only" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
900 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
901 |
^ 4 |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
902 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
903 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
904 |
timingPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
905 |
"return the priority, at which all timing takes place (messageTally, |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
906 |
delay etc.)" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
907 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
908 |
^ TimingPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
909 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
910 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
911 |
userBackgroundPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
912 |
"return the priority, at which background user (non-interactive) processing |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
913 |
should take place. |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
914 |
Not currently used - for ST80 compatibility only" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
915 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
916 |
^ 6 |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
917 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
918 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
919 |
userInterruptPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
920 |
"return the priority, at which the event scheduler runs - i.e. |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
921 |
all processes running at a lower priority are interruptable by Cntl-C |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
922 |
or the timer. Processes running at higher prio will not be interrupted." |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
923 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
924 |
^ UserInterruptPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
925 |
! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
926 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
927 |
userSchedulingPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
928 |
"return the priority, at which all normal user (interactive) processing |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
929 |
takes place" |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
930 |
|
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
931 |
^ UserSchedulingPriority |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
932 |
! ! |
de394714f50b
added #hiIOPriority for protocol completeness
Claus Gittinger <cg@exept.de>
parents:
1836
diff
changeset
|
933 |
|
699 | 934 |
!ProcessorScheduler methodsFor:'private'! |
935 |
||
936 |
remember:aProcess |
|
937 |
"remember aProcess for later disposal (where the underlying |
|
938 |
system resources have to be freed)." |
|
939 |
||
940 |
|newShadow oldId wasBlocked |
|
941 |
oldSize "{ Class: SmallInteger }" |
|
942 |
index "{ Class: SmallInteger }" |
|
1787
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
943 |
sz "{ Class: SmallInteger }" | |
699 | 944 |
|
945 |
wasBlocked := OperatingSystem blockInterrupts. |
|
946 |
index := 1. |
|
947 |
sz := KnownProcessIds size. |
|
948 |
[index <= sz] whileTrue:[ |
|
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
949 |
(KnownProcesses at:index) isNil ifTrue:[ |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
950 |
oldId := KnownProcessIds at:index. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
951 |
oldId notNil ifTrue:[ |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
952 |
self class threadDestroy:oldId. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
953 |
]. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
954 |
KnownProcesses at:index put:aProcess. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
955 |
KnownProcessIds at:index put:aProcess id. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
956 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
957 |
^ self |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
958 |
]. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
959 |
index := index + 1 |
699 | 960 |
]. |
961 |
||
962 |
KnownProcessIds grow:index. |
|
963 |
KnownProcessIds at:index put:aProcess id. |
|
964 |
||
965 |
oldSize := KnownProcesses size. |
|
966 |
(index > oldSize) ifTrue:[ |
|
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
967 |
newShadow := WeakArray new:(oldSize * 2). |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
968 |
newShadow addDependent:self class. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
969 |
newShadow replaceFrom:1 with:KnownProcesses. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
970 |
KnownProcesses := newShadow |
699 | 971 |
]. |
972 |
KnownProcesses at:index put:aProcess. |
|
973 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
974 |
|
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
975 |
"Modified: 7.1.1997 / 16:48:39 / stefan" |
699 | 976 |
! |
977 |
||
978 |
unRemember:aProcess |
|
979 |
"forget aProcess - dispose processing will not consider this one" |
|
980 |
||
981 |
|index wasBlocked| |
|
982 |
||
983 |
wasBlocked := OperatingSystem blockInterrupts. |
|
984 |
index := KnownProcesses identityIndexOf:aProcess. |
|
985 |
index ~~ 0 ifTrue:[ |
|
986 |
KnownProcessIds at:index put:nil. |
|
987 |
KnownProcesses at:index put:nil. |
|
988 |
]. |
|
989 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
990 |
! ! |
|
991 |
||
992 |
!ProcessorScheduler methodsFor:'private initializing'! |
|
993 |
||
994 |
initialize |
|
995 |
"initialize the one-and-only ProcessorScheduler" |
|
996 |
||
997 |
|nPrios "{ Class: SmallInteger }" |
|
1618 | 998 |
p l| |
699 | 999 |
|
1000 |
KnownProcesses isNil ifTrue:[ |
|
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
1001 |
KnownProcesses := WeakArray new:30. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
1002 |
KnownProcesses addDependent:self class. |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
1003 |
KnownProcessIds := OrderedCollection new. |
699 | 1004 |
]. |
1005 |
||
1006 |
" |
|
1007 |
create a collection with process lists; accessed using the priority as key |
|
1008 |
" |
|
1009 |
nPrios := SchedulingPriority. |
|
1010 |
quiescentProcessLists := Array new:nPrios. |
|
1618 | 1011 |
"/ 1 to:nPrios do:[:pri | |
1012 |
"/ quiescentProcessLists at:pri put:(LinkedList new) |
|
1013 |
"/ ]. |
|
699 | 1014 |
|
1015 |
readFdArray := Array with:nil. |
|
1016 |
readCheckArray := Array with:nil. |
|
1017 |
readSemaphoreArray := Array with:nil. |
|
1018 |
writeFdArray := Array with:nil. |
|
1019 |
writeSemaphoreArray := Array with:nil. |
|
1020 |
timeoutArray := Array with:nil. |
|
1021 |
timeoutSemaphoreArray := Array with:nil. |
|
1022 |
timeoutActionArray := Array with:nil. |
|
1023 |
timeoutProcessArray := Array with:nil. |
|
1024 |
anyTimeouts := false. |
|
1025 |
dispatching := false. |
|
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1026 |
exitWhenNoMoreUserProcesses := false. "/ mhmh - how about true ? |
699 | 1027 |
useIOInterrupts := OperatingSystem supportsIOInterrupts. |
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
1028 |
gotIOInterrupt := false. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
1029 |
osChildExitActions := Dictionary new. |
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
1030 |
gotChildSignalInterrupt := false. |
699 | 1031 |
|
1032 |
" |
|
1033 |
handcraft the first (dispatcher-) process - this one will never |
|
1034 |
block, but go into a select if there is nothing to do. |
|
1035 |
Also, it has a prio of max+1 - thus, it comes first when looking |
|
1036 |
for a runnable process. |
|
1037 |
" |
|
1038 |
currentPriority := SchedulingPriority. |
|
1039 |
p := Process new. |
|
1040 |
p setId:0 state:#run. |
|
1041 |
p setPriority:currentPriority. |
|
1042 |
p name:'scheduler'. |
|
1043 |
||
1044 |
scheduler := activeProcess := p. |
|
1045 |
||
1618 | 1046 |
quiescentProcessLists at:currentPriority put:(l := LinkedList new). |
1047 |
l add:p. |
|
699 | 1048 |
|
1049 |
" |
|
1050 |
let me handle IO and timer interrupts |
|
1051 |
" |
|
1052 |
ObjectMemory ioInterruptHandler:self. |
|
1053 |
ObjectMemory timerInterruptHandler:self. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
807
diff
changeset
|
1054 |
ObjectMemory childSignalInterruptHandler:self. |
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
1055 |
|
1618 | 1056 |
"Modified: 29.7.1996 / 12:10:59 / cg" |
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1981
diff
changeset
|
1057 |
"Modified: 7.1.1997 / 16:48:26 / stefan" |
699 | 1058 |
! |
1059 |
||
1060 |
reinitialize |
|
1061 |
"all previous processes (except those marked as restartable) are made dead |
|
1062 |
- each object should reinstall its process(s) upon restart; |
|
1063 |
especially, windowgroups have to. |
|
1064 |
In contrast to ST-80, restartable processes are restarted at the beginning |
|
1065 |
NOT continued where left. This is a consequence of the portable implementation |
|
1066 |
of ST/X, since in order to continue a process, we needed to know the |
|
1067 |
internals of the machines (and C-compilers) stack layout. |
|
1068 |
This was not done, favouring portability for process continuation. |
|
1069 |
In praxis, this is not much of a problem, since in almost every case, |
|
1070 |
the computation state can be saved in some object, and processing be |
|
1071 |
restarted from scratch, reinitializing things from this saved state." |
|
1072 |
||
1073 |
|processesToRestart| |
|
1074 |
||
1075 |
" |
|
1076 |
lay all processes to rest, collect restartable ones |
|
1077 |
" |
|
1078 |
processesToRestart := OrderedCollection new. |
|
1079 |
KnownProcesses do:[:p | |
|
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1080 |
(p notNil and:[p ~~ 0]) ifTrue:[ |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1081 |
"how, exactly should this be done ?" |
699 | 1082 |
|
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1083 |
p isRestartable == true ifTrue:[ |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1084 |
p nextLink:nil. |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1085 |
processesToRestart add:p |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1086 |
] ifFalse:[ |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1087 |
p setId:nil state:#dead |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1088 |
] |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1089 |
]. |
699 | 1090 |
]. |
1091 |
scheduler setId:nil state:#dead. |
|
1092 |
||
1093 |
" |
|
1094 |
now, start from scratch |
|
1095 |
" |
|
1096 |
KnownProcesses := nil. |
|
1097 |
self initialize. |
|
1098 |
||
1099 |
" |
|
1100 |
... and restart those that can be. |
|
1101 |
" |
|
1102 |
processesToRestart do:[:p | |
|
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1103 |
p imageRestart |
699 | 1104 |
] |
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1105 |
|
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1106 |
"Modified: 28.10.1996 / 20:45:54 / cg" |
699 | 1107 |
! ! |
1108 |
||
1109 |
!ProcessorScheduler methodsFor:'process creation'! |
|
1110 |
||
1111 |
newProcessFor:aProcess |
|
1112 |
"create a physical (VM-) process for aProcess. |
|
1113 |
Return true if ok, false if something went wrong. |
|
1114 |
The process is not scheduled; to start it running, |
|
1115 |
it needs a Process>>resume. Once resumed, the process will later |
|
1116 |
get control in its #start method." |
|
1117 |
||
1118 |
|id| |
|
1119 |
||
1120 |
id := self class threadCreate:aProcess withId:nil. |
|
1121 |
id isNil ifTrue:[^ false]. |
|
1122 |
||
1123 |
aProcess setId:id state:#light. "meaning: has no stack yet" |
|
1124 |
self remember:aProcess. |
|
1125 |
^ true |
|
1126 |
! |
|
1127 |
||
1128 |
newProcessFor:aProcess withId:idWant |
|
1129 |
"private entry for Process restart - do not use in your program" |
|
1130 |
||
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1131 |
idWant isNil ifTrue:[ |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1132 |
^ self newProcessFor:aProcess |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1133 |
]. |
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1134 |
|
699 | 1135 |
(self class threadCreate:aProcess withId:idWant) ~~ idWant ifTrue:[ |
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1136 |
^ false |
699 | 1137 |
]. |
1138 |
||
1139 |
aProcess state:#light. "meaning: has no stack yet" |
|
1140 |
self remember:aProcess. |
|
1141 |
^ true |
|
1836
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1142 |
|
08a200835cc8
process restart is different if done at image restart time.
Claus Gittinger <cg@exept.de>
parents:
1793
diff
changeset
|
1143 |
"Modified: 28.10.1996 / 19:14:28 / cg" |
699 | 1144 |
! ! |
1145 |
||
1146 |
!ProcessorScheduler methodsFor:'queries'! |
|
1147 |
||
1148 |
activeProcessIsSystemProcess |
|
1149 |
"return true if the active process is a system process, |
|
1150 |
which should not be suspended." |
|
1151 |
||
1152 |
^ self isSystemProcess:activeProcess |
|
1153 |
||
1154 |
" |
|
1155 |
Processor activeProcessIsSystemProcess |
|
1156 |
" |
|
1157 |
! |
|
1158 |
||
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1159 |
anyUserProcessAtAll |
1571
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1160 |
"return true, if there is any process still running with a |
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1161 |
non-zero processGroup (i.e. any non-system process). |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1162 |
This is used to determine if we should stop scheduling |
1571
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1163 |
in standAlone applications." |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1164 |
|
987 | 1165 |
|listArray l prio "{ Class: SmallInteger }" | |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1166 |
|
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1167 |
prio := HighestPriority. |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1168 |
listArray := quiescentProcessLists. |
1571
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1169 |
|
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1170 |
[prio >= 1] whileTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1171 |
l := listArray at:prio. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1172 |
l notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1173 |
l do:[:aProcess | |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1174 |
aProcess processGroupId ~~ 0 ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1175 |
^ true. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1176 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1177 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1178 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1179 |
prio := prio - 1 |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1180 |
]. |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1181 |
^ false |
1571
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1182 |
|
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1183 |
" |
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1184 |
Processor anyUserProcessAtAll |
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1185 |
" |
8d00e6b97ca7
changed #anyUserProcessAtAll,
Claus Gittinger <cg@exept.de>
parents:
1473
diff
changeset
|
1186 |
|
1618 | 1187 |
"Modified: 29.7.1996 / 11:49:17 / cg" |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1188 |
! |
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
1189 |
|
699 | 1190 |
highestPriorityRunnableProcess |
1191 |
"return the highest prio runnable process" |
|
1192 |
||
1193 |
|listArray l p prio "{ Class: SmallInteger }" | |
|
1194 |
||
1195 |
prio := HighestPriority. |
|
1196 |
listArray := quiescentProcessLists. |
|
1197 |
[prio >= 1] whileTrue:[ |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1198 |
l := listArray at:prio. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1199 |
l notNil ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1200 |
l notEmpty ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1201 |
p := l first. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1202 |
" |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1203 |
if it got corrupted somehow ... |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1204 |
" |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1205 |
p id isNil ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1206 |
'Processor [warning]: process with nil id removed' errorPrintCR. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1207 |
l removeFirst. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1208 |
^ nil. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1209 |
]. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1210 |
^ p |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1211 |
] |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1212 |
]. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1213 |
prio := prio - 1 |
699 | 1214 |
]. |
1215 |
^ nil |
|
1086 | 1216 |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1217 |
"Modified: 10.1.1997 / 18:03:28 / cg" |
699 | 1218 |
! |
1219 |
||
1177 | 1220 |
isPureEventDriven |
1221 |
"this is temporary - (maybe not :-). |
|
1222 |
you can run ST/X either with or without processes. |
|
1223 |
Without, there is conceptionally a single process handling all |
|
1224 |
outside events and timeouts. This has some negative implications |
|
1225 |
(Debugger is ugly), but allows a fully portable ST/X without any |
|
1226 |
assembler support - i.e. quick portability. |
|
1227 |
The PureEvent flag will automatically be set if the runtime system |
|
1228 |
does not support threads - otherwise, it can be set manually |
|
1229 |
(from rc-file). |
|
1230 |
" |
|
1231 |
||
1232 |
^ PureEventDriven |
|
1233 |
||
1234 |
"Created: 13.4.1996 / 20:31:31 / cg" |
|
1235 |
! |
|
1236 |
||
699 | 1237 |
isSystemProcess:aProcess |
1238 |
"return true if aProcess is a system process, |
|
1239 |
which should not be suspended/terminated etc.." |
|
1240 |
||
1177 | 1241 |
(PureEventDriven |
699 | 1242 |
or:[aProcess id == 0 |
1243 |
or:[(Display notNil and:[Display dispatchProcess == aProcess]) |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1244 |
" nameOrId endsWith:'dispatcher' " |
699 | 1245 |
]]) ifTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1246 |
^ true |
699 | 1247 |
]. |
1248 |
^ false |
|
1249 |
||
1250 |
" |
|
1251 |
Processor activeProcessIsSystemProcess |
|
1252 |
" |
|
1177 | 1253 |
|
1254 |
"Modified: 13.4.1996 / 20:35:00 / cg" |
|
699 | 1255 |
! ! |
1256 |
||
1257 |
!ProcessorScheduler methodsFor:'scheduling'! |
|
1258 |
||
1259 |
changePriority:prio for:aProcess |
|
1260 |
"change the priority of aProcess" |
|
1261 |
||
1262 |
|oldList newList oldPrio newPrio wasBlocked| |
|
1263 |
||
1264 |
oldPrio := aProcess priority. |
|
1265 |
oldPrio == prio ifTrue:[^ self]. |
|
1042 | 1266 |
aProcess == scheduler ifTrue:[^ self]. |
699 | 1267 |
|
1268 |
" |
|
1269 |
check for valid argument |
|
1270 |
" |
|
1271 |
newPrio := prio. |
|
1272 |
newPrio < 1 ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1273 |
newPrio := 1. |
699 | 1274 |
] ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1275 |
newPrio > HighestPriority ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1276 |
newPrio := HighestPriority |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1277 |
] |
699 | 1278 |
]. |
1279 |
||
1042 | 1280 |
[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1281 |
wasBlocked := OperatingSystem blockInterrupts. |
699 | 1282 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1283 |
aProcess setPriority:newPrio. |
699 | 1284 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1285 |
oldList := quiescentProcessLists at:oldPrio. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1286 |
oldList notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1287 |
(oldList identityIndexOf:aProcess) ~~ 0 ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1288 |
oldList remove:aProcess. |
699 | 1289 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1290 |
newList := quiescentProcessLists at:newPrio. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1291 |
newList isNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1292 |
quiescentProcessLists at:newPrio put:(newList := LinkedList new). |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1293 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1294 |
newList addLast:aProcess. |
1042 | 1295 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1296 |
"if its the current process lowering its prio |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1297 |
or another one raising, we have to reschedule" |
699 | 1298 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1299 |
aProcess == activeProcess ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1300 |
currentPriority := newPrio. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1301 |
newPrio < oldPrio ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1302 |
self threadSwitch:scheduler. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1303 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1304 |
] ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1305 |
newPrio > currentPriority ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1306 |
self threadSwitch:aProcess. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1307 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1308 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1309 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1310 |
] |
1042 | 1311 |
] valueNowOrOnUnwindDo:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1312 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1042 | 1313 |
] |
1032 | 1314 |
|
1618 | 1315 |
"Modified: 29.7.1996 / 12:11:57 / cg" |
699 | 1316 |
! |
1317 |
||
1318 |
interruptActive |
|
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
1319 |
"interrupt the current process |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
1320 |
- this message is sent by the VM, when a process is about to be switched to, |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
1321 |
and that process has the interrupted flag bit set. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
1322 |
Pass the interrupt to the process, which may do whatever it likes with it." |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
1323 |
|
1791 | 1324 |
|s| |
1325 |
||
1326 |
"/ hide those intermediate scheduler contexts; |
|
1327 |
"/ the interrupt block should think it was called right |
|
1328 |
"/ from the originally interrupted context |
|
1329 |
||
1330 |
s := thisContext sender. |
|
1331 |
s selector == #threadSwitch: ifTrue:[ |
|
1332 |
s := s sender. |
|
1333 |
s selector == #timerInterrupt ifTrue:[ |
|
1334 |
s := s sender |
|
1335 |
] |
|
1336 |
]. |
|
1337 |
||
1793 | 1338 |
activeProcess interruptedIn:s |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
1339 |
|
1793 | 1340 |
"Modified: 20.10.1996 / 17:06:48 / cg" |
699 | 1341 |
! |
1342 |
||
1343 |
processTermination |
|
1344 |
"sent by VM if the current process finished its startup block |
|
1345 |
without proper process termination. Lay him to rest now. |
|
1346 |
This can only happen, if something went wrong in Block>>newProcess, |
|
1347 |
since the block defined there always terminates itself." |
|
1348 |
||
1349 |
self terminateNoSignal:activeProcess. |
|
1350 |
self threadSwitch:scheduler |
|
1351 |
! |
|
1352 |
||
1353 |
reschedule |
|
1354 |
"switch to the highest prio runnable process. |
|
1355 |
The scheduler itself is always runnable, so we can do an unconditional switch |
|
1356 |
to that one. This method is a historical left-over and will vanish." |
|
1357 |
||
1358 |
^ self threadSwitch:scheduler |
|
1359 |
! |
|
1360 |
||
1361 |
resume:aProcess |
|
1362 |
"set aProcess runnable - |
|
1363 |
if its prio is higher than the currently running prio, switch to it." |
|
1364 |
||
1365 |
|l pri wasBlocked| |
|
1366 |
||
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1367 |
"ignore, if process is already dead" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1368 |
(aProcess isNil or:[aProcess id isNil]) ifTrue:[^ self]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1369 |
|
699 | 1370 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1371 |
aProcess == activeProcess ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1372 |
"special handling for waiting schedulers" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1373 |
aProcess == scheduler ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1374 |
suspendScheduler := false. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1375 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1376 |
^ self |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1377 |
]. |
699 | 1378 |
|
1379 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1380 |
||
1381 |
pri := aProcess priority. |
|
1382 |
||
1383 |
l := quiescentProcessLists at:pri. |
|
1384 |
"if already running, ignore" |
|
1618 | 1385 |
l notNil ifTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1386 |
(l identityIndexOf:aProcess) ~~ 0 ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1387 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1388 |
^ self |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1389 |
] |
1618 | 1390 |
] ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1391 |
l := LinkedList new. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1392 |
quiescentProcessLists at:pri put:l. |
699 | 1393 |
]. |
1394 |
l addLast:aProcess. |
|
1395 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1396 |
||
1397 |
(pri > currentPriority) ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1398 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1399 |
its prio is higher; immediately transfer control to it |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1400 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1401 |
self threadSwitch:aProcess |
699 | 1402 |
] ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1403 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1404 |
its prio is lower; it will have to wait for a while ... |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1405 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1406 |
aProcess state:#run |
699 | 1407 |
] |
1618 | 1408 |
|
1409 |
"Modified: 29.7.1996 / 12:07:37 / cg" |
|
699 | 1410 |
! |
1411 |
||
1412 |
resumeForSingleSend:aProcess |
|
1413 |
"like resume, but let the process execute a single send only. |
|
1414 |
This will be used by the (new, not yet released) debugger |
|
1415 |
for single stepping." |
|
1416 |
||
1417 |
(aProcess isNil or:[aProcess == activeProcess]) ifTrue:[^ self]. |
|
1418 |
aProcess singleStep:true. |
|
1419 |
self resume:aProcess |
|
1420 |
! |
|
1421 |
||
1422 |
suspend:aProcess |
|
1423 |
"remove the argument, aProcess from the list of runnable processes. |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
1424 |
If the process is the current one, reschedule. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
1425 |
This method should only be called by Process>>suspend" |
699 | 1426 |
|
1427 |
|pri l p wasBlocked| |
|
1428 |
||
1429 |
" |
|
1430 |
some debugging stuff |
|
1431 |
" |
|
1432 |
aProcess isNil ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1433 |
InvalidProcessSignal raiseWith:aProcess errorString:'PROCESSOR: nil suspend'. |
1618 | 1434 |
^ self |
699 | 1435 |
]. |
1436 |
aProcess id isNil ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1437 |
InvalidProcessSignal raiseWith:aProcess errorString:'PROCESSOR: bad suspend: already dead'. |
1618 | 1438 |
self threadSwitch:scheduler. |
1439 |
^ self |
|
699 | 1440 |
]. |
1441 |
aProcess == scheduler ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1442 |
"only scheduler may suspend itself" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1443 |
activeProcess == scheduler ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1444 |
suspendScheduler := true. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1445 |
[suspendScheduler] whileTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1446 |
self dispatch. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1447 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1448 |
^ self |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1449 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1450 |
|
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1451 |
InvalidProcessSignal raiseWith:aProcess errorString:'PROCESSOR: scheduler should never be suspended'. |
1618 | 1452 |
^ self |
699 | 1453 |
]. |
1454 |
||
1455 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1456 |
||
1457 |
pri := aProcess priority. |
|
1458 |
l := quiescentProcessLists at:pri. |
|
1459 |
||
1460 |
"notice: this is slightly faster than putting the if-code into |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
1461 |
the ifAbsent block, because [] is a shared cheap block, created at compile time |
699 | 1462 |
" |
1618 | 1463 |
(l isNil or:[(l remove:aProcess ifAbsent:[]) isNil]) ifTrue:[ |
1464 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1465 |
'Processor [warning]: bad suspend: not on run list' errorPrintCR. |
1618 | 1466 |
"/ MiniDebugger enterWithMessage:'bad suspend: not on run list'. |
1467 |
self threadSwitch:scheduler. |
|
1468 |
^ self |
|
699 | 1469 |
]. |
1470 |
||
1471 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1472 |
||
1473 |
(aProcess == activeProcess) ifTrue:[ |
|
1618 | 1474 |
"we can immediately switch sometimes" |
1475 |
l notEmpty ifTrue:[ |
|
1476 |
p := l first |
|
1477 |
] ifFalse:[ |
|
1478 |
p := scheduler |
|
1479 |
]. |
|
1480 |
self threadSwitch:p |
|
699 | 1481 |
]. |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
750
diff
changeset
|
1482 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1483 |
"Modified: 23.9.1996 / 13:49:24 / stefan" |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1484 |
"Modified: 10.1.1997 / 18:04:01 / cg" |
699 | 1485 |
! |
1486 |
||
1487 |
terminate:aProcess |
|
1488 |
"terminate aProcess. This is donen by sending aProcess the terminateSignal, |
|
1489 |
which will evaluate any unwind blocks and finally do a hard terminate." |
|
1490 |
||
1491 |
aProcess terminate |
|
1492 |
! |
|
1493 |
||
1494 |
terminateActive |
|
1495 |
"terminate the current process (i.e. the running process kills itself). |
|
1496 |
The active process is sent the terminateSignal so it will evaluate any |
|
1497 |
unwind blocks and finally do a hard terminate. |
|
1498 |
This is sent for regular termination and by the VM, if the hard-stack limit |
|
1499 |
is reached. (i.e. a process did not repair things in a recursionInterrupt and |
|
1500 |
continued to grow its stack)" |
|
1501 |
||
1502 |
activeProcess terminate |
|
1503 |
! |
|
1504 |
||
1505 |
terminateActiveNoSignal |
|
1506 |
"hard terminate the active process, without sending any |
|
1507 |
terminate signal thus no unwind blocks are evaluated." |
|
1508 |
||
1509 |
self terminateNoSignal:activeProcess |
|
1510 |
! |
|
1511 |
||
1512 |
terminateNoSignal:aProcess |
|
1513 |
"hard terminate aProcess without sending the terminate signal, thus |
|
1514 |
no unwind blocks or exitAction are performed in the process.. |
|
1515 |
If its not the current process, it is simply removed from its list |
|
1516 |
and physically destroyed. Otherwise (since we can't take away the chair |
|
1517 |
we are sitting on), a switch is forced and the process |
|
1518 |
will be physically destroyed by the next running process. |
|
1519 |
(see zombie handling)" |
|
1520 |
||
1521 |
|pri id l wasBlocked| |
|
1522 |
||
1523 |
aProcess isNil ifTrue:[^ self]. |
|
807
e51ce11ca948
and dont allow quickTerminate as well.
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
1524 |
aProcess == scheduler ifTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1525 |
InvalidProcessSignal raiseWith:aProcess errorString:'PROCESSOR: I will not terminate scheduler'. |
1618 | 1526 |
^ self |
807
e51ce11ca948
and dont allow quickTerminate as well.
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
1527 |
]. |
e51ce11ca948
and dont allow quickTerminate as well.
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
1528 |
|
699 | 1529 |
id := aProcess id. |
1530 |
id isNil ifTrue:[^ self]. "already dead" |
|
1531 |
||
1532 |
aProcess setId:nil state:#dead. |
|
1533 |
||
1534 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1535 |
||
1536 |
"remove the process from the runnable list" |
|
1537 |
||
1538 |
pri := aProcess priority. |
|
1539 |
l := quiescentProcessLists at:pri. |
|
1540 |
(l identityIndexOf:aProcess) ~~ 0 ifTrue:[ |
|
1618 | 1541 |
l remove:aProcess. |
1542 |
l isEmpty ifTrue:[ |
|
1543 |
quiescentProcessLists at:pri put:nil |
|
1544 |
] |
|
699 | 1545 |
]. |
1546 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1547 |
||
1548 |
aProcess == activeProcess ifTrue:[ |
|
1618 | 1549 |
" |
1550 |
hard case - its the currently running process |
|
1551 |
we must have the next active process destroy this one |
|
1552 |
(we cannot destroy the chair we are sitting on ... :-) |
|
1553 |
" |
|
1554 |
zombie := id. |
|
1555 |
self unRemember:aProcess. |
|
1556 |
self threadSwitch:scheduler. |
|
1557 |
"not reached" |
|
1558 |
^ self |
|
699 | 1559 |
]. |
1560 |
self class threadDestroy:id. |
|
1561 |
self unRemember:aProcess. |
|
1562 |
^ self |
|
1618 | 1563 |
|
1564 |
"Modified: 29.7.1996 / 11:56:08 / cg" |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
1565 |
"Modified: 23.9.1996 / 13:50:24 / stefan" |
699 | 1566 |
! |
1567 |
||
1568 |
yield |
|
1569 |
"move the currently running process to the end of the currentList |
|
1570 |
and reschedule to the first in the list, thus switching to the |
|
1571 |
next same-prio-process." |
|
1572 |
||
1618 | 1573 |
|l sz wasBlocked| |
699 | 1574 |
|
1575 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1576 |
||
1577 |
" |
|
1578 |
debugging consistency check - will be removed later |
|
1579 |
" |
|
1580 |
activeProcess priority ~~ currentPriority ifTrue:[ |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1581 |
'Processor [warning]: process changed its priority' errorPrintCR. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1582 |
currentPriority := activeProcess priority. |
699 | 1583 |
]. |
1584 |
||
1585 |
l := quiescentProcessLists at:currentPriority. |
|
1618 | 1586 |
sz := l size. |
699 | 1587 |
|
1588 |
" |
|
1589 |
debugging consistency checks - will be removed later |
|
1590 |
" |
|
1618 | 1591 |
sz == 0 ifTrue:[ |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1592 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1593 |
'Processor [warning]: empty runnable list' errorPrintCR. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1594 |
^ self |
699 | 1595 |
]. |
1596 |
||
1597 |
" |
|
1598 |
check if the running process is not the only one |
|
1599 |
" |
|
1618 | 1600 |
sz ~~ 1 ifTrue:[ |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1601 |
" |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1602 |
bring running process to the end |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1603 |
" |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1604 |
l removeFirst. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1605 |
l addLast:activeProcess. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1606 |
|
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1607 |
" |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1608 |
and switch to first in the list |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1609 |
" |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1610 |
self threadSwitch:(l first). |
699 | 1611 |
]. |
1612 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1086 | 1613 |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
1614 |
"Modified: 10.1.1997 / 18:04:35 / cg" |
699 | 1615 |
! ! |
1616 |
||
1617 |
!ProcessorScheduler methodsFor:'semaphore signalling'! |
|
1618 |
||
1619 |
disableSemaphore:aSemaphore |
|
1620 |
"disable triggering of a semaphore" |
|
1621 |
||
1622 |
|idx "{ Class: SmallInteger }" |
|
1623 |
wasBlocked| |
|
1624 |
||
1625 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1626 |
idx := readSemaphoreArray identityIndexOf:aSemaphore startingAt:1. |
|
1627 |
[idx ~~ 0] whileTrue:[ |
|
1628 |
readFdArray at:idx put:nil. |
|
1629 |
readSemaphoreArray at:idx put:nil. |
|
1630 |
readCheckArray at:idx put:nil. |
|
1631 |
idx := readSemaphoreArray identityIndexOf:aSemaphore startingAt:idx. |
|
1632 |
]. |
|
1633 |
idx := writeSemaphoreArray identityIndexOf:aSemaphore startingAt:1. |
|
1634 |
[idx ~~ 0] whileTrue:[ |
|
1635 |
writeFdArray at:idx put:nil. |
|
1636 |
writeSemaphoreArray at:idx put:nil. |
|
1637 |
idx := writeSemaphoreArray identityIndexOf:aSemaphore startingAt:idx. |
|
1638 |
]. |
|
1639 |
idx := timeoutSemaphoreArray identityIndexOf:aSemaphore startingAt:1. |
|
1640 |
[idx ~~ 0] whileTrue:[ |
|
1641 |
timeoutArray at:idx put:nil. |
|
1642 |
timeoutSemaphoreArray at:idx put:nil. |
|
1643 |
timeoutActionArray at:idx put:nil. |
|
1644 |
timeoutProcessArray at:idx put:nil. |
|
1645 |
idx := timeoutSemaphoreArray identityIndexOf:aSemaphore startingAt:idx. |
|
1646 |
]. |
|
1647 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1648 |
! |
|
1649 |
||
1683 | 1650 |
signal:aSemaphore |
1651 |
"arrange for a semaphore to be triggered as soon as possible. |
|
1652 |
The actual signalling is performed slightly delayed, when the dispatcher |
|
1653 |
looks for a process to resume. |
|
1654 |
This is provided as entry for primitive code using __STX_SignalSemaphore(). |
|
1655 |
Normal smalltalk code should send an appropriate message directly |
|
1656 |
to the semaphore." |
|
1657 |
||
1658 |
|now wasBlocked| |
|
1659 |
||
1660 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1661 |
now := OperatingSystem getMillisecondTime. |
|
1662 |
self signal:aSemaphore atMilliseconds:now. |
|
1663 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1664 |
||
1665 |
"Created: 24.9.1996 / 10:18:45 / cg" |
|
1666 |
! |
|
1667 |
||
699 | 1668 |
signal:aSemaphore afterMilliseconds:millis |
1669 |
"arrange for a semaphore to be triggered after some milliseconds" |
|
1670 |
||
1671 |
|now then wasBlocked| |
|
1672 |
||
1673 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1674 |
now := OperatingSystem getMillisecondTime. |
|
1675 |
then := OperatingSystem millisecondTimeAdd:now and:millis rounded. |
|
1676 |
self signal:aSemaphore atMilliseconds:then. |
|
1677 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1678 |
! |
|
1679 |
||
1680 |
signal:aSemaphore afterSeconds:seconds |
|
1681 |
"arrange for a semaphore to be triggered after some seconds" |
|
1682 |
||
1683 |
self signal:aSemaphore afterMilliseconds:(seconds * 1000) |
|
1684 |
! |
|
1685 |
||
1686 |
signal:aSemaphore atMilliseconds:aMillisecondTime |
|
1687 |
"arrange for a semaphore to be triggered at a specific millisecond time. |
|
1688 |
If there is already a pending trigger time, the time is changed." |
|
1689 |
||
1690 |
|index "{ Class: SmallInteger }" |
|
1691 |
wasBlocked| |
|
1692 |
||
1693 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1694 |
index := timeoutSemaphoreArray identityIndexOf:aSemaphore startingAt:1. |
|
1695 |
index ~~ 0 ifTrue:[ |
|
1696 |
timeoutArray at:index put:aMillisecondTime |
|
1697 |
] ifFalse:[ |
|
1698 |
index := timeoutArray identityIndexOf:nil startingAt:1. |
|
1699 |
index ~~ 0 ifTrue:[ |
|
1700 |
timeoutSemaphoreArray at:index put:aSemaphore. |
|
1701 |
timeoutArray at:index put:aMillisecondTime. |
|
1702 |
timeoutActionArray at:index put:nil. |
|
1703 |
timeoutProcessArray at:index put:nil |
|
1704 |
] ifFalse:[ |
|
1705 |
timeoutSemaphoreArray := timeoutSemaphoreArray copyWith:aSemaphore. |
|
1706 |
timeoutArray := timeoutArray copyWith:aMillisecondTime. |
|
1707 |
timeoutActionArray := timeoutActionArray copyWith:nil. |
|
1708 |
timeoutProcessArray := timeoutProcessArray copyWith:nil |
|
1709 |
]. |
|
1710 |
]. |
|
1711 |
||
1712 |
anyTimeouts := true. |
|
1713 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1714 |
! |
|
1715 |
||
1716 |
signal:aSemaphore onInput:aFileDescriptor |
|
1717 |
"arrange for a semaphore to be triggered when input on aFileDescriptor |
|
1718 |
arrives." |
|
1719 |
||
1720 |
self signal:aSemaphore onInput:aFileDescriptor orCheck:nil |
|
1721 |
! |
|
1722 |
||
1723 |
signal:aSemaphore onInput:aFileDescriptor orCheck:aBlock |
|
1724 |
"arrange for a semaphore to be triggered when input on aFileDescriptor |
|
1725 |
arrives OR checkblock evaluates to true. |
|
1726 |
(checkBlock is used for buffered input, where a select may not detect |
|
1727 |
data already read into a buffer - as in Xlib)" |
|
1728 |
||
1729 |
|idx "{ Class: SmallInteger }" |
|
1730 |
wasBlocked| |
|
1731 |
||
1627
f95285226059
infoPrint for NT (no select)
Claus Gittinger <cg@exept.de>
parents:
1618
diff
changeset
|
1732 |
aFileDescriptor isNil ifTrue:[ |
2123 | 1733 |
'ProcessorScheduler [info]: no fd to select on - polling with checkBlock' infoPrintCR |
1627
f95285226059
infoPrint for NT (no select)
Claus Gittinger <cg@exept.de>
parents:
1618
diff
changeset
|
1734 |
]. |
f95285226059
infoPrint for NT (no select)
Claus Gittinger <cg@exept.de>
parents:
1618
diff
changeset
|
1735 |
|
699 | 1736 |
wasBlocked := OperatingSystem blockInterrupts. |
1737 |
(readFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
|
2123 | 1738 |
idx := readFdArray identityIndexOf:nil startingAt:1. |
1739 |
idx ~~ 0 ifTrue:[ |
|
1740 |
readFdArray at:idx put:aFileDescriptor. |
|
1741 |
readSemaphoreArray at:idx put:aSemaphore. |
|
1742 |
readCheckArray at:idx put:aBlock |
|
1743 |
] ifFalse:[ |
|
1744 |
readFdArray := readFdArray copyWith:aFileDescriptor. |
|
1745 |
readSemaphoreArray := readSemaphoreArray copyWith:aSemaphore. |
|
1746 |
readCheckArray := readCheckArray copyWith:aBlock. |
|
1747 |
] |
|
699 | 1748 |
]. |
1749 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
2123 | 1750 |
|
1751 |
"Modified: 10.1.1997 / 15:09:41 / cg" |
|
699 | 1752 |
! |
1753 |
||
1754 |
signal:aSemaphore onOutput:aFileDescriptor |
|
1755 |
"arrange for a semaphore to be triggered when output on aFileDescriptor |
|
1756 |
is possible. (i.e. can be written without blocking)" |
|
1757 |
||
1758 |
|idx "{ Class: SmallInteger }" |
|
1759 |
wasBlocked| |
|
1760 |
||
1761 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1762 |
(writeFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
|
1763 |
idx := writeFdArray identityIndexOf:nil startingAt:1. |
|
1764 |
idx ~~ 0 ifTrue:[ |
|
1765 |
writeFdArray at:idx put:aFileDescriptor. |
|
1766 |
writeSemaphoreArray at:idx put:aSemaphore. |
|
1767 |
] ifFalse:[ |
|
1768 |
writeFdArray := writeFdArray copyWith:aFileDescriptor. |
|
1769 |
writeSemaphoreArray := writeSemaphoreArray copyWith:aSemaphore. |
|
1770 |
] |
|
1771 |
]. |
|
1772 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1773 |
! ! |
|
1774 |
||
1775 |
!ProcessorScheduler methodsFor:'timeout handling'! |
|
1776 |
||
1777 |
addTimedBlock:aBlock afterMilliseconds:delta |
|
1778 |
"add the argument, aBlock to the list of time-scheduled-blocks; to be |
|
1779 |
evaluated after delta milliseconds. The process which installs this timed |
|
1780 |
block will be interrupted for execution of the block. |
|
1781 |
(if it is running, the interrupt will occur in whatever method it is |
|
1782 |
executing; if it is suspended, it will be resumed). |
|
1783 |
The block will be removed from the timed-block list after evaluation |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1784 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1785 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
699 | 1786 |
|
1787 |
^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:delta |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1788 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1789 |
"Modified: 23.9.1996 / 14:33:59 / cg" |
699 | 1790 |
! |
1791 |
||
1792 |
addTimedBlock:aBlock afterSeconds:delta |
|
1793 |
"add the argument, aBlock to the list of time-scheduled-blocks. |
|
1794 |
to be evaluated after delta seconds. The process which installs this timed |
|
1795 |
block will be interrupted for execution of the block. |
|
1796 |
(if it is running, the interrupt will occur in whatever method it is |
|
1797 |
executing; if it is suspended, it will be resumed). |
|
1798 |
The block will be removed from the timed-block list after evaluation |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1799 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1800 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
699 | 1801 |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1802 |
^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:(delta * 1000) rounded |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1803 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1804 |
"Modified: 23.9.1996 / 14:34:04 / cg" |
699 | 1805 |
! |
1806 |
||
1807 |
addTimedBlock:aBlock atMilliseconds:aMillisecondTime |
|
1808 |
"add the argument, aBlock to the list of time-scheduled-blocks; to be |
|
1809 |
evaluated when the millisecondClock value passes aMillisecondTime. |
|
1810 |
The process which installs this timed block will be interrupted for |
|
1811 |
execution of the block. |
|
1812 |
(if it is running, the interrupt will occur in whatever method it is |
|
1813 |
executing; if it is suspended, it will be resumed). |
|
1814 |
The block will be removed from the timed-block list after evaluation |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1815 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1816 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
699 | 1817 |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1818 |
^ self addTimedBlock:aBlock for:activeProcess atMilliseconds:aMillisecondTime |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1819 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1820 |
"Modified: 23.9.1996 / 14:34:09 / cg" |
699 | 1821 |
! |
1822 |
||
1823 |
addTimedBlock:aBlock for:aProcess afterMilliseconds:delta |
|
1824 |
"add the argument, aBlock to the list of time-scheduled-blocks; to be |
|
1825 |
evaluated after delta milliseconds. The process specified by the argument, |
|
1826 |
aProcess will be interrupted for execution of the block. |
|
1827 |
(if it is running, the interrupt will occur in whatever method it is |
|
1828 |
executing; if it is suspended, it will be resumed). |
|
1829 |
If aProcess is nil, the block will be evaluated by the scheduler itself |
|
1830 |
(which is dangerous - the block should not raise any error conditions). |
|
1831 |
The block will be removed from the timed-block list after evaluation |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1832 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1833 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
699 | 1834 |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1835 |
|now then wasBlocked id| |
699 | 1836 |
|
1837 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1838 |
now := OperatingSystem getMillisecondTime. |
|
1839 |
then := OperatingSystem millisecondTimeAdd:now and:delta. |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1840 |
id := self addTimedBlock:aBlock for:aProcess atMilliseconds:then. |
699 | 1841 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1842 |
^ id |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1843 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1844 |
"Modified: 23.9.1996 / 14:34:13 / cg" |
699 | 1845 |
! |
1846 |
||
1847 |
addTimedBlock:aBlock for:aProcess afterSeconds:delta |
|
1848 |
"add the argument, aBlock to the list of time-scheduled-blocks. |
|
1849 |
to be evaluated after delta seconds. aProcess will be interrupted for |
|
1850 |
execution of the block. |
|
1851 |
(if it is running, the interrupt will occur in whatever method it is |
|
1852 |
executing; if it is suspended, it will be resumed). |
|
1853 |
If aProcess is nil, the block will be evaluated by the scheduler itself |
|
1854 |
(which is dangerous - the block should not raise any error conditions). |
|
1855 |
The block will be removed from the timed-block list after evaluation |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1856 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1857 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
699 | 1858 |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1859 |
^ self addTimedBlock:aBlock for:aProcess afterMilliseconds:(delta * 1000) rounded |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1860 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1861 |
"Modified: 23.9.1996 / 14:34:18 / cg" |
699 | 1862 |
! |
1863 |
||
1864 |
addTimedBlock:aBlock for:aProcess atMilliseconds:aMillisecondTime |
|
1865 |
"add the argument, aBlock to the list of time-scheduled-blocks; to be |
|
1866 |
evaluated by aProcess when the millisecondClock value passes |
|
1867 |
aMillisecondTime. |
|
1868 |
If that block is already in the timeout list, |
|
1869 |
its trigger-time is changed. |
|
1870 |
The process specified by the argument, aProcess will be interrupted |
|
1871 |
for execution of the block. |
|
1872 |
If aProcess is nil, the block will be evaluated by the scheduler itself |
|
1873 |
(which is dangerous - the block should not raise any error conditions). |
|
1874 |
If the process is active at trigger time, the interrupt will occur in |
|
1875 |
whatever method it is executing; if suspended at trigger time, it will be |
|
1876 |
resumed. |
|
1877 |
The block will be removed from the timed-block list after evaluation |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1878 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1879 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
699 | 1880 |
|
1881 |
|index "{ Class: SmallInteger }" |
|
1882 |
wasBlocked| |
|
1883 |
||
1884 |
wasBlocked := OperatingSystem blockInterrupts. |
|
1885 |
index := timeoutActionArray identityIndexOf:aBlock startingAt:1. |
|
1886 |
index ~~ 0 ifTrue:[ |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1887 |
timeoutArray at:index put:aMillisecondTime |
699 | 1888 |
] ifFalse:[ |
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1889 |
index := timeoutArray indexOf:nil. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1890 |
index ~~ 0 ifTrue:[ |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1891 |
timeoutArray at:index put:aMillisecondTime. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1892 |
timeoutActionArray at:index put:aBlock. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1893 |
timeoutSemaphoreArray at:index put:nil. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1894 |
timeoutProcessArray at:index put:aProcess |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1895 |
] ifFalse:[ |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1896 |
timeoutArray := timeoutArray copyWith:aMillisecondTime. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1897 |
timeoutActionArray := timeoutActionArray copyWith:aBlock. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1898 |
timeoutSemaphoreArray := timeoutSemaphoreArray copyWith:nil. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1899 |
timeoutProcessArray := timeoutProcessArray copyWith:aProcess. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1900 |
index := timeoutArray size. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1901 |
]. |
699 | 1902 |
]. |
1903 |
||
1904 |
anyTimeouts := true. |
|
1905 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1906 |
^ index |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1907 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1908 |
"Modified: 23.9.1996 / 14:34:23 / cg" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1909 |
! |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1910 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1911 |
addTimeoutFunctionCall:anExternalFunction for:aProcess afterMilliseconds:delta with:argument |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1912 |
"prepare for an external function to be called with a single argument |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1913 |
after some millisecond-Delay. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1914 |
If aProcess is nil, the block will be evaluated by the scheduler itself, |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1915 |
otherwise, that process will be interrupted and the function is performed |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1916 |
in this processes context. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1917 |
The callBack will be removed from the timed-block list after evaluation |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1918 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1919 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1920 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1921 |
|now then wasBlocked id| |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1922 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1923 |
wasBlocked := OperatingSystem blockInterrupts. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1924 |
now := OperatingSystem getMillisecondTime. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1925 |
then := OperatingSystem millisecondTimeAdd:now and:delta. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1926 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1927 |
id := self |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1928 |
addTimeoutFunctionCall:anExternalFunction |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1929 |
for:aProcess |
1681 | 1930 |
atMilliseconds:then |
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1931 |
with:argument. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1932 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1933 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1934 |
^ id |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1935 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1936 |
"Created: 23.9.1996 / 14:28:27 / cg" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1937 |
"Modified: 23.9.1996 / 14:34:42 / cg" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1938 |
! |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1939 |
|
1681 | 1940 |
addTimeoutFunctionCall:anExternalFunction for:aProcess atMilliseconds:milliTime with:argument |
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1941 |
"prepare for an external function to be called with a single argument |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1942 |
at some millisecond-time. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1943 |
If aProcess is nil, the block will be evaluated by the scheduler itself, |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1944 |
otherwise, that process will be interrupted and the function is performed |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1945 |
in this processes context. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1946 |
The callBack will be removed from the timed-block list after evaluation |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1947 |
(i.e. it will trigger only once). |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1948 |
Returns an ID, which can be used in #removeTimeoutWidthID:" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1949 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1950 |
|action| |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1951 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1952 |
action := [anExternalFunction callWith:argument]. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1953 |
^ self |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1954 |
addTimedBlock:action |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1955 |
for:aProcess |
1681 | 1956 |
atMilliseconds:milliTime. |
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1957 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1958 |
"Created: 23.9.1996 / 14:29:30 / cg" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
1959 |
"Modified: 23.9.1996 / 14:34:57 / cg" |
699 | 1960 |
! |
1961 |
||
1962 |
evaluateTimeouts |
|
1963 |
"walk through timeouts and evaluate blocks or signal semas that need to be .." |
|
1964 |
||
1965 |
|sema now aTime block blocksToEvaluate |
|
1966 |
processes n "{ Class: SmallInteger }"| |
|
1967 |
||
1968 |
anyTimeouts ifFalse:[ ^ self]. |
|
1969 |
||
1970 |
"have to collect the blocks first, then evaluate them. This avoids |
|
1971 |
problems due to newly inserted blocks." |
|
1972 |
||
1973 |
now := OperatingSystem getMillisecondTime. |
|
1974 |
blocksToEvaluate := nil. |
|
1975 |
n := timeoutArray size. |
|
1976 |
anyTimeouts := false. |
|
1977 |
1 to:n do:[:index | |
|
1978 |
aTime := timeoutArray at:index. |
|
1979 |
aTime notNil ifTrue:[ |
|
1980 |
(OperatingSystem millisecondTime:aTime isAfter:now) ifFalse:[ |
|
1981 |
"this one should be triggered" |
|
1982 |
||
1983 |
sema := timeoutSemaphoreArray at:index. |
|
1984 |
sema notNil ifTrue:[ |
|
1985 |
sema signalOnce. |
|
1986 |
timeoutSemaphoreArray at:index put:nil |
|
1987 |
] ifFalse:[ |
|
1988 |
"to support pure-events" |
|
1989 |
block := timeoutActionArray at:index. |
|
1990 |
block notNil ifTrue:[ |
|
1991 |
blocksToEvaluate isNil ifTrue:[ |
|
1992 |
blocksToEvaluate := OrderedCollection new:10. |
|
1993 |
processes := OrderedCollection new:10. |
|
1994 |
]. |
|
1995 |
blocksToEvaluate add:block. |
|
1996 |
processes add:(timeoutProcessArray at:index). |
|
1997 |
timeoutActionArray at:index put:nil. |
|
1998 |
timeoutProcessArray at:index put:nil. |
|
1999 |
] |
|
2000 |
]. |
|
2001 |
timeoutArray at:index put:nil. |
|
2002 |
] ifTrue:[ |
|
2003 |
anyTimeouts := true |
|
2004 |
] |
|
2005 |
] |
|
2006 |
]. |
|
2007 |
||
2008 |
blocksToEvaluate notNil ifTrue:[ |
|
2009 |
blocksToEvaluate keysAndValuesDo:[:index :block | |
|
2010 |
|p| |
|
2011 |
||
2012 |
p := processes at:index. |
|
2013 |
(p isNil or:[p == scheduler or:[PureEventDriven]]) ifTrue:[ |
|
2014 |
block value |
|
2015 |
] ifFalse:[ |
|
2016 |
p interruptWith:block |
|
2017 |
] |
|
2018 |
] |
|
2019 |
] |
|
2020 |
! |
|
2021 |
||
2022 |
removeTimedBlock:aBlock |
|
2023 |
"remove the argument, aBlock from the list of time-sceduled-blocks." |
|
2024 |
||
2025 |
|index "{ Class: SmallInteger }" |
|
2026 |
wasBlocked| |
|
2027 |
||
2028 |
wasBlocked := OperatingSystem blockInterrupts. |
|
2029 |
index := timeoutActionArray identityIndexOf:aBlock startingAt:1. |
|
2030 |
(index ~~ 0) ifTrue:[ |
|
2031 |
timeoutArray at:index put:nil. |
|
2032 |
timeoutActionArray at:index put:nil. |
|
2033 |
timeoutSemaphoreArray at:index put:nil. |
|
2034 |
timeoutProcessArray at:index put:nil. |
|
2035 |
]. |
|
2036 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2037 |
! |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2038 |
|
1680 | 2039 |
removeTimeoutWithID:anID |
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2040 |
"remove the timeOut with anID (as returned by #addTimedBlock) |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2041 |
from the list of time-sceduled-blocks." |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2042 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2043 |
|index "{ Class: SmallInteger }" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2044 |
wasBlocked| |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2045 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2046 |
index := anID. |
1680 | 2047 |
(index > 0) ifTrue:[ |
2048 |
wasBlocked := OperatingSystem blockInterrupts. |
|
2049 |
||
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2050 |
timeoutArray at:index put:nil. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2051 |
timeoutActionArray at:index put:nil. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2052 |
timeoutSemaphoreArray at:index put:nil. |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2053 |
timeoutProcessArray at:index put:nil. |
1680 | 2054 |
|
2055 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
2056 |
] |
|
1676
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2057 |
|
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2058 |
"Created: 23.9.1996 / 14:32:33 / cg" |
12b3b5dcf68f
return an id from #addTimeout:
Claus Gittinger <cg@exept.de>
parents:
1641
diff
changeset
|
2059 |
"Modified: 23.9.1996 / 14:35:09 / cg" |
10 | 2060 |
! ! |
1 | 2061 |
|
10 | 2062 |
!ProcessorScheduler methodsFor:'waiting'! |
2063 |
||
699 | 2064 |
checkForInputWithTimeout:millis |
2065 |
"this is called, when there is absolutely nothing to do; |
|
2066 |
hard wait for either input to arrive or a timeout to occur." |
|
2067 |
||
2116
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2068 |
|fd index sema action wasBlocked| |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2069 |
|
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2070 |
"/ must enable interrupts, to be able to get out of a |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2071 |
"/ long wait (especially, to handle sigChild in the meantime) |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2072 |
|
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2073 |
(wasBlocked := OperatingSystem interruptsBlocked) ifTrue:[ |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2074 |
OperatingSystem unblockInterrupts. |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2075 |
]. |
699 | 2076 |
|
2077 |
fd := OperatingSystem |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2078 |
selectOnAnyReadable:readFdArray |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2079 |
writable:writeFdArray |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2080 |
exception:nil |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2081 |
withTimeOut:millis. |
1061
61012b7bed9c
protect myself against invalid fd's in readFdArray/writeFdArray
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
2082 |
|
2116
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2083 |
wasBlocked ifTrue:[ |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2084 |
OperatingSystem blockInterrupts. |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2085 |
]. |
1bcb6ee86fca
fixed pending sigChild problem;
Claus Gittinger <cg@exept.de>
parents:
2111
diff
changeset
|
2086 |
|
1061
61012b7bed9c
protect myself against invalid fd's in readFdArray/writeFdArray
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
2087 |
fd isNil ifTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2088 |
(OperatingSystem lastErrorSymbol == #EBADF) ifTrue:[ |
1061
61012b7bed9c
protect myself against invalid fd's in readFdArray/writeFdArray
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
2089 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2090 |
"/ mhmh - one of the fd's given to me is corrupt. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2091 |
"/ find out which one .... and remove it |
1061
61012b7bed9c
protect myself against invalid fd's in readFdArray/writeFdArray
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
2092 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2093 |
OperatingSystem clearLastErrorNumber. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2094 |
self removeCorruptedFds |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2095 |
] |
1061
61012b7bed9c
protect myself against invalid fd's in readFdArray/writeFdArray
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
2096 |
] ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2097 |
index := readFdArray indexOf:fd. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2098 |
index ~~ 0 ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2099 |
sema := readSemaphoreArray at:index. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2100 |
sema notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2101 |
sema signalOnce. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2102 |
^ true |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2103 |
] ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2104 |
action := readCheckArray at:index. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2105 |
action notNil ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2106 |
action value. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2107 |
^ true |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2108 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2109 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2110 |
] |
699 | 2111 |
]. |
2112 |
^ false |
|
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
2113 |
|
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
2114 |
"Modified: 12.4.1996 / 09:31:22 / stefan" |
699 | 2115 |
! |
2116 |
||
10 | 2117 |
ioInterrupt |
1787
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
2118 |
"{ Pragma: +returnable }" |
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
2119 |
|
159 | 2120 |
"data arrived while waiting - switch to scheduler process which will decide |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2121 |
what to do now. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2122 |
This method is called by the VM' interrupt handling mechanism. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2123 |
Notice, that at the time of the message, we are still in the context |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2124 |
of whichever process is currently running." |
10 | 2125 |
|
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
2126 |
gotIOInterrupt := true. |
181 | 2127 |
interruptedProcess := activeProcess. |
1791 | 2128 |
self threadSwitch:scheduler |
804
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
2129 |
|
264d440a67a0
Fixes when useIOInterrupts == true.
Stefan Vogel <sv@exept.de>
parents:
786
diff
changeset
|
2130 |
"Modified: 21.12.1995 / 16:17:40 / stefan" |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2131 |
"Modified: 18.10.1996 / 20:36:05 / cg" |
10 | 2132 |
! |
2133 |
||
1086 | 2134 |
removeCorruptedFds |
2135 |
"this is sent when select returns an error due to some invalid |
|
1606 | 2136 |
fileDescriptor. May happen, if someone does a readWait/writeWait on a |
2137 |
socket connection, which somehow got corrupted |
|
2138 |
(shutdown by partner, or closed in another thread). |
|
1086 | 2139 |
Without special care, all following selects would immediately return with |
2140 |
an #EBADF error, leading to high-frequency polling and a locked up system. |
|
2141 |
(you could still fix things by interrupting on the console and fixing the |
|
2142 |
readFdArray/writeFdArray in the debugger)" |
|
2143 |
||
2144 |
readFdArray keysAndValuesDo:[:idx :fd | |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2145 |
|rslt sema| |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2146 |
|
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2147 |
rslt := OperatingSystem |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2148 |
selectOnAnyReadable:(Array with:fd) |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2149 |
writable:nil |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2150 |
exception:nil |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2151 |
withTimeOut:0. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2152 |
|
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2153 |
(rslt isNil and:[OperatingSystem lastErrorSymbol == #EBADF]) ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2154 |
('Processor [warning]: removing invalid read fileDescriptor: ' , fd printString) errorPrintCR. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2155 |
readFdArray at:idx put:nil. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2156 |
OperatingSystem clearLastErrorNumber. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2157 |
(sema := readSemaphoreArray at:idx) notNil ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2158 |
readSemaphoreArray at:idx put:nil. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2159 |
sema signal. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2160 |
]. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2161 |
] |
1086 | 2162 |
]. |
2163 |
||
2164 |
writeFdArray keysAndValuesDo:[:idx :fd | |
|
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2165 |
|rslt sema| |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2166 |
|
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2167 |
rslt := OperatingSystem |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2168 |
selectOnAnyReadable:nil |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2169 |
writable:(Array with:fd) |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2170 |
exception:nil |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2171 |
withTimeOut:0. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2172 |
|
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2173 |
(rslt isNil and:[OperatingSystem lastErrorSymbol == #EBADF]) ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2174 |
('Processor [warning]: removing invalid write fileDescriptor: ' , fd printString) errorPrintCR. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2175 |
writeFdArray at:idx put:nil. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2176 |
OperatingSystem clearLastErrorNumber. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2177 |
(sema := writeSemaphoreArray at:idx) notNil ifTrue:[ |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2178 |
writeSemaphoreArray at:idx put:nil. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2179 |
sema signal. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2180 |
]. |
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2181 |
] |
1086 | 2182 |
]. |
1154
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
2183 |
|
96bb8fce61cf
Fix removeCorruptedFds to clear LastErrorNumber. Handle ChildSignalInterrupts in Scheduler's context, to avoid errno corruption.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
2184 |
"Modified: 12.4.1996 / 09:32:58 / stefan" |
2129
e03cd7bc3475
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
2185 |
"Modified: 10.1.1997 / 18:03:51 / cg" |
1086 | 2186 |
! |
2187 |
||
750
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2188 |
schedulerInterrupt |
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2189 |
"forced reschedule - switch to scheduler process which will decide |
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2190 |
what to do now." |
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2191 |
|
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2192 |
interruptedProcess := activeProcess. |
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2193 |
self threadSwitch:scheduler |
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2194 |
! |
f4ed622893ce
added schedulerInterrupt - for soon to come semaSignal primitive function
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
2195 |
|
10 | 2196 |
timeToNextTimeout |
2197 |
"return the delta-T (in millis) to next timeout, or nil if |
|
2198 |
there is none" |
|
2199 |
||
231 | 2200 |
|aTime now delta minDelta n "{ Class: SmallInteger }"| |
10 | 2201 |
|
2202 |
"find next timeout. since there are usually not many, just search. |
|
302 | 2203 |
If there were many, the list should be kept sorted ... keeping deltas |
10 | 2204 |
to next (as in Unix kernel)" |
2205 |
||
231 | 2206 |
n := timeoutArray size. |
10 | 2207 |
1 to:n do:[:index | |
231 | 2208 |
aTime := timeoutArray at:index. |
159 | 2209 |
aTime notNil ifTrue:[ |
231 | 2210 |
now isNil ifTrue:[ |
159 | 2211 |
now := OperatingSystem getMillisecondTime. |
231 | 2212 |
]. |
2213 |
(OperatingSystem millisecondTime:aTime isAfter:now) ifFalse:[^ 0]. |
|
2214 |
delta := OperatingSystem millisecondTimeDeltaBetween:aTime and:now. |
|
2215 |
minDelta isNil ifTrue:[ |
|
2216 |
minDelta := delta |
|
159 | 2217 |
] ifFalse:[ |
231 | 2218 |
minDelta := minDelta min:delta |
159 | 2219 |
] |
2220 |
] |
|
10 | 2221 |
]. |
2222 |
||
2223 |
^ minDelta |
|
2224 |
! |
|
2225 |
||
699 | 2226 |
timerInterrupt |
1787
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
2227 |
"{ Pragma: +returnable }" |
32632b6f969d
remember threadSwitch:from: idea for later implementation;
Claus Gittinger <cg@exept.de>
parents:
1783
diff
changeset
|
2228 |
|
699 | 2229 |
"timer expired while waiting - switch to scheduler process which will decide |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2230 |
what to do now. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2231 |
This method is called by the VM' interrupt handling mechanism. |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2232 |
Notice, that at the time of the message, we are still in the context |
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2233 |
of whichever process is currently running." |
699 | 2234 |
|
2235 |
interruptedProcess := activeProcess. |
|
1791 | 2236 |
self threadSwitch:scheduler |
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2237 |
|
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2238 |
"Modified: 18.10.1996 / 20:35:54 / cg" |
699 | 2239 |
! |
2240 |
||
10 | 2241 |
waitForEventOrTimeout |
44 | 2242 |
"entered when no process is runnable - wait for either input on |
2243 |
any file descriptors to arrive or a timeout to happen. |
|
2244 |
If it makes sense, do some background garbage collection. |
|
2245 |
The idle actions are a leftover from previous ST/X releases and will |
|
93 | 2246 |
vanish (installing a low-prio process has the same effect)." |
44 | 2247 |
|
1575 | 2248 |
|millis doingGC anySema| |
10 | 2249 |
|
2250 |
doingGC := true. |
|
2251 |
[doingGC] whileTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2252 |
anyTimeouts ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2253 |
millis := self timeToNextTimeout. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2254 |
(millis notNil and:[millis <= 0]) ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2255 |
^ self "oops - hurry up checking" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2256 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2257 |
]. |
10 | 2258 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2259 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2260 |
if its worth doing, collect a bit of garbage; |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2261 |
but not, if a backgroundCollector is active |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2262 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2263 |
ObjectMemory backgroundCollectorRunning ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2264 |
doingGC := false |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2265 |
] ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2266 |
doingGC := ObjectMemory gcStepIfUseful. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2267 |
]. |
10 | 2268 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2269 |
"then do idle actions" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2270 |
(idleActions notNil and:[idleActions size ~~ 0]) ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2271 |
idleActions do:[:aBlock | |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2272 |
aBlock value. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2273 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2274 |
^ self "go back checking" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2275 |
]. |
10 | 2276 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2277 |
doingGC ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2278 |
(self checkForInputWithTimeout:0) ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2279 |
^ self "go back checking" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2280 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2281 |
] |
10 | 2282 |
]. |
2283 |
||
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
2284 |
exitWhenNoMoreUserProcesses ifTrue:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2285 |
"/ check if there are any processes at all |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2286 |
"/ stop dispatching if there is none |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2287 |
"/ (and millis is nil, which means that no timeout blocks are present) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2288 |
"/ and no readSemaphores are present (which means that noone is waiting for input) |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2289 |
"/ and no writeSemaphores are present |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
2290 |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2291 |
anySema := false. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2292 |
anySema := (readSemaphoreArray findFirst:[:sema | sema notNil]) ~~ 0. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2293 |
anySema ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2294 |
anySema := (writeSemaphoreArray findFirst:[:sema | sema notNil]) ~~ 0. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2295 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2296 |
anySema ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2297 |
self anyUserProcessAtAll ifFalse:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2298 |
dispatching := false. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2299 |
^ self |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2300 |
] |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2301 |
]. |
964
6d87e84d86ac
in standAloneMode: exit dispatch if last process dies and no more sema/timer waits are pending
Claus Gittinger <cg@exept.de>
parents:
840
diff
changeset
|
2302 |
]. |
10 | 2303 |
|
1627
f95285226059
infoPrint for NT (no select)
Claus Gittinger <cg@exept.de>
parents:
1618
diff
changeset
|
2304 |
"/ |
f95285226059
infoPrint for NT (no select)
Claus Gittinger <cg@exept.de>
parents:
1618
diff
changeset
|
2305 |
"/ absolutely nothing to do - simply wait |
f95285226059
infoPrint for NT (no select)
Claus Gittinger <cg@exept.de>
parents:
1618
diff
changeset
|
2306 |
"/ |
49 | 2307 |
OperatingSystem supportsSelect ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2308 |
"SCO instant ShitStation has a bug here, |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2309 |
waiting always 1 sec in the select - therefore we delay a bit and |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2310 |
return - effectively polling in 50ms cycles |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2311 |
" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2312 |
(self checkForInputWithTimeout:0) ifTrue:[ |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2313 |
^ self "go back checking" |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2314 |
]. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2315 |
OperatingSystem millisecondDelay:50. |
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2316 |
^ self |
10 | 2317 |
]. |
2318 |
||
2319 |
millis isNil ifTrue:[ |
|
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2320 |
millis := 9999. |
1 | 2321 |
] ifFalse:[ |
1679
dbbfbd78b1e4
Allow scheduler to suspend/resume itself. This makes semaphores work
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
2322 |
millis := millis rounded |
10 | 2323 |
]. |
2324 |
self checkForInputWithTimeout:millis |
|
768
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2325 |
|
20434b8239f3
stefans modalBox changes (no more polling)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
2326 |
"Modified: 14.12.1995 / 13:37:46 / stefan" |
1576 | 2327 |
"Modified: 18.7.1996 / 20:42:17 / cg" |
10 | 2328 |
! ! |
2329 |
||
1783
be7402f74d94
hide timerInterrupt & ioInterrupt contexts when switching
Claus Gittinger <cg@exept.de>
parents:
1780
diff
changeset
|
2330 |
!ProcessorScheduler class methodsFor:'documentation'! |
10 | 2331 |
|
699 | 2332 |
version |
2137 | 2333 |
^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.107 1997-01-10 18:17:32 cg Exp $' |
1 | 2334 |
! ! |
699 | 2335 |
ProcessorScheduler initialize! |