author | Claus Gittinger <cg@exept.de> |
Fri, 14 Dec 2001 11:54:51 +0100 | |
changeset 6322 | 8e6d732fda15 |
parent 6219 | 6fbbd5e48b8f |
child 6421 | 58dca33cf0fc |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1992 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 |
||
5377 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
1 | 15 |
Link subclass:#Process |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
16 |
instanceVariableNames:'id suspendContext prio state startBlock name restartable |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
17 |
interruptActions exitActions suspendSemaphore singleStepping |
2724 | 18 |
emergencySignalHandler suspendActions creatorId processGroupId |
4874
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
19 |
interruptsDisabled priorityRange exceptionHandlerSet processType' |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
20 |
classVariableNames:'TerminateSignal RestartSignal CoughtSignals' |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
21 |
poolDictionaries:'' |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
22 |
category:'Kernel-Processes' |
1 | 23 |
! |
24 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
25 |
!Process class methodsFor:'documentation'! |
88 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
159 | 30 |
All Rights Reserved |
88 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
Instances of Process represent lightweight smalltalk processes |
|
44 |
(i.e. threads). These all run in a shared smalltalk/X address space, |
|
93 | 45 |
and can thus access and communicate via any objects. |
46 |
Do not confuse these with (heavy-weight) unix processes, which are |
|
47 |
created differently, and do NOT run in the same address space. |
|
48 |
Also notice, that heavy-weight process creation takes much longer. |
|
49 |
(see OperatingSystemclass>>fork). |
|
50 |
||
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
51 |
Smalltalk processes do not nescessarily need to be implemented as native |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
52 |
threads - it may, but the actual implementation depends on the underlying |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
53 |
OS'S features. However, even if implemented as native thread, the ST/X |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
54 |
kernel makes certain, that only one thread executes at a time (with certain, |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
55 |
well-defined exceptions). The reason is that the reqiored locking in the |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
56 |
runtime system would make things slower in most cases. |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
57 |
|
202 | 58 |
Processes are typically created by sending #fork or #forkAt: to a block; |
59 |
the block creates a new process, defines itself as its startBlock, |
|
60 |
and (optionally) tells the Processor about the new process. |
|
61 |
||
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
62 |
Scheduling is done by Processor, which is the sole instance of ProcessorScheduler. |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
63 |
In ST/X, the scheduling algorithms are fully implemented (and visible) on the |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
64 |
smalltalk level - beside the threadSwitch primitive, there is virtually no VM |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
65 |
support (i.e. it can be easily changed). |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
66 |
|
93 | 67 |
|
202 | 68 |
Processes can be terminated either soft or via a hardTerminate. |
217 | 69 |
|
202 | 70 |
A soft terminate (see Process>>terminate) will raise a TerminationSignal |
217 | 71 |
in the process, which can be handled by the process. |
72 |
If no other handler was specified, the processes own handler |
|
73 |
(see Process>>start) will catch the signal and terminate the process. |
|
74 |
During this signal processing, normal unwind processing takes place, |
|
75 |
this means that with a soft terminate, all valueOnUnwind:/valueNowOrOnUnwind: |
|
76 |
cleanup blocks are evaluated. |
|
202 | 77 |
(so a process which has set up those blocks correctly does not have to |
78 |
care especially about cleanup in case of termination). |
|
2689 | 79 |
Other than that, the TerminateSignal can be caught for special cleanup or |
217 | 80 |
even to make the process continue execution. |
4415
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
81 |
If the process is suspended at termination time, it will be resumed |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
82 |
in order to perform its cleanup actions (i.e. the cleanup is always |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
83 |
done in the context of the terminating process itself). |
202 | 84 |
|
85 |
A hard terminate (Process>>terminateNoSignal) will NOT do all of the above, |
|
86 |
but quickly (and without any cleanup) terminate the process. |
|
87 |
The debugger offers a quickTerminate option on its popupMenu for |
|
88 |
situations, when soft termination fails. (for example, if some error was |
|
89 |
coded into a handler or unwind block). |
|
90 |
||
4415
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
91 |
Leaving the processes startBlock has the same effct as a soft-terminate |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
92 |
(i.e. there is no need to send an explicit terminate). |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
93 |
|
202 | 94 |
Notice: |
5450 | 95 |
in Smalltalk/X, processes are gone, when an image is restarted; |
96 |
this means, that you have to take care of process re-creation yourself. |
|
97 |
Usually, this is done by depending on ObjectMemory, recreating the |
|
98 |
process(es) when the #returnFromSnapshot-change notifiction arrives. |
|
202 | 99 |
|
5450 | 100 |
All views (actually windowGroups) recreate their window process |
101 |
on image-restart. You have to do so manually for your own processes. |
|
93 | 102 |
|
103 |
A later version will allow specification of automatic restart, but |
|
217 | 104 |
thats not yet implemented. However, even when implemented, restartable processes |
105 |
will be recreated to restart from the beginning. It will not be possible to |
|
106 |
automatically continue a processes execution where it left off. |
|
107 |
This is a consequence of the portable implementation of ST/X, since in order to |
|
375 | 108 |
implement process continuation, the machines stack had to be preserved and |
109 |
recreated. Although this is possible to do (and actually not too complicated), |
|
110 |
this has not been implemented, since the machines stack layout is highly machine/compiler |
|
111 |
dependent, thus leading to much bigger porting effort of ST/X (which conflicts |
|
112 |
with ST/X's design goal of being highly portable). |
|
217 | 113 |
|
114 |
Process synchronization: |
|
5450 | 115 |
Synchronization with cooperating processes is supported as usual, |
116 |
via Semaphores (see Semaphore, Delay, SharedQueue etc.) |
|
375 | 117 |
|
5450 | 118 |
With uncooperative processes, only synchronization on suspend |
119 |
and termination is possible: |
|
120 |
any other process can wait for a process to suspend or terminate. |
|
121 |
This waiting is implemented by using suspendSemaphore and exitBlocks |
|
122 |
(where an exitSemaphore is signalled). |
|
123 |
See waitUntilSuspended / waitUntilTerminated. |
|
1273 | 124 |
|
3784 | 125 |
|
126 |
Process states: |
|
5450 | 127 |
#dead process has (been) terminated; |
128 |
the process instance has no underlting |
|
129 |
thread. |
|
3784 | 130 |
|
5450 | 131 |
#run the process is willing to run, |
132 |
but not active (i.e. another higher prio |
|
133 |
process is currently executing) |
|
3784 | 134 |
|
5450 | 135 |
#active the process is the current process |
136 |
(there is only one) |
|
3784 | 137 |
|
5450 | 138 |
#ioWait waiting on some io-related semaphore |
139 |
(typically in #readWait / #writeWait) |
|
3784 | 140 |
|
5450 | 141 |
#eventWait waiting on some GUI event |
3784 | 142 |
|
5450 | 143 |
#timeWait waiting on a timer-related semaphore |
3784 | 144 |
|
5450 | 145 |
#wait waiting on some (other) semaphore |
3784 | 146 |
|
5450 | 147 |
#suspended stopped from execution; however, an interrupt |
148 |
will return it into the run state. |
|
3784 | 149 |
|
5450 | 150 |
#stopped stopped from execution; an interrupt will |
151 |
NOT return it into the run state (for debugging) |
|
3784 | 152 |
|
5450 | 153 |
#debug debugger sitting on top of the processes |
154 |
stack. |
|
3784 | 155 |
|
156 |
Win32 only: |
|
157 |
||
5450 | 158 |
#osWait waiting on an OS-API call to finish. |
159 |
can be interrupted, terminated and aborted |
|
160 |
(i.e. the usual context actions are is possible). |
|
3784 | 161 |
|
5450 | 162 |
#halted thread was cought while in a blocking API call |
163 |
or primitive endless loop and has been halted by |
|
164 |
the scheduler. |
|
165 |
Can only be resumed or hard-terminated - abort |
|
166 |
or soft terminate or unwind actions are not possible. |
|
167 |
(due to win32 limitations) |
|
3784 | 168 |
|
169 |
||
1273 | 170 |
[Instance variables:] |
93 | 171 |
|
5450 | 172 |
id <SmallInteger> a unique process-id |
93 | 173 |
|
5450 | 174 |
creatorId <SmallInteger> the id of the process that |
175 |
created me (useful for debugging |
|
176 |
or monitoring). |
|
2197 | 177 |
|
5450 | 178 |
processGroupId usually the id of the creator, |
179 |
unless the process detached from |
|
180 |
the group and became a groupLeader. |
|
181 |
Groups can be easily terminated |
|
182 |
as a whole. |
|
183 |
Group leaders have a groupId of nil. |
|
184 |
A groupId of 0 (zero) marks a system |
|
185 |
process; these do not prevent a standAlone |
|
186 |
app from exiting. |
|
2197 | 187 |
|
5450 | 188 |
prio <SmallInteger> the processes priority |
202 | 189 |
|
5450 | 190 |
priorityRange <Interval> the processes dynamic priority range |
191 |
(or nil) |
|
3723 | 192 |
|
5450 | 193 |
state <Symbol> the processes state |
194 |
(for process-monitor) |
|
202 | 195 |
|
5450 | 196 |
startBlock <Block> the startup-block (the one that forked) |
202 | 197 |
|
5450 | 198 |
name <String-or-nil> the processes name (if any) |
199 |
(for process-monitor) |
|
202 | 200 |
|
5450 | 201 |
suspendSemaphore <Semaphore> triggered when suspend (if nonNil) |
217 | 202 |
|
5450 | 203 |
restartable <Boolean> is restartable; if true, the process |
204 |
will be restarted when an image is |
|
205 |
restarted. Otherwise, it remains dead. |
|
206 |
Running processes cannot be continued |
|
207 |
at the point where leftOff after an |
|
208 |
image-restart. |
|
202 | 209 |
|
5450 | 210 |
interruptActions <Collection> interrupt actions as defined by interruptWith:, |
211 |
performed at interrupt time |
|
202 | 212 |
|
5450 | 213 |
exitActions <Collection of Block> |
214 |
additional cleanup actions to perform |
|
215 |
on termination (if nonEmpty) |
|
202 | 216 |
|
5450 | 217 |
emergencySignalHandler <Block> can be used for per-process |
218 |
emergency signal handling |
|
2725
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
219 |
|
5450 | 220 |
interruptsDisabled <Boolean> flag if interrupts (as installed |
221 |
via #interruptWith:) are currently |
|
222 |
disabled. (i.e. on-hold). |
|
223 |
Interrupts will be delivered when |
|
224 |
reenabled. |
|
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
225 |
|
5450 | 226 |
exceptionHandlerSet <ExceptionhandlerSet> |
227 |
Handled by any process; allows for |
|
228 |
exceptionHandlers and query-answerers to |
|
229 |
be added/removed dynamically. |
|
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
230 |
|
1273 | 231 |
[Class variables:] |
159 | 232 |
|
5450 | 233 |
TerminateSignal <Signal> signal used to terminate processes |
234 |
(should not be caught - or at least |
|
235 |
rejected in handlers). |
|
236 |
If caught and proceeded, a process |
|
237 |
cannot be terminated via #terminate. |
|
238 |
For hardTermination (in case of emergency), |
|
239 |
send it a #erminateNoSignal message. |
|
2197 | 240 |
|
5450 | 241 |
RestartSignal <Signal> signal used to restart a process. |
242 |
Can be caught in additional handler(s), |
|
243 |
to perform all kind of re-initialization. |
|
244 |
However, these handlers should reject, |
|
245 |
for the restart to be really performed. |
|
1273 | 246 |
|
247 |
[see also:] |
|
5450 | 248 |
ProcessorScheduler |
249 |
Block |
|
250 |
Sempahore SemaphoreSet Delay SharedQueue |
|
251 |
WindowGroup |
|
252 |
(``Working with processes'': programming/processes.html) |
|
1273 | 253 |
|
1294 | 254 |
[author:] |
5450 | 255 |
Claus Gittinger |
1294 | 256 |
|
88 | 257 |
" |
213 | 258 |
! |
259 |
||
260 |
examples |
|
261 |
" |
|
262 |
start a background process, computing 1000 factorial 100 times; |
|
263 |
the processes priority is set to not disturb any interactive process. |
|
264 |
Since its prio is higher than the 3D animation demos prio, you will notice, |
|
265 |
that those are suspended while the computation runs. But Interactive views |
|
266 |
(like browsers) will continue to react normal. |
|
5450 | 267 |
[exBegin] |
213 | 268 |
[ |
269 |
'starting' printNL. |
|
270 |
100 timesRepeat:[1000 factorial]. |
|
271 |
'done with factorial' printNL. |
|
272 |
] forkAt:(Processor userBackgroundPriority). |
|
5450 | 273 |
[exEnd] |
213 | 274 |
|
275 |
||
276 |
start a background process, computing 1000 factorial 100 times; |
|
277 |
the processes priority is set to not disturb any process. |
|
278 |
The prio is set to 1 (which is the lowest possible) notice that now, |
|
279 |
the 3D animation demos also continue to run. |
|
5450 | 280 |
[exBegin] |
213 | 281 |
[ |
282 |
'starting' printNL. |
|
283 |
100 timesRepeat:[1000 factorial]. |
|
284 |
'done with factorial' printNL. |
|
285 |
] forkAt:1. |
|
5450 | 286 |
[exEnd] |
213 | 287 |
|
288 |
||
289 |
start a background process, reading a pipe without blocking other |
|
290 |
processes; |
|
5450 | 291 |
[exBegin] |
213 | 292 |
[ |
293 |
|p| |
|
294 |
||
295 |
'starting' printNL. |
|
296 |
p := PipeStream readingFrom:'ls -lR .'. |
|
297 |
[p atEnd] whileFalse:[ |
|
5450 | 298 |
p readWait. |
299 |
p nextLine printNL. |
|
213 | 300 |
]. |
301 |
p close. |
|
302 |
'done with pipe' printNL. |
|
303 |
] forkAt:1. |
|
5450 | 304 |
[exEnd] |
213 | 305 |
|
306 |
see more examples in doc/coding |
|
307 |
(or search in the browser for senders of fork*) |
|
308 |
" |
|
88 | 309 |
! ! |
1 | 310 |
|
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
311 |
!Process class methodsFor:'initialization'! |
159 | 312 |
|
313 |
initialize |
|
314 |
TerminateSignal isNil ifTrue:[ |
|
6212 | 315 |
"/ TerminateSignal := Signal new mayProceed:true. |
316 |
"/ TerminateSignal nameClass:self message:#terminateSignal. |
|
317 |
TerminateSignal := TerminateProcessRequest. |
|
318 |
TerminateSignal notifierString:'unhandled process termination'. |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
319 |
|
6212 | 320 |
"/ RestartSignal := Signal new mayProceed:true. |
321 |
"/ RestartSignal nameClass:self message:#restartSignal. |
|
322 |
RestartSignal := RestartProcessRequest. |
|
323 |
RestartSignal notifierString:'unhandled process restart'. |
|
302 | 324 |
|
6212 | 325 |
CoughtSignals := SignalSet |
326 |
with:AbortSignal |
|
327 |
with:TerminateSignal |
|
328 |
with:RestartSignal. |
|
159 | 329 |
] |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
330 |
|
6212 | 331 |
"Modified: / 17.11.2001 / 11:07:29 / cg" |
159 | 332 |
! ! |
333 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
334 |
!Process class methodsFor:'instance creation'! |
699 | 335 |
|
336 |
for:aBlock priority:aPrio |
|
337 |
"create a new (unscheduled) process which will execute aBlock at |
|
338 |
a given priority, once scheduled. The process will start execution once |
|
339 |
it gets a #resume-message." |
|
340 |
||
2268
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
341 |
^ self basicNew for:aBlock priority:aPrio |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
342 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
343 |
"Modified: 25.1.1997 / 01:23:12 / cg" |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
344 |
! |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
345 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
346 |
new |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
347 |
"create a new (unscheduled) process which will execute the start |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
348 |
method, when scheduled. The process will start execution once |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
349 |
it gets a #resume-message." |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
350 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
351 |
^ self basicNew for:nil priority:(Processor activePriority). |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
352 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
353 |
"Created: 25.1.1997 / 01:31:05 / cg" |
699 | 354 |
! ! |
355 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
356 |
!Process class methodsFor:'Signal constants'! |
159 | 357 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
358 |
restartSignal |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
359 |
"return the signal used for process restart" |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
360 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
361 |
^ RestartSignal |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
362 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
363 |
"Created: 28.10.1996 / 20:26:50 / cg" |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
364 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
365 |
|
159 | 366 |
terminateSignal |
202 | 367 |
"return the signal used for process termination" |
368 |
||
159 | 369 |
^ TerminateSignal |
370 |
! ! |
|
371 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
372 |
!Process class methodsFor:'defaults'! |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
373 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
374 |
defaultMaximumStackSize |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
375 |
"return the default max stack size. All new processes get |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
376 |
this limit initially. |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
377 |
It may be changed for individual processes with: |
5450 | 378 |
aProcess setMaximumStackSize:limit" |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
379 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
380 |
%{ /* NOCONTEXT */ |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
381 |
|
1352 | 382 |
RETURN ( __MKSMALLINT( __defaultThreadMaxStackSize() )); |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
383 |
%} |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
384 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
385 |
" |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
386 |
Process defaultMaximumStackSize |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
387 |
" |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
388 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
389 |
"Modified: 8.5.1996 / 10:22:24 / cg" |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
390 |
! |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
391 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
392 |
defaultMaximumStackSize:numberOfBytes |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
393 |
"set the default max stack size, return the previous value. |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
394 |
All new processes get this stack limit initially. |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
395 |
It may be changed for individual processes with: |
5450 | 396 |
aProcess setMaximumStackSize:limit |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
397 |
Notice: |
5450 | 398 |
There is seldom any need to change the default setting, |
399 |
except for highly recursive programs." |
|
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
400 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
401 |
%{ /* NOCONTEXT */ |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
402 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
403 |
if (__isSmallInteger(numberOfBytes)) { |
5450 | 404 |
RETURN ( __MKSMALLINT( __setDefaultThreadSetMaxStackSize(__intVal(numberOfBytes)) )); |
1352 | 405 |
} |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
406 |
%} |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
407 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
408 |
" |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
409 |
Process defaultMaximumStackSize:500*1024 |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
410 |
" |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
411 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
412 |
"Modified: 8.5.1996 / 10:23:26 / cg" |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
413 |
! ! |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
414 |
|
3783
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
415 |
!Process class methodsFor:'instance retrieval'! |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
416 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
417 |
findProcessWithId:id |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
418 |
"return a process with a particular id. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
419 |
This is only a debugging helper, to allow |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
420 |
easy access of a process by name in the MiniDebugger" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
421 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
422 |
self allSubInstances do:[:aProcess | aProcess id = id ifTrue:[^ aProcess]]. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
423 |
^ nil |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
424 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
425 |
" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
426 |
Process findProcessWithId:1 |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
427 |
" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
428 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
429 |
"Modified: / 26.8.1998 / 15:39:55 / cg" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
430 |
! |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
431 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
432 |
findProcessWithName:name |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
433 |
"return a process with a particular name. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
434 |
This is only a debugging helper, to allow |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
435 |
easy access of a process by name in the MiniDebugger" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
436 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
437 |
self allSubInstances do:[:aProcess | aProcess name = name ifTrue:[^ aProcess]]. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
438 |
^ nil |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
439 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
440 |
" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
441 |
Process findProcessWithName:'scheduler' |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
442 |
" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
443 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
444 |
"Modified: / 26.8.1998 / 15:40:54 / cg" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
445 |
! ! |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
446 |
|
1980
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
447 |
!Process methodsFor:'Compatibility - V''Age'! |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
448 |
|
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
449 |
queueInterrupt:aBlock |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
450 |
"VisualAge compatibility: alias for #interruptWith: |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
451 |
arrange for the receiver process to be interrupted and |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
452 |
evaluate aBlock in its interrupt handler." |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
453 |
|
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
454 |
^ self interruptWith:aBlock |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
455 |
|
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
456 |
"Created: 15.11.1996 / 11:41:06 / cg" |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
457 |
! ! |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
458 |
|
699 | 459 |
!Process methodsFor:'accessing'! |
460 |
||
4874
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
461 |
beGUIProcess |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
462 |
"mark the receiver as a gui process. |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
463 |
This is currently not used, but allows end-user applications |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
464 |
to terminate all subprocesses which are GUI related, and leave |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
465 |
other background processes in the same process group untouched." |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
466 |
|
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
467 |
processType := #gui |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
468 |
! |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
469 |
|
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
470 |
beGroupLeader |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
471 |
"make the receiver a processGroupLeader. |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
472 |
This detaches the process from its creator, so that it will not |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
473 |
be terminated when it teminates via #terminateGroup. |
5088 | 474 |
Also, processes forked from a groupLeader belong to that group |
475 |
and can be terminated via #terminateGroup - unless they become |
|
476 |
group leaders themself. |
|
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
477 |
(windowgroup processes do this)." |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
478 |
|
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
479 |
processGroupId := id |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
480 |
|
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
481 |
"Modified: 8.7.1996 / 14:00:35 / cg" |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
482 |
"Created: 8.7.1996 / 14:08:44 / cg" |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
483 |
! |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
484 |
|
2196 | 485 |
beSystemProcess |
486 |
"make the receiver a system process. |
|
487 |
These processes have a groupId of 0. |
|
488 |
When executed as standAlone application, smalltalk exits when |
|
489 |
no more user processes are running. |
|
5088 | 490 |
(i.e. when there are only systemProcesses left) |
2196 | 491 |
To prevent any daemon processes from preventing this exit, |
5088 | 492 |
you should make them systemProcesses" |
2196 | 493 |
|
494 |
processGroupId := 0 |
|
495 |
||
496 |
"Created: 17.1.1997 / 21:42:46 / cg" |
|
497 |
! |
|
498 |
||
699 | 499 |
changePriority:aNumber |
500 |
"same as priority:, but returns the old priority. |
|
818 | 501 |
(cannot do this in #priority: for ST-80 compatibility)" |
699 | 502 |
|
503 |
|oldPrio| |
|
504 |
||
505 |
oldPrio := prio. |
|
506 |
Processor changePriority:aNumber for:self. |
|
507 |
^ oldPrio |
|
818 | 508 |
|
509 |
"Modified: 23.12.1995 / 18:38:53 / cg" |
|
699 | 510 |
! |
511 |
||
1530
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
512 |
creatorId |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
513 |
"return the processcreators id. |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
514 |
This has no semantic meaning, but is useful to identify processes |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
515 |
when debugging." |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
516 |
|
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
517 |
^ creatorId |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
518 |
! |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
519 |
|
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
520 |
exceptionHandlerSet |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
521 |
"retrieve the exceptionHandlerSet, which includes the set of |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
522 |
exceptionHandlers which are cought by the process. |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
523 |
Initially being empty, this allows for default handlers to be |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
524 |
dynamically added/removed from the set of handled exceptions/queries." |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
525 |
|
4877 | 526 |
exceptionHandlerSet isNil ifTrue:[ |
5450 | 527 |
exceptionHandlerSet := ExceptionHandlerSet new. |
4877 | 528 |
]. |
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
529 |
^ exceptionHandlerSet |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
530 |
! |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
531 |
|
818 | 532 |
id |
533 |
"return the processes id" |
|
534 |
||
535 |
^ id |
|
536 |
! |
|
537 |
||
538 |
name |
|
539 |
"return the processes name" |
|
540 |
||
541 |
^ name |
|
542 |
! |
|
543 |
||
544 |
name:aString |
|
545 |
"set the processes name" |
|
546 |
||
547 |
name := aString |
|
548 |
! |
|
549 |
||
550 |
priority |
|
551 |
"return the receivers priority" |
|
552 |
||
553 |
^ prio |
|
554 |
! |
|
555 |
||
556 |
priority:aNumber |
|
557 |
"set my priority" |
|
558 |
||
559 |
Processor changePriority:aNumber for:self. |
|
560 |
! |
|
561 |
||
3679 | 562 |
priorityRange |
3723 | 563 |
"return my dynamic priority range" |
3679 | 564 |
|
565 |
^ priorityRange |
|
566 |
||
3723 | 567 |
"Modified: / 3.8.1998 / 22:55:53 / cg" |
3679 | 568 |
! |
569 |
||
570 |
priorityRange:anInterval |
|
3723 | 571 |
"change my dynamic priority range" |
3679 | 572 |
|
573 |
priorityRange := anInterval |
|
574 |
||
3723 | 575 |
"Modified: / 3.8.1998 / 22:56:05 / cg" |
3679 | 576 |
! |
577 |
||
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
578 |
processGroupId |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
579 |
"return the processes processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
580 |
Normally, when created, a processes creator id is taken and used |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
581 |
as the processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
582 |
When #terminateGroup is sent to a process, the process and all of its |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
583 |
group members are terminated together. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
584 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
585 |
Processes can detach themself from the process group to prevent being |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
586 |
killed when the parent terminates (windowgroup processes do this)." |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
587 |
|
1530
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
588 |
^ processGroupId |
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
589 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
590 |
"Created: 8.7.1996 / 13:47:47 / cg" |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
591 |
! |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
592 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
593 |
processGroupId:aGroupLeadersProcessID |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
594 |
"set the processes processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
595 |
Normally, when created, a processes creator id is taken and used |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
596 |
as the processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
597 |
When #terminateGroup is sent to a process, the process and all of its |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
598 |
group members are terminated together. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
599 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
600 |
Processes can detach themself from the process group to prevent being |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
601 |
killed when the parent terminates (windowgroup processes do this)." |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
602 |
|
1530
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
603 |
processGroupId := aGroupLeadersProcessID |
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
604 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
605 |
"Created: 8.7.1996 / 13:47:53 / cg" |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
606 |
! |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
607 |
|
818 | 608 |
restartable:aBoolean |
609 |
"set/clear, the restartable flag. |
|
610 |
Restartable processes will automatically be restarted by the |
|
611 |
ProcessorScheduler upon image restart. |
|
612 |
Others have to be restarted manually." |
|
613 |
||
614 |
startBlock isNil ifTrue:[ |
|
5450 | 615 |
self error:'cannot be made restartable when already started' mayProceed:true. |
616 |
^ self |
|
818 | 617 |
]. |
618 |
restartable := aBoolean |
|
619 |
||
620 |
"Modified: 23.12.1995 / 18:38:32 / cg" |
|
621 |
! |
|
622 |
||
623 |
singleStep:aBoolean |
|
624 |
singleStepping := aBoolean |
|
625 |
! |
|
626 |
||
627 |
startBlock |
|
628 |
"return the processes startup-block" |
|
629 |
||
630 |
^ startBlock |
|
631 |
! |
|
632 |
||
633 |
state |
|
634 |
"return a symbol describing the processes state" |
|
635 |
||
636 |
^ state |
|
637 |
! |
|
638 |
||
639 |
state:aSymbol |
|
640 |
"set the state - only to be used from scheduler" |
|
641 |
||
642 |
state := aSymbol |
|
643 |
! |
|
644 |
||
645 |
suspendedContext |
|
646 |
"return the processes suspended context |
|
647 |
- this is the context from which a process switch into the scheduler |
|
5088 | 648 |
or another process occured. |
649 |
For the active process, a dead process, or one which |
|
2888
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
650 |
had no chance to run yet, nil is returned. |
818 | 651 |
Typically, only the debugger is interested in this one." |
652 |
||
653 |
%{ /* NOCONTEXT */ |
|
654 |
OBJ i; |
|
655 |
||
1133 | 656 |
if (__isSmallInteger(i = __INST(id))) { |
5450 | 657 |
RETURN (__threadContext(__intVal(i))); |
818 | 658 |
} |
659 |
%}. |
|
660 |
^ nil |
|
5088 | 661 |
|
662 |
||
663 |
||
664 |
||
818 | 665 |
! ! |
666 |
||
667 |
!Process methodsFor:'accessing-change notifications'! |
|
668 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
669 |
addExitAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
670 |
"add aBlock to the processes exit actions. |
5088 | 671 |
This block will be evaluated right before the process dies, |
672 |
and can be used to trigger actions somewhere else (i.e. synchronization)." |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
673 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
674 |
exitActions isNil ifTrue:[ |
5450 | 675 |
exitActions := OrderedCollection new |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
676 |
]. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
677 |
exitActions add:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
678 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
679 |
"Created: 12.1.1997 / 00:34:51 / cg" |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
680 |
! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
681 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
682 |
addSuspendAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
683 |
"add aBlock to the processes suspend actions. |
5088 | 684 |
This block will be evaluated when a process gets suspended. |
685 |
You may ask what that is useful for - it is useful to flush |
|
686 |
buffered graphic commands of a GUI process (i.e. to force xlib |
|
687 |
to send buffered commands to the display)." |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
688 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
689 |
suspendActions isNil ifTrue:[ |
5450 | 690 |
suspendActions := OrderedCollection new |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
691 |
]. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
692 |
suspendActions add:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
693 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
694 |
"Modified: 13.12.1995 / 13:44:31 / stefan" |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
695 |
"Created: 12.1.1997 / 00:35:11 / cg" |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
696 |
! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
697 |
|
699 | 698 |
emergencySignalHandler |
699 |
"return the emergencySignalHandler block. |
|
700 |
See Signal>>documentation for more info." |
|
701 |
||
702 |
^ emergencySignalHandler |
|
703 |
! |
|
704 |
||
705 |
emergencySignalHandler:aOneArgBlock |
|
706 |
"set the emergencySignalHandler block. |
|
707 |
See Signal>>documentation for more info." |
|
708 |
||
709 |
emergencySignalHandler := aOneArgBlock |
|
710 |
! |
|
711 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
712 |
removeAllExitActions |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
713 |
"remove all exit actions." |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
714 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
715 |
exitActions := nil. |
699 | 716 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
717 |
"Created: 12.1.1997 / 00:36:02 / cg" |
699 | 718 |
! |
719 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
720 |
removeAllSuspendActions |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
721 |
"remove all suspend actions." |
699 | 722 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
723 |
suspendActions := nil. |
699 | 724 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
725 |
"Created: 12.1.1997 / 00:36:16 / cg" |
818 | 726 |
! ! |
699 | 727 |
|
818 | 728 |
!Process methodsFor:'accessing-stack'! |
699 | 729 |
|
730 |
maximumStackSize |
|
731 |
"returns the processes stack limit - i.e. the process will be |
|
732 |
interrupted with a recursionSignal-raise, if it ever |
|
733 |
needs more stack (in bytes) than this number" |
|
734 |
||
735 |
%{ /* NOCONTEXT */ |
|
736 |
extern int __threadMaxStackSize(); |
|
737 |
OBJ i; |
|
738 |
||
1133 | 739 |
if (__isSmallInteger(i = __INST(id))) { |
740 |
RETURN( __MKSMALLINT(__threadMaxStackSize(__intVal(i))) ); |
|
699 | 741 |
} |
742 |
%}. |
|
743 |
^ nil |
|
744 |
! |
|
745 |
||
746 |
setMaximumStackSize:limit |
|
747 |
"sets the processes stack limit - i.e. the process will be |
|
748 |
interrupted with a recursionSignal-raise, if it ever |
|
749 |
needs more stack (in bytes) than this number. |
|
750 |
Returns the old value." |
|
751 |
||
752 |
%{ /* NOCONTEXT */ |
|
753 |
extern int __threadSetMaxStackSize(); |
|
754 |
OBJ i; |
|
755 |
||
1133 | 756 |
if (__isSmallInteger(i = __INST(id)) |
699 | 757 |
&& __isSmallInteger(limit) ) { |
1133 | 758 |
RETURN ( __MKSMALLINT(__threadSetMaxStackSize(__intVal(i), __intVal(limit))) ); |
699 | 759 |
} |
760 |
%}. |
|
761 |
^ nil |
|
762 |
! |
|
763 |
||
712
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
764 |
setStackInitialSize:initial increment:increment safe:safe |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
765 |
"hook for fine-tuning. Sets the processes initialStackSize- and |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
766 |
and stackIncrement-parameters. Not for normal use." |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
767 |
|
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
768 |
%{ /* NOCONTEXT */ |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
769 |
extern int __threadSetJunkSizes(); |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
770 |
OBJ i; |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
771 |
|
1133 | 772 |
if (__isSmallInteger(i = __INST(id)) |
712
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
773 |
&& __isSmallInteger(initial) |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
774 |
&& __isSmallInteger(increment) |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
775 |
&& __isSmallInteger(safe)) { |
1133 | 776 |
RETURN ( __threadSetJunkSizes(__intVal(i), __intVal(initial), __intVal(increment), __intVal(safe)) ? true : false ); |
712
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
777 |
} |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
778 |
%}. |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
779 |
^ false |
699 | 780 |
! ! |
781 |
||
782 |
!Process methodsFor:'interrupts'! |
|
783 |
||
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
784 |
addInterruptAction:aBlock |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
785 |
"make the receiver evaluate aBlock when resumed/interrupted. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
786 |
The name is somewhat misleading (actually, its historic): |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
787 |
the block is also evaluated on resume." |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
788 |
|
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
789 |
|wasBlocked| |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
790 |
|
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
791 |
wasBlocked := OperatingSystem blockInterrupts. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
792 |
interruptActions isNil ifTrue:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
793 |
interruptActions := OrderedCollection with:aBlock. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
794 |
] ifFalse:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
795 |
interruptActions addLast:aBlock. |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
796 |
]. |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
797 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
798 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
799 |
! |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
800 |
|
2725
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
801 |
blockInterrupts |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
802 |
"disable interrupt processing for the receiver process |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
803 |
- if disabled, incoming interrupts will be registered and handled as |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
804 |
soon as interrupts are reenabled via unblockInterrupts. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
805 |
Returns the previous blocking status i.e. true if interrupts |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
806 |
where already blocked. You need this information for proper |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
807 |
unblocking, in case of nested block/unblock calls. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
808 |
This is similar to OperatingSystem>>blockInterrupts, but only |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
809 |
affects interrupts for the receiver process |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
810 |
(i.e. those which are installed via #interruptWith:)" |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
811 |
|
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
812 |
|disabledBefore| |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
813 |
|
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
814 |
disabledBefore := interruptsDisabled. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
815 |
interruptsDisabled := true. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
816 |
^ disabledBefore ? false |
2726 | 817 |
|
818 |
" |
|
819 |
|p1| |
|
820 |
||
821 |
p1 := [ |
|
5450 | 822 |
Transcript showCR:'disabled ...'. |
823 |
Transcript showCR:Processor activeProcess blockInterrupts. |
|
824 |
Transcript showCR:'busy ...'. |
|
825 |
Delay waitForSeconds:10. |
|
826 |
Transcript showCR:'enabled ...'. |
|
827 |
Processor activeProcess unblockInterrupts. |
|
828 |
] forkAt:9. |
|
2726 | 829 |
|
830 |
p1 interruptWith:[Transcript showCR:'interrupted']. |
|
831 |
" |
|
2725
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
832 |
! |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
833 |
|
6322 | 834 |
evaluateInterruptActionsWithContext:aContext |
835 |
"evaluate my interrupt-actions." |
|
836 |
||
837 |
|action wasBlocked| |
|
838 |
||
839 |
[interruptActions size > 0] whileTrue:[ |
|
840 |
wasBlocked := OperatingSystem blockInterrupts. |
|
841 |
action := interruptActions removeFirst. |
|
842 |
interruptActions size == 0 ifTrue:[ interruptActions := nil ]. |
|
843 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
844 |
||
845 |
action numArgs == 1 ifTrue:[ |
|
846 |
action value:aContext |
|
847 |
] ifFalse:[ |
|
848 |
action value |
|
849 |
] |
|
850 |
]. |
|
851 |
! |
|
852 |
||
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
853 |
forceInterruptOnReturnOf:aContext |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
854 |
"helper entry for debugger. Force a stepInterrupt whenever aContext |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
855 |
returns either directly or via an unwind." |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
856 |
|
1728 | 857 |
aContext markForInterruptOnUnwind. |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
858 |
%{ |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
859 |
OBJ i; |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
860 |
|
1133 | 861 |
if (__isSmallInteger(i = __INST(id))) { |
5450 | 862 |
__threadContextStepInterrupt(__intVal(i), 1); |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
863 |
} |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
864 |
%} |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
865 |
|
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
866 |
! |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
867 |
|
5491 | 868 |
hasInterruptActions |
869 |
"return true, if there are any interrupt actions to evaluate |
|
870 |
(i.e. if the receiver has been interrupted)." |
|
871 |
||
872 |
^ interruptActions size > 0 |
|
873 |
! |
|
874 |
||
699 | 875 |
interrupt |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
876 |
"evaluate my interrupt-actions. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
877 |
The process will go back to where it got interrupted |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
878 |
after doing this." |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
879 |
|
6322 | 880 |
self evaluateInterruptActionsWithContext:thisContext sender |
699 | 881 |
! |
882 |
||
883 |
interruptWith:aBlock |
|
884 |
"interrupt the receiver and make it evaluate aBlock. |
|
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
885 |
If the receiver is currently suspended it is resumed. |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
886 |
Notice, that the process will only perform the block immediately, |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
887 |
IFF its priority is higher than the current processes priority. |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
888 |
Otherwise, it will remain suspended, until its time comes." |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
889 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
890 |
Processor activeProcess == self ifTrue:[ |
5450 | 891 |
aBlock value |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
892 |
] ifFalse:[ |
5450 | 893 |
self addInterruptAction:aBlock. |
894 |
Processor scheduleForInterrupt:self. |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
895 |
] |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
896 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
897 |
"Modified: 12.1.1997 / 00:52:05 / cg" |
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
898 |
! |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
899 |
|
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
900 |
interruptedIn:aContext |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
901 |
"evaluate my interrupt-actions. |
2724 | 902 |
This is indirectly called by the VM, when some #interruptWith: action |
903 |
was scheduled for the process, and the process is resumed. |
|
904 |
The process will go back to where it got interrupted after doing this." |
|
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
905 |
|
2727 | 906 |
"/ the returned value here has a subtle effect: |
907 |
"/ if false, the interrupt is assumed to be not taken, |
|
908 |
"/ and will be redelivered. |
|
909 |
||
2724 | 910 |
interruptsDisabled == true ifTrue:[ |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
911 |
"/ no, I dont want interrupts right now; |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
912 |
"/ try again later. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
913 |
^ false |
2724 | 914 |
]. |
915 |
||
6322 | 916 |
self evaluateInterruptActionsWithContext:aContext. |
2724 | 917 |
^ true |
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
918 |
|
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
919 |
"Created: 18.10.1996 / 20:43:39 / cg" |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
920 |
"Modified: 18.10.1996 / 20:47:20 / cg" |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
921 |
! |
699 | 922 |
|
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
923 |
onResumeDo:aBlock |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
924 |
"prepare for the receiver to evaluate aBlock when resumed. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
925 |
This is like #interruptWith:, but does not resume the receiver |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
926 |
(i.e. it continues its sleep). |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
927 |
This is useful to place a breakpoint on a sleeping process, to be fired |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
928 |
when it awakes." |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
929 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
930 |
self addInterruptAction:aBlock. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
931 |
Processor scheduleInterruptActionsOf:self. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
932 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
933 |
"Created: 5.3.1996 / 17:28:04 / cg" |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
934 |
"Modified: 8.3.1996 / 13:01:21 / cg" |
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
935 |
! |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
936 |
|
2857
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
937 |
stepInterruptHandler:anObject |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
938 |
"set the handler for stepInterrupts occurring in the receiver process. |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
939 |
This is an interface for the debugger and allows it to monitor a threads |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
940 |
stepInterrupts. Returns the previous handler. |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
941 |
Not for general use." |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
942 |
|
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
943 |
%{ /* NOCONTEXT */ |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
944 |
extern OBJ __threadStepInterruptHandler(); |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
945 |
|
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
946 |
RETURN( __threadStepInterruptHandler(anObject) ); |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
947 |
%} |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
948 |
! |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
949 |
|
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
950 |
unblockInterrupts |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
951 |
"enable interrupt processing for the receiver process |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
952 |
- if any interrupts are pending, these will be handled immediately. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
953 |
When unblocking interrupts, take care of nested block/unblock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
954 |
calls - you should only unblock after a blockcall if they where |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
955 |
really not blocked before. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
956 |
This is similar to OperatingSystem>>unblockInterrupts, but only |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
957 |
affects interrupts for the receiver process |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
958 |
(i.e. those which are installed via #interruptWith:)" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
959 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
960 |
interruptsDisabled := false. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
961 |
interruptActions size > 0 ifTrue:[ |
5450 | 962 |
Processor activeProcess == self ifTrue:[ |
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
963 |
self interrupt |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
964 |
] |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
965 |
] |
699 | 966 |
! ! |
967 |
||
968 |
!Process methodsFor:'monitoring'! |
|
969 |
||
970 |
numberOfStackBoundaryHits |
|
971 |
"internal monitoring only - will vanish" |
|
972 |
||
973 |
%{ /* NOCONTEXT */ |
|
974 |
extern int __threadNumberOfStackBoundaryHits(); |
|
975 |
int n; |
|
976 |
OBJ i; |
|
159 | 977 |
|
1133 | 978 |
if (__isSmallInteger(i = __INST(id))) { |
979 |
n = __threadNumberOfStackBoundaryHits(__intVal(i)); |
|
699 | 980 |
n &= 0x3FFFFFFF; |
1133 | 981 |
RETURN( __MKSMALLINT(n) ); |
699 | 982 |
} |
983 |
%}. |
|
984 |
^ nil |
|
985 |
! |
|
986 |
||
987 |
numberOfStackSegments |
|
988 |
"return the processes number of stack segments currently used. |
|
989 |
This method is for monitoring purposes only - it may vanish." |
|
990 |
||
991 |
%{ /* NOCONTEXT */ |
|
992 |
extern int __threadTotalStackSize(); |
|
993 |
OBJ i; |
|
994 |
||
1133 | 995 |
if (__isSmallInteger(i = __INST(id))) { |
996 |
RETURN( __MKSMALLINT(__threadStackSegments(__intVal(i))) ); |
|
699 | 997 |
} |
998 |
%}. |
|
999 |
^ nil |
|
1000 |
! |
|
1001 |
||
1002 |
totalStackSize |
|
1003 |
"return the processes maximum used stack size. |
|
1004 |
This method is for monitoring purposes only - it may vanish." |
|
1005 |
||
1006 |
%{ /* NOCONTEXT */ |
|
1007 |
extern int __threadTotalStackSize(); |
|
1008 |
OBJ i; |
|
1009 |
||
1133 | 1010 |
if (__isSmallInteger(i = __INST(id))) { |
1011 |
RETURN( __MKSMALLINT(__threadTotalStackSize(__intVal(i))) ); |
|
699 | 1012 |
} |
1013 |
%}. |
|
1014 |
^ nil |
|
1015 |
! |
|
1016 |
||
1017 |
usedStackSize |
|
1018 |
"Return the processes current stack size. |
|
1019 |
This method is for monitoring purposes only - it may vanish." |
|
1020 |
||
1021 |
%{ /* NOCONTEXT */ |
|
1022 |
extern int __threadUsedStackSize(); |
|
1023 |
OBJ i; |
|
1024 |
||
1133 | 1025 |
if (__isSmallInteger(i = __INST(id))) { |
1026 |
RETURN( __MKSMALLINT(__threadUsedStackSize(__intVal(i))) ); |
|
699 | 1027 |
} |
1028 |
%}. |
|
1029 |
^ nil |
|
1030 |
! |
|
1031 |
||
1032 |
vmTrace:aBoolean |
|
1033 |
"turn on/off VM message tracing for the receiver. |
|
1034 |
This is meant for ST/X debugging, and may vanish. |
|
1035 |
Expect lots of output, once this is turned on." |
|
1036 |
||
1037 |
%{ /* NOCONTEXT */ |
|
1038 |
OBJ i; |
|
1039 |
||
1133 | 1040 |
if (__isSmallInteger(i = __INST(id))) { |
1041 |
__threadTracing(__intVal(i), aBoolean); |
|
699 | 1042 |
} |
1043 |
%}. |
|
1044 |
! ! |
|
1045 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1046 |
!Process methodsFor:'obsolete'! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1047 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1048 |
exitAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1049 |
"Obsoleted by addExitAction: / removeAllExitActions. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1050 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1051 |
Add aBlock to the processes exit actions. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1052 |
This block will be evaluated right before the process dies. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1053 |
An argument of nil removes all exitActions." |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1054 |
|
5870 | 1055 |
<resource:#obsolete> |
1056 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1057 |
self obsoleteMethodWarning:'use addExitAction: / removeAllExitActions'. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1058 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1059 |
aBlock isNil ifTrue:[ |
5870 | 1060 |
^ self removeAllExitActions. |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1061 |
]. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1062 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1063 |
^ self addExitAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1064 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1065 |
"Modified: 13.12.1995 / 13:44:03 / stefan" |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1066 |
"Modified: 12.1.1997 / 00:39:59 / cg" |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1067 |
! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1068 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1069 |
suspendAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1070 |
"Obsoleted by addSuspendAction: / removeAllSuspendActions. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1071 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1072 |
Add aBlock to the processes suspend actions. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1073 |
This block will be evaluated when a process gets suspended. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1074 |
A nil argument removes all suspendActions." |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1075 |
|
5870 | 1076 |
<resource:#obsolete> |
1077 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1078 |
self obsoleteMethodWarning:'use addSuspendAction: / removeAllSuspendActions'. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1079 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1080 |
aBlock isNil ifTrue:[ |
5870 | 1081 |
^ self removeAllSuspendActions. |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1082 |
]. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1083 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1084 |
^ self addSuspendAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1085 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1086 |
"Modified: 12.1.1997 / 00:38:22 / cg" |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1087 |
! ! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1088 |
|
699 | 1089 |
!Process methodsFor:'printing & storing'! |
1090 |
||
1091 |
printOn:aStream |
|
1092 |
"a little more info in my printed representation" |
|
1093 |
||
1094 |
aStream nextPutAll:state article; |
|
1095 |
space; |
|
1096 |
nextPutAll:state; |
|
1097 |
nextPutAll:' Process ('; |
|
1098 |
nextPutAll:self nameOrId; |
|
1099 |
nextPutAll:')' |
|
159 | 1100 |
! ! |
1101 |
||
1102 |
!Process methodsFor:'private'! |
|
1103 |
||
1104 |
for:aBlock priority:aPrio |
|
1105 |
"setup the new process - the receiver is not scheduled for |
|
1106 |
execution, to get it running, send it #resume" |
|
1107 |
||
339 | 1108 |
|nm active| |
159 | 1109 |
|
1110 |
prio := aPrio. |
|
1111 |
startBlock := aBlock. |
|
339 | 1112 |
restartable := false. |
159 | 1113 |
|
1114 |
(Processor newProcessFor:self) ifFalse:[ |
|
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1115 |
"for some reason, the Processor was unable to create |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1116 |
a VM process for me ...." |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1117 |
^ nil |
159 | 1118 |
]. |
1119 |
||
1120 |
" |
|
1121 |
give me a user-friendly name |
|
1122 |
" |
|
339 | 1123 |
active := Processor activeProcess. |
2268
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
1124 |
(nm := active name) notNil ifTrue:[ |
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1125 |
" |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1126 |
avoid name inflation |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1127 |
" |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1128 |
(nm endsWith:' sub') ifFalse:[ |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1129 |
nm := nm , ' [' , active id printString , '] sub' |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1130 |
]. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1131 |
name := nm |
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
1132 |
]. |
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1133 |
creatorId := active id. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1134 |
processGroupId := active processGroupId. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1135 |
(processGroupId isNil or:[processGroupId == 0]) ifTrue:[ |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1136 |
processGroupId := creatorId. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1137 |
]. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1138 |
|
4880 | 1139 |
"/ since groupId is used to detect a systemProcess (0), |
1140 |
"/ do not allow a 0 here; need an explicit beSystemProcess. |
|
1141 |
processGroupId == 0 ifTrue:[processGroupId := nil]. |
|
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
1142 |
|
5812
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1143 |
"Modified: 25.1.1997 / 01:28:54 / cg" |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1144 |
! ! |
159 | 1145 |
|
699 | 1146 |
!Process methodsFor:'private scheduler access'! |
1 | 1147 |
|
699 | 1148 |
setId:idNumber state:stateSymbol |
1149 |
"set id and state - not for public use" |
|
375 | 1150 |
|
699 | 1151 |
id := idNumber. |
4880 | 1152 |
creatorId := 0. |
1153 |
processGroupId := nil. |
|
699 | 1154 |
state := stateSymbol. |
1844 | 1155 |
|
1156 |
"Modified: 30.10.1996 / 00:35:29 / cg" |
|
182 | 1157 |
! |
1158 |
||
159 | 1159 |
setPriority:aNumber |
1160 |
"set priority without telling processor - not for public use" |
|
1161 |
||
1162 |
prio := aNumber |
|
1163 |
! |
|
1164 |
||
1165 |
setStartBlock:aBlock |
|
1166 |
"set the receivers startup block" |
|
1167 |
||
1168 |
startBlock := aBlock |
|
1169 |
! |
|
13 | 1170 |
|
159 | 1171 |
setStateTo:newState if:oldState |
1172 |
state == oldState ifTrue:[state := newState] |
|
1173 |
! |
|
1174 |
||
1175 |
setStateTo:newState if:oldState1 or:oldState2 |
|
1176 |
(state == oldState1 or:[state == oldState2]) ifTrue:[state := newState] |
|
699 | 1177 |
! ! |
1178 |
||
818 | 1179 |
!Process methodsFor:'queries'! |
1180 |
||
5397 | 1181 |
isActive |
1182 |
"return true if I am the active process" |
|
1183 |
||
1184 |
^ Processor activeProcess == self |
|
1185 |
! |
|
1186 |
||
818 | 1187 |
isDead |
1188 |
"return true, iff the receiver is a dead process" |
|
1189 |
||
1190 |
^ (state isNil or:[state == #dead]) |
|
1191 |
||
1192 |
"Modified: 23.12.1995 / 18:35:29 / cg" |
|
1193 |
! |
|
1194 |
||
4874
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1195 |
isGUIProcess |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1196 |
"return true, if this is a GUI process. |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1197 |
I.e. a windowGroup process. |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1198 |
This is currently not used, but allows end-user applications |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1199 |
to terminate all subprocesses which are GUI related, and leave |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1200 |
other background processes in the same process group untouched." |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1201 |
|
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1202 |
^ processType == #gui |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1203 |
! |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1204 |
|
818 | 1205 |
isRestartable |
1206 |
"return true, iff the receiver is restartable" |
|
1207 |
||
1208 |
^ restartable |
|
1209 |
! |
|
1210 |
||
1211 |
isSingleStepping |
|
1212 |
^ singleStepping |
|
1213 |
! |
|
1214 |
||
5643 | 1215 |
isStopped |
1216 |
"return true, iff the receiver is stopped" |
|
1217 |
||
1218 |
^ (state == #stopped) |
|
1219 |
||
1220 |
"Modified: 23.12.1995 / 18:35:29 / cg" |
|
1221 |
! |
|
1222 |
||
2636
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1223 |
isSystemProcess |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1224 |
"return true if aProcess is a system process, |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1225 |
which should not be suspended/terminated etc.." |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1226 |
|
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1227 |
^ (Processor isPureEventDriven |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1228 |
or:[id == 0 |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1229 |
or:[processGroupId == 0 |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1230 |
or:[(Display notNil and:[Display dispatchProcess == self]) |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1231 |
]]]) |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1232 |
|
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1233 |
" |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1234 |
Processor activeProcessIsSystemProcess |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1235 |
" |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1236 |
|
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1237 |
"Created: 17.4.1997 / 12:57:37 / stefan" |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1238 |
! |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1239 |
|
818 | 1240 |
nameOrId |
1241 |
"return a string to identify the process - either name or id" |
|
1242 |
||
1243 |
name notNil ifTrue:[^ name]. |
|
1244 |
^ id printString |
|
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1245 |
! |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1246 |
|
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1247 |
processGroupLeader |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1248 |
"answer the parent of this process group" |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1249 |
|
5681 | 1250 |
|processes leader next creatorId| |
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1251 |
|
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1252 |
processes := ProcessorScheduler knownProcesses. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1253 |
leader := processes detect:[:p| p id = processGroupId] ifNone:nil. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1254 |
leader isNil ifTrue:[ |
5681 | 1255 |
leader := self. |
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1256 |
[ |
5681 | 1257 |
creatorId := leader creatorId. |
1258 |
next := processes detect:[:p| p id = creatorId |
|
5675
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1259 |
and:[p processGroupId = processGroupId]] |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1260 |
ifNone:nil. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1261 |
] doWhile:[next notNil and:[leader := next. true]]. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1262 |
]. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1263 |
|
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1264 |
^ leader. |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1265 |
|
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1266 |
" |
34d5b32f9259
Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents:
5643
diff
changeset
|
1267 |
Processor activeProcess processGroupLeader |
5812
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1268 |
" |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1269 |
! ! |
818 | 1270 |
|
699 | 1271 |
!Process methodsFor:'special'! |
1272 |
||
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1273 |
millisecondDelay:millis |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1274 |
"suspend the current process for some time. |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1275 |
If the receiver is a system process (i.e. scheduler or event dispatcher) |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1276 |
this blocks the whole smalltalk for the time delta; |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1277 |
if its a normal thread, only that thread is suspended." |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1278 |
|
2636
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1279 |
(self isSystemProcess) ifTrue:[ |
5450 | 1280 |
OperatingSystem millisecondDelay:millis |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1281 |
] ifFalse:[ |
5450 | 1282 |
Delay waitForMilliseconds:millis |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1283 |
] |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1284 |
|
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1285 |
"Created: 16.12.1995 / 13:10:53 / cg" |
2636
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1286 |
"Modified: 17.4.1997 / 13:02:25 / stefan" |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1287 |
! |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1288 |
|
699 | 1289 |
trapRestrictedMethods:trap |
1290 |
"Allow/deny the execution of restricted methods. |
|
1291 |
Process specific method restriction is not implemented yet, so this call is |
|
1292 |
redirected to ObjectMemory and causes a system wide restriction. |
|
1293 |
||
1294 |
Notice: method restriction is a nonstandard feature, not supported |
|
1295 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1296 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1297 |
It may change or even vanish (if it shows to be not useful)." |
|
1298 |
||
1299 |
^ObjectMemory trapRestrictedMethods:trap |
|
1300 |
||
1301 |
" |
|
1302 |
Processor activeProcess trapRestrictedMethods:true |
|
1303 |
Processor activeProcess trapRestrictedMethods:false |
|
1304 |
" |
|
1305 |
||
1306 |
"Created: 8.11.1995 / 19:45:04 / stefan" |
|
1307 |
! |
|
1308 |
||
1309 |
uninterruptablyDo:aBlock |
|
1310 |
"execute aBlock with interrupts blocked. |
|
1311 |
This does not prevent preemption by a higher priority processes |
|
1312 |
if any becomes runnable due to the evaluation of aBlock |
|
1313 |
(i.e. if a semaphore is signalled there)." |
|
1314 |
||
1315 |
"we must keep track of blocking-state if this is called nested" |
|
2302 | 1316 |
(OperatingSystem blockInterrupts) ifTrue:[ |
5450 | 1317 |
"/ already blocked |
1318 |
^ aBlock value |
|
2302 | 1319 |
]. |
699 | 1320 |
|
2302 | 1321 |
^ aBlock valueNowOrOnUnwindDo:[OperatingSystem unblockInterrupts] |
159 | 1322 |
! |
1323 |
||
699 | 1324 |
waitUntilSuspended |
1325 |
"wait until the receiver is suspended." |
|
1326 |
||
5377 | 1327 |
self isDead ifFalse:[ |
5450 | 1328 |
[ |
1329 |
"/ must check again - interrupt could have happened |
|
1330 |
"/ and process already terminated. |
|
1331 |
self isDead ifFalse:[ |
|
1332 |
suspendSemaphore isNil ifTrue:[ |
|
1333 |
suspendSemaphore := Semaphore new name:'process suspend' |
|
1334 |
]. |
|
1335 |
suspendSemaphore wait |
|
1336 |
] |
|
1337 |
] valueUninterruptably |
|
5377 | 1338 |
] |
699 | 1339 |
|
1946
370f57e569dc
oops - race in waitUntilSuspended & waitUntilTerminated
Claus Gittinger <cg@exept.de>
parents:
1844
diff
changeset
|
1340 |
"Modified: 8.11.1996 / 23:05:24 / cg" |
699 | 1341 |
! |
1342 |
||
1343 |
waitUntilTerminated |
|
1344 |
"wait until the receiver is terminated. |
|
1345 |
This method allows another process to wait till the receiver finishes." |
|
1346 |
||
1033 | 1347 |
|sema| |
699 | 1348 |
|
5377 | 1349 |
self isDead ifFalse:[ |
5450 | 1350 |
[ |
1351 |
"/ must check again - interrupt could have happened |
|
1352 |
"/ and process already terminated. |
|
1353 |
self isDead ifFalse:[ |
|
1354 |
sema := Semaphore new name:'process termination'. |
|
1355 |
self addExitAction:[sema signal]. |
|
1356 |
sema wait. |
|
1357 |
] |
|
1358 |
] valueUninterruptably |
|
5377 | 1359 |
] |
1033 | 1360 |
|
1789 | 1361 |
" |
1362 |
|p| |
|
1363 |
||
1364 |
p := [10 timesRepeat:[100 factorial]] forkAt:4. |
|
1365 |
||
1366 |
Transcript showCR:'now waiting ...'. |
|
1367 |
p waitUntilTerminated. |
|
1368 |
Transcript showCR:'done.' |
|
1369 |
" |
|
1370 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1371 |
"Modified: 12.1.1997 / 00:40:59 / cg" |
699 | 1372 |
! |
1373 |
||
4735
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1374 |
waitUntilTerminatedWithTimeout:secondsOrNil |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1375 |
"wait until the receiver is terminated or (if non-nil) until |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1376 |
the time period exired. Returns true if a timeout occurred. |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1377 |
This method allows another process to wait till the receiver finishes |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1378 |
(optionally) within some time." |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1379 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1380 |
|sema didTimeout| |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1381 |
|
5377 | 1382 |
self isDead ifFalse:[ |
5450 | 1383 |
[ |
1384 |
"/ must check again - interrupt could have happened |
|
1385 |
"/ and process already terminated. |
|
1386 |
self isDead ifFalse:[ |
|
1387 |
sema := Semaphore new name:'process termination'. |
|
1388 |
self addExitAction:[sema signal]. |
|
1389 |
secondsOrNil isNil ifTrue:[ |
|
1390 |
sema wait |
|
1391 |
] ifFalse:[ |
|
1392 |
didTimeout := (sema waitWithTimeout:secondsOrNil) isNil |
|
1393 |
] |
|
1394 |
] |
|
1395 |
] valueUninterruptably. |
|
5377 | 1396 |
]. |
1397 |
^ didTimeout == true |
|
4735
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1398 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1399 |
" |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1400 |
|p| |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1401 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1402 |
p := [10 timesRepeat:[10000 factorial]] forkAt:4. |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1403 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1404 |
Transcript showCR:'now waiting ...'. |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1405 |
(p waitUntilTerminatedWithTimeout:2) ifTrue:[ |
5450 | 1406 |
Transcript showCR:'timeout occurred.' |
4735
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1407 |
] |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1408 |
" |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1409 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1410 |
"Modified: 12.1.1997 / 00:40:59 / cg" |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1411 |
! |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1412 |
|
699 | 1413 |
withLowerPriorityDo:aBlock |
1414 |
"execute aBlock at a lower priority. This can be used to perform |
|
1415 |
time-consuming operations at a more user-friendly priority." |
|
159 | 1416 |
|
699 | 1417 |
^ self withPriority:(prio - 1) do:aBlock |
1418 |
||
1419 |
" |
|
1420 |
Processor activeProcess withLowerPriorityDo:[3000 factorial] |
|
1421 |
" |
|
1422 |
! |
|
1423 |
||
1424 |
withPriority:aPrio do:aBlock |
|
1425 |
"execute aBlock at another priority. This can be used to perform |
|
1426 |
time-consuming operations at a more user-friendly priority, |
|
1427 |
or some critical action at a higher priority. Do not use too high |
|
1428 |
of a priority to avoid locking up the system (event processing takes place |
|
1429 |
at 24)" |
|
1430 |
||
1431 |
|oldprio| |
|
1432 |
||
1433 |
oldprio := prio. |
|
1434 |
self priority:aPrio. |
|
1435 |
||
1436 |
^ aBlock valueNowOrOnUnwindDo:[ |
|
1437 |
self priority:oldprio |
|
1438 |
] |
|
1439 |
||
1440 |
" |
|
1441 |
Processor activeProcess withPriority:7 do:[3000 factorial] |
|
1442 |
" |
|
1443 |
"be careful - even ^C wont work until done: |
|
1444 |
Processor activeProcess withPriority:25 do:[3000 factorial] |
|
1445 |
" |
|
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1446 |
! |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1447 |
|
4433 | 1448 |
withPriority:lowPrio to:highPrio do:aBlock |
1449 |
"execute aBlock at a priority range. This can be used to perform |
|
1450 |
time-consuming operations at a more user-friendly priority, |
|
1451 |
or some critical action at a higher priority. Do not use too high |
|
1452 |
of a priority to avoid locking up the system (event processing takes place |
|
1453 |
at 24)" |
|
1454 |
||
1455 |
|oldprio oldRange| |
|
1456 |
||
1457 |
oldprio := prio. |
|
1458 |
oldRange := priorityRange. |
|
1459 |
self priorityRange:(lowPrio to:highPrio). |
|
1460 |
self priority:lowPrio. |
|
1461 |
||
1462 |
^ aBlock valueNowOrOnUnwindDo:[ |
|
5450 | 1463 |
self priorityRange:oldRange. |
1464 |
self priority:oldprio. |
|
4433 | 1465 |
] |
1466 |
||
1467 |
" |
|
1468 |
Processor activeProcess withPriority:7 to:8 do:[3000 factorial] |
|
1469 |
" |
|
1470 |
! |
|
1471 |
||
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1472 |
withSystemBackgroundPriorityDo:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1473 |
"execute aBlock at system background priority. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1474 |
This can be used to perform |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1475 |
background operations at a more user-friendly priority." |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1476 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1477 |
^ self withPriority:(Processor systemBackgroundPriority) do:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1478 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1479 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1480 |
Processor activeProcess withSystemBackgroundPriorityDo:[3000 factorial] |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1481 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1482 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1483 |
"Created: 7.8.1997 / 12:56:23 / cg" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1484 |
! |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1485 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1486 |
withUserBackgroundPriorityDo:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1487 |
"execute aBlock at background priority. This can be used to perform |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1488 |
time-consuming operations at a more user-friendly priority." |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1489 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1490 |
^ self withPriority:(Processor userBackgroundPriority) do:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1491 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1492 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1493 |
Processor activeProcess withUserBackgroundPriorityDo:[3000 factorial] |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1494 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1495 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1496 |
"Created: 6.8.1997 / 15:40:02 / cg" |
202 | 1497 |
! ! |
1498 |
||
5256 | 1499 |
!Process methodsFor:'startup'! |
116 | 1500 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1501 |
imageRestart |
699 | 1502 |
"restart the process from the beginning. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1503 |
This is sent by the ProcessorScheduler at image restart time, |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1504 |
to all restartable processes." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1505 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1506 |
|savedGroupId| |
699 | 1507 |
|
1508 |
"/ ('restart process ' , id printString) errorPrintNL. |
|
1509 |
||
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1510 |
savedGroupId := processGroupId. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1511 |
|
699 | 1512 |
(Processor newProcessFor:self withId:id) ifFalse:[ |
5450 | 1513 |
"for some reason, the Processor was unable to create |
1514 |
a VM process for me ...." |
|
699 | 1515 |
|
5450 | 1516 |
('Process [warning]: process ' , id printString , ' failed to restart.') errorPrintCR. |
1517 |
^ nil |
|
699 | 1518 |
]. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1519 |
processGroupId := savedGroupId. |
699 | 1520 |
self resume |
1086 | 1521 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1522 |
"Created: 28.10.1996 / 20:32:34 / cg" |
2130
b9e7e1cf98bd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1523 |
"Modified: 10.1.1997 / 18:01:13 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1524 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1525 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1526 |
restart |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1527 |
"restart the process from the beginning. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1528 |
This is only possible, if its restartable." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1529 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1530 |
restartable ifFalse:[ |
5450 | 1531 |
^ self error:'process is not restartable' mayProceed:true |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1532 |
]. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1533 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1534 |
self interruptWith:[RestartSignal raise] |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1535 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1536 |
"Modified: 12.1.1997 / 00:54:32 / cg" |
699 | 1537 |
! |
1538 |
||
116 | 1539 |
start |
159 | 1540 |
"start the process - this is sent by the VM to the process to get |
1541 |
the process up and running. |
|
329 | 1542 |
Sending #start to the process (instead of directly executing the startBlock) |
1543 |
allows more flexible handling of processes, since anything that responds |
|
1544 |
to #start can be handled transparently by the VM then ..." |
|
159 | 1545 |
|
1546 |
|block| |
|
116 | 1547 |
|
159 | 1548 |
(block := startBlock) notNil ifTrue:[ |
6219 | 1549 |
"/ |
1550 |
"/ just for your convenience ... |
|
1551 |
"/ |
|
1552 |
name isNil ifTrue:[ |
|
1553 |
name := '(' , block displayString , ')' |
|
1554 |
]. |
|
1555 |
restartable ~~ true ifTrue:[startBlock := nil]. |
|
1839 | 1556 |
|
6219 | 1557 |
[ |
1558 |
"/ |
|
1559 |
"/ handle Process-Termination, Process-Restart and Abort |
|
1560 |
"/ |
|
1561 |
CoughtSignals handle:[:ex | |
|
1562 |
ex signal == RestartProcessRequest ifTrue:[ |
|
1563 |
ex restart |
|
1564 |
]. |
|
1565 |
ex return |
|
1566 |
] do:[ |
|
1567 |
exceptionHandlerSet isNil ifTrue:[ |
|
1568 |
exceptionHandlerSet := ExceptionHandlerSet new. |
|
1569 |
]. |
|
1570 |
"/ |
|
1571 |
"/ block is the one which received the fork some time ago... |
|
1572 |
"/ |
|
1573 |
exceptionHandlerSet handleDo:block |
|
1574 |
] |
|
1575 |
] valueOnUnwindDo:[self terminateNoSignal]. |
|
202 | 1576 |
|
6219 | 1577 |
self terminateNoSignal. |
159 | 1578 |
] ifFalse:[ |
6219 | 1579 |
"is this artificial restriction useful ?" |
1580 |
self error:'a process cannot be started twice' mayProceed:true |
|
116 | 1581 |
] |
1475 | 1582 |
|
6219 | 1583 |
"Modified: / 17.11.2001 / 16:45:32 / cg" |
1 | 1584 |
! ! |
1585 |
||
1586 |
!Process methodsFor:'suspend / resume'! |
|
1587 |
||
5592 | 1588 |
abort |
1589 |
"raise an obortSignal in the receiver process. |
|
1590 |
Most processes willing to handle this will return to some save state |
|
1591 |
(typically, some kind of event loop). |
|
1592 |
If not handled, this will result in termination of the process." |
|
1593 |
||
1594 |
Processor activeProcess == self ifTrue:[ |
|
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5870
diff
changeset
|
1595 |
AbortOperationRequest raiseRequest |
5592 | 1596 |
] ifFalse:[ |
1597 |
self interruptWith:[ |
|
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5870
diff
changeset
|
1598 |
AbortOperationRequest raiseRequest |
5592 | 1599 |
]. |
1600 |
] |
|
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5870
diff
changeset
|
1601 |
|
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5870
diff
changeset
|
1602 |
"Modified: / 16.11.2001 / 17:39:18 / cg" |
5592 | 1603 |
! |
1604 |
||
699 | 1605 |
resume |
1606 |
"resume the receiver process" |
|
1607 |
||
4002
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1608 |
state == #stopped ifTrue:[ |
5450 | 1609 |
state := #run. |
4002
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1610 |
]. |
699 | 1611 |
Processor resume:self |
1612 |
! |
|
1613 |
||
1614 |
resumeForSingleSend |
|
1615 |
"resume the receiver process, but only let it execute a single send." |
|
1616 |
||
1617 |
Processor resumeForSingleSend:self |
|
1618 |
! |
|
1619 |
||
326 | 1620 |
stop |
1621 |
"suspend the receiver process - will continue to run when a resume is sent. |
|
1622 |
A stopped process will not be resumed for interrupt processing." |
|
1623 |
||
3679 | 1624 |
"/ state := #stopped. |
1625 |
self suspendWithState:#stopped |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1626 |
|
3679 | 1627 |
"Modified: / 13.12.1995 / 13:22:58 / stefan" |
1628 |
"Modified: / 27.7.1998 / 23:37:15 / cg" |
|
326 | 1629 |
! |
1630 |
||
1 | 1631 |
suspend |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1632 |
"suspend the receiver process - it will continue to run when a resume is sent. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1633 |
Notice, that an interrupt will also resume the receiver, |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1634 |
so any waiting code should be prepared for premature return from |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1635 |
a suspend (see wait code in Semaphore). |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1636 |
Use #stop for a hard-suspend, which is not affected by interrupts." |
13 | 1637 |
|
1474 | 1638 |
self suspendWithState:#suspended |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1639 |
|
1474 | 1640 |
"Modified: 17.6.1996 / 14:41:34 / cg" |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1641 |
! |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1642 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1643 |
suspendWithState:aStateSymbol |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1644 |
"like suspend, this suspends the receiver process until a resume is sent. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1645 |
This sets the state to the argument, aStateSymbol, which is shown |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1646 |
in the ProcessMonitor (instead of #suspended). |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1647 |
(i.e. no new functionality, but a bit more debuggability) |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1648 |
Notice, that an interrupt will also resume the receiver, |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1649 |
so any waiting code should be prepared for premature return from |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1650 |
a suspend (see wait code in Semaphore). |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1651 |
Use #stop for a hard-suspend, which is not affected by interrupts." |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1652 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1653 |
suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1654 |
suspendActions notNil ifTrue:[ |
5450 | 1655 |
suspendActions do:[:action | action value] |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1656 |
]. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1657 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1658 |
" |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1659 |
this is a bit of a kludge: allow someone else to |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1660 |
set the state to something like #ioWait etc. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1661 |
In this case, do not set the receivers state to #suspend. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1662 |
(All of this to enhance the output of the process monitor ...) |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1663 |
" |
4002
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1664 |
(state == #active |
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1665 |
or:[state == #run |
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1666 |
or:[aStateSymbol == #stopped]]) ifTrue:[ |
5450 | 1667 |
state := aStateSymbol. |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1668 |
]. |
1 | 1669 |
Processor suspend:self |
1670 |
! |
|
1671 |
||
1672 |
terminate |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1673 |
"terminate the receiver process. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1674 |
Termination is done by raising the terminateSignal in the receiver process, |
2689 | 1675 |
which can be caught. |
375 | 1676 |
All unwind actions and the exit-actions (if any) |
4415
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
1677 |
will be performed before the process is really terminated. |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
1678 |
Notice, that the terminate actions are performed by the receiver, |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
1679 |
at its current priority. Therefore, in case higher prio processes are |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
1680 |
running, it may take any arbitrary time until the termination is eventually |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
1681 |
done." |
10 | 1682 |
|
2888
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
1683 |
|wasBlocked| |
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
1684 |
|
3293
3f52fbf6b94c
oops - a self-terminating process did not evaluate its
Claus Gittinger <cg@exept.de>
parents:
3094
diff
changeset
|
1685 |
Processor activeProcess ~~ self ifTrue:[ |
5450 | 1686 |
"/ if the receiver had no chance to execute yet, |
1687 |
"/ it can be shot down without a signal. |
|
2888
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
1688 |
|
5450 | 1689 |
wasBlocked := OperatingSystem blockInterrupts. |
1690 |
[ |
|
1691 |
state == #osWait ifTrue:[ |
|
1692 |
self terminateNoSignal. |
|
1693 |
^ self. |
|
1694 |
]. |
|
3776
87eda283dab1
fix terminate while in osWait (win32)
Claus Gittinger <cg@exept.de>
parents:
3723
diff
changeset
|
1695 |
|
5450 | 1696 |
self suspendedContext isNil ifTrue:[ |
1697 |
self terminateNoSignal. |
|
1698 |
^ self |
|
1699 |
] |
|
1700 |
] valueNowOrOnUnwindDo:[ |
|
1701 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts] |
|
1702 |
]. |
|
3293
3f52fbf6b94c
oops - a self-terminating process did not evaluate its
Claus Gittinger <cg@exept.de>
parents:
3094
diff
changeset
|
1703 |
|
5450 | 1704 |
self interruptWith:[ |
1705 |
Signal noHandlerSignal handle:[:ex | |
|
1706 |
ex parameter signal == TerminateSignal ifTrue:[ |
|
1707 |
ex return. |
|
1708 |
]. |
|
1709 |
ex reject. |
|
1710 |
] do:[ |
|
1711 |
TerminateSignal raise. |
|
1712 |
]. |
|
1713 |
self terminateNoSignal. |
|
1714 |
]. |
|
1715 |
self resume |
|
3293
3f52fbf6b94c
oops - a self-terminating process did not evaluate its
Claus Gittinger <cg@exept.de>
parents:
3094
diff
changeset
|
1716 |
] ifFalse:[ |
5450 | 1717 |
"/ terminating myself |
2888
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
1718 |
|
5450 | 1719 |
Signal noHandlerSignal handle:[:ex | |
1720 |
ex parameter signal == TerminateSignal ifTrue:[ |
|
1721 |
ex return. |
|
1722 |
]. |
|
1723 |
ex reject. |
|
1724 |
] do:[ |
|
1725 |
TerminateSignal raise. |
|
1726 |
]. |
|
1727 |
self terminateNoSignal. |
|
159 | 1728 |
] |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1729 |
|
3776
87eda283dab1
fix terminate while in osWait (win32)
Claus Gittinger <cg@exept.de>
parents:
3723
diff
changeset
|
1730 |
"Modified: / 24.8.1998 / 18:29:46 / cg" |
159 | 1731 |
! |
1732 |
||
4875 | 1733 |
terminateAllGUISubprocesses |
1734 |
"terminate all the receivers gui subprocesses and their children as well |
|
5683
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1735 |
(i.e. all processes which are offsprings of the receiver, except for |
4875 | 1736 |
the receiver itself)." |
1737 |
||
5377 | 1738 |
id isNil ifTrue:[ |
5683
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1739 |
"/ problem: |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1740 |
"/ if receiver is already dead, its id is nil. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1741 |
"/ children are found by looking for processes with a parentID identical to |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1742 |
"/ mine - ifNil, system processes are found, which is probably not what you |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1743 |
"/ want ... |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1744 |
"/ FIX: remember the id (or dont nil it when terminating) |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1745 |
"/ requires VM changes. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1746 |
self error:'process is already dead - cannot determine child processes'. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1747 |
^ self |
5377 | 1748 |
]. |
4875 | 1749 |
ProcessorScheduler knownProcesses do:[:aProcess | |
5683
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1750 |
aProcess ~~ self ifTrue:[ |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1751 |
aProcess creatorId == id ifTrue:[ |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1752 |
aProcess isGUIProcess ifTrue:[ |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1753 |
aProcess terminateWithAllGUISubprocesses |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1754 |
] |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1755 |
] |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1756 |
] |
4875 | 1757 |
]. |
1758 |
||
1759 |
"Created: / 28.10.1996 / 20:43:32 / cg" |
|
5812
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1760 |
"Modified: / 3.11.1997 / 00:28:06 / cg" |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1761 |
! |
4875 | 1762 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1763 |
terminateAllSubprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1764 |
"terminate all the receivers subprocesses and their children as well |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1765 |
(i.e. all processes in the receivers process group, except for |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1766 |
the receiver itself)." |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1767 |
|
5377 | 1768 |
id isNil ifTrue:[ |
5812
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1769 |
"/ problem: |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1770 |
"/ if receiver is already dead, its id is nil. |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1771 |
"/ children are found by looking for processes with a parentID identical to |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1772 |
"/ mine - ifNil, system processes are found, which is probably not what you |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1773 |
"/ want ... |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1774 |
"/ FIX: remember the id (or dont nil it when terminating) |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1775 |
"/ requires VM changes. |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1776 |
self error:'process is already dead - cannot determine child processes' mayProceed:true. |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1777 |
^ self |
5377 | 1778 |
]. |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1779 |
ProcessorScheduler knownProcesses do:[:aProcess | |
5812
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1780 |
aProcess ~~ self ifTrue:[ |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1781 |
("aProcess processGroupId == processGroupId |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1782 |
or:["aProcess processGroupId == id"]") ifTrue:[ |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1783 |
aProcess terminateWithAllSubprocesses |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1784 |
] |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1785 |
] |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1786 |
]. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1787 |
|
3094
647219dc860b
avoid endless recursion in terminateAllSubProcesses
Claus Gittinger <cg@exept.de>
parents:
3013
diff
changeset
|
1788 |
"Created: / 28.10.1996 / 20:43:32 / cg" |
647219dc860b
avoid endless recursion in terminateAllSubProcesses
Claus Gittinger <cg@exept.de>
parents:
3013
diff
changeset
|
1789 |
"Modified: / 3.11.1997 / 00:28:06 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1790 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1791 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1792 |
terminateGroup |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1793 |
"terminate the receiver with all of its created subprocesses |
5683
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1794 |
that are in the receivers process group." |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1795 |
|
5683
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1796 |
id isNil ifTrue:[ |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1797 |
"/ problem: |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1798 |
"/ if receiver is already dead, its id is nil. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1799 |
"/ children are found by looking for processes with a parentID identical to |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1800 |
"/ mine - ifNil, system processes are found, which is probably not what you |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1801 |
"/ want ... |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1802 |
"/ FIX: remember the id (or dont nil it when terminating) |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1803 |
"/ requires VM changes. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1804 |
self error:'process is already dead - cannot determine child processes'. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1805 |
^ self |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1806 |
]. |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1807 |
ProcessorScheduler knownProcesses do:[:aProcess | |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1808 |
aProcess ~~ self ifTrue:[ |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1809 |
aProcess processGroupId == id ifTrue:[ |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1810 |
aProcess terminate |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1811 |
] |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1812 |
] |
3312d4d798dc
terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents:
5681
diff
changeset
|
1813 |
]. |
5812
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1814 |
self terminate |
e23a3fdc75cb
already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents:
5683
diff
changeset
|
1815 |
! |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1816 |
|
159 | 1817 |
terminateNoSignal |
2197 | 1818 |
"hard-terminate the receiver process without sending a terminateSignal |
375 | 1819 |
or performing any unwind-handling. |
2197 | 1820 |
However, exit-actions are performed. |
1821 |
This is useful in case of emergency, when a buggy terminationHandler |
|
1822 |
prevents you from getting a process to terminate." |
|
375 | 1823 |
|
1824 |
|block| |
|
159 | 1825 |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1826 |
"/ this is treated like the final suspend |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1827 |
suspendActions notNil ifTrue:[ |
5450 | 1828 |
[suspendActions isEmpty] whileFalse:[ |
1829 |
block := suspendActions removeFirst. |
|
1830 |
block value. |
|
1831 |
] |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1832 |
]. |
375 | 1833 |
exitActions notNil ifTrue:[ |
5450 | 1834 |
[exitActions isEmpty] whileFalse:[ |
1835 |
block := exitActions removeFirst. |
|
1836 |
block value. |
|
1837 |
] |
|
375 | 1838 |
]. |
329 | 1839 |
suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. |
159 | 1840 |
Processor terminateNoSignal:self |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1841 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1842 |
"Modified: 13.12.1995 / 13:40:14 / stefan" |
2384 | 1843 |
"Modified: 12.2.1997 / 12:41:38 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1844 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1845 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1846 |
terminateSubprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1847 |
"terminate all the receivers subprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1848 |
(i.e. all processes in the receivers process group, except for |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1849 |
the receiver itself)." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1850 |
|
5377 | 1851 |
id isNil ifTrue:[ |
5450 | 1852 |
"/ problem: |
1853 |
"/ if receiver is already dead, its id is nil. |
|
1854 |
"/ children are found by looking for processes with a parentID identical to |
|
1855 |
"/ mine - ifNil, system processes are found, which is probably not what you |
|
1856 |
"/ want ... |
|
1857 |
"/ FIX: remember the id (or dont nil it when terminating) |
|
1858 |
"/ requires VM changes. |
|
1859 |
self error:'process is already dead - cannot determine child processes'. |
|
1860 |
^ self |
|
5377 | 1861 |
]. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1862 |
ProcessorScheduler knownProcesses do:[:aProcess | |
5450 | 1863 |
aProcess ~~ self ifTrue:[ |
1864 |
(aProcess processGroupId == processGroupId |
|
1865 |
or:[aProcess processGroupId == id]) ifTrue:[ |
|
1866 |
aProcess terminate |
|
1867 |
] |
|
1868 |
] |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1869 |
]. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1870 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1871 |
"Created: 28.10.1996 / 20:41:49 / cg" |
2891 | 1872 |
"Modified: 26.8.1997 / 03:09:57 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1873 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1874 |
|
4875 | 1875 |
terminateWithAllGUISubprocesses |
1876 |
"terminate the receiver with all of its created gui subprocesses and their gui children |
|
1877 |
(i.e. all processes in the receivers process group)." |
|
1878 |
||
1879 |
self terminateAllGUISubprocesses. |
|
1880 |
self terminate |
|
1881 |
||
1882 |
"Modified: 28.10.1996 / 20:42:00 / cg" |
|
1883 |
"Created: 28.10.1996 / 20:44:07 / cg" |
|
1884 |
! |
|
1885 |
||
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1886 |
terminateWithAllSubprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1887 |
"terminate the receiver with all of its created subprocesses and their children |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1888 |
(i.e. all processes in the receivers process group)." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1889 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1890 |
self terminateAllSubprocesses. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1891 |
self terminate |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1892 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1893 |
"Modified: 28.10.1996 / 20:42:00 / cg" |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1894 |
"Created: 28.10.1996 / 20:44:07 / cg" |
1 | 1895 |
! ! |
1896 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
1897 |
!Process class methodsFor:'documentation'! |
159 | 1898 |
|
699 | 1899 |
version |
6322 | 1900 |
^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.125 2001-12-14 10:54:51 cg Exp $' |
159 | 1901 |
! ! |
699 | 1902 |
Process initialize! |