author | Claus Gittinger <cg@exept.de> |
Thu, 28 Sep 2000 21:25:55 +0200 | |
changeset 5643 | 0fe1ec12c5e8 |
parent 5592 | d1b0db212b9d |
child 5675 | 34d5b32f9259 |
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:[ |
|
5450 | 315 |
TerminateSignal := Signal new mayProceed:true. |
316 |
TerminateSignal nameClass:self message:#terminateSignal. |
|
317 |
TerminateSignal notifierString:'unhandled process termination'. |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
318 |
|
5450 | 319 |
RestartSignal := Signal new mayProceed:true. |
320 |
RestartSignal nameClass:self message:#restartSignal. |
|
321 |
RestartSignal notifierString:'unhandled process restart'. |
|
302 | 322 |
|
5450 | 323 |
CoughtSignals := SignalSet |
324 |
with:AbortSignal |
|
325 |
with:TerminateSignal |
|
326 |
with:RestartSignal. |
|
159 | 327 |
] |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
328 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
329 |
"Modified: 28.10.1996 / 20:39:05 / cg" |
159 | 330 |
! ! |
331 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
332 |
!Process class methodsFor:'instance creation'! |
699 | 333 |
|
334 |
for:aBlock priority:aPrio |
|
335 |
"create a new (unscheduled) process which will execute aBlock at |
|
336 |
a given priority, once scheduled. The process will start execution once |
|
337 |
it gets a #resume-message." |
|
338 |
||
2268
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
339 |
^ self basicNew for:aBlock priority:aPrio |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
340 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
341 |
"Modified: 25.1.1997 / 01:23:12 / cg" |
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 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
344 |
new |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
345 |
"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
|
346 |
method, when scheduled. The process will start execution once |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
347 |
it gets a #resume-message." |
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
348 |
|
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
349 |
^ self basicNew for:nil priority:(Processor activePriority). |
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 |
"Created: 25.1.1997 / 01:31:05 / cg" |
699 | 352 |
! ! |
353 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
354 |
!Process class methodsFor:'Signal constants'! |
159 | 355 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
356 |
restartSignal |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
357 |
"return the signal used for process restart" |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
358 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
359 |
^ RestartSignal |
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 |
"Created: 28.10.1996 / 20:26:50 / cg" |
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 |
|
159 | 364 |
terminateSignal |
202 | 365 |
"return the signal used for process termination" |
366 |
||
159 | 367 |
^ TerminateSignal |
368 |
! ! |
|
369 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
370 |
!Process class methodsFor:'defaults'! |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
371 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
372 |
defaultMaximumStackSize |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
373 |
"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
|
374 |
this limit initially. |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
375 |
It may be changed for individual processes with: |
5450 | 376 |
aProcess setMaximumStackSize:limit" |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
377 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
378 |
%{ /* NOCONTEXT */ |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
379 |
|
1352 | 380 |
RETURN ( __MKSMALLINT( __defaultThreadMaxStackSize() )); |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
381 |
%} |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
382 |
|
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 |
Process defaultMaximumStackSize |
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 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
387 |
"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
|
388 |
! |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
389 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
390 |
defaultMaximumStackSize:numberOfBytes |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
391 |
"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
|
392 |
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
|
393 |
It may be changed for individual processes with: |
5450 | 394 |
aProcess setMaximumStackSize:limit |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
395 |
Notice: |
5450 | 396 |
There is seldom any need to change the default setting, |
397 |
except for highly recursive programs." |
|
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
398 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
399 |
%{ /* NOCONTEXT */ |
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 |
if (__isSmallInteger(numberOfBytes)) { |
5450 | 402 |
RETURN ( __MKSMALLINT( __setDefaultThreadSetMaxStackSize(__intVal(numberOfBytes)) )); |
1352 | 403 |
} |
1346
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
404 |
%} |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
405 |
|
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 |
Process defaultMaximumStackSize:500*1024 |
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 |
|
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
410 |
"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
|
411 |
! ! |
429d560b7013
allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
412 |
|
3783
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
413 |
!Process class methodsFor:'instance retrieval'! |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
414 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
415 |
findProcessWithId:id |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
416 |
"return a process with a particular id. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
417 |
This is only a debugging helper, to allow |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
418 |
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
|
419 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
420 |
self allSubInstances do:[:aProcess | aProcess id = id ifTrue:[^ aProcess]]. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
421 |
^ nil |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
422 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
423 |
" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
424 |
Process findProcessWithId:1 |
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 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
427 |
"Modified: / 26.8.1998 / 15:39:55 / cg" |
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 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
430 |
findProcessWithName:name |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
431 |
"return a process with a particular name. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
432 |
This is only a debugging helper, to allow |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
433 |
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
|
434 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
435 |
self allSubInstances do:[:aProcess | aProcess name = name ifTrue:[^ aProcess]]. |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
436 |
^ nil |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
437 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
438 |
" |
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
439 |
Process findProcessWithName:'scheduler' |
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 |
|
5ac905a9a8c0
added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents:
3776
diff
changeset
|
442 |
"Modified: / 26.8.1998 / 15:40:54 / cg" |
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 |
|
1980
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
445 |
!Process methodsFor:'Compatibility - V''Age'! |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
446 |
|
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
447 |
queueInterrupt:aBlock |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
448 |
"VisualAge compatibility: alias for #interruptWith: |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
449 |
arrange for the receiver process to be interrupted and |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
450 |
evaluate aBlock in its interrupt handler." |
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
451 |
|
173122fed8e2
added V'Age compatibility method
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
452 |
^ self interruptWith:aBlock |
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 |
"Created: 15.11.1996 / 11:41:06 / cg" |
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 |
|
699 | 457 |
!Process methodsFor:'accessing'! |
458 |
||
4874
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
459 |
beGUIProcess |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
460 |
"mark the receiver as a gui process. |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
461 |
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
|
462 |
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
|
463 |
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
|
464 |
|
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
465 |
processType := #gui |
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 |
|
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
468 |
beGroupLeader |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
469 |
"make the receiver a processGroupLeader. |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
470 |
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
|
471 |
be terminated when it teminates via #terminateGroup. |
5088 | 472 |
Also, processes forked from a groupLeader belong to that group |
473 |
and can be terminated via #terminateGroup - unless they become |
|
474 |
group leaders themself. |
|
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
475 |
(windowgroup processes do this)." |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
476 |
|
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
477 |
processGroupId := id |
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 |
"Modified: 8.7.1996 / 14:00:35 / cg" |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
480 |
"Created: 8.7.1996 / 14:08:44 / cg" |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
481 |
! |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
482 |
|
2196 | 483 |
beSystemProcess |
484 |
"make the receiver a system process. |
|
485 |
These processes have a groupId of 0. |
|
486 |
When executed as standAlone application, smalltalk exits when |
|
487 |
no more user processes are running. |
|
5088 | 488 |
(i.e. when there are only systemProcesses left) |
2196 | 489 |
To prevent any daemon processes from preventing this exit, |
5088 | 490 |
you should make them systemProcesses" |
2196 | 491 |
|
492 |
processGroupId := 0 |
|
493 |
||
494 |
"Created: 17.1.1997 / 21:42:46 / cg" |
|
495 |
! |
|
496 |
||
699 | 497 |
changePriority:aNumber |
498 |
"same as priority:, but returns the old priority. |
|
818 | 499 |
(cannot do this in #priority: for ST-80 compatibility)" |
699 | 500 |
|
501 |
|oldPrio| |
|
502 |
||
503 |
oldPrio := prio. |
|
504 |
Processor changePriority:aNumber for:self. |
|
505 |
^ oldPrio |
|
818 | 506 |
|
507 |
"Modified: 23.12.1995 / 18:38:53 / cg" |
|
699 | 508 |
! |
509 |
||
1530
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
510 |
creatorId |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
511 |
"return the processcreators id. |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
512 |
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
|
513 |
when debugging." |
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
514 |
|
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
515 |
^ creatorId |
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 |
|
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
518 |
exceptionHandlerSet |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
519 |
"retrieve the exceptionHandlerSet, which includes the set of |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
520 |
exceptionHandlers which are cought by the process. |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
521 |
Initially being empty, this allows for default handlers to be |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
522 |
dynamically added/removed from the set of handled exceptions/queries." |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
523 |
|
4877 | 524 |
exceptionHandlerSet isNil ifTrue:[ |
5450 | 525 |
exceptionHandlerSet := ExceptionHandlerSet new. |
4877 | 526 |
]. |
4646
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
527 |
^ exceptionHandlerSet |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
528 |
! |
8103e1cbce8a
added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
529 |
|
818 | 530 |
id |
531 |
"return the processes id" |
|
532 |
||
533 |
^ id |
|
534 |
! |
|
535 |
||
536 |
name |
|
537 |
"return the processes name" |
|
538 |
||
539 |
^ name |
|
540 |
! |
|
541 |
||
542 |
name:aString |
|
543 |
"set the processes name" |
|
544 |
||
545 |
name := aString |
|
546 |
! |
|
547 |
||
548 |
priority |
|
549 |
"return the receivers priority" |
|
550 |
||
551 |
^ prio |
|
552 |
! |
|
553 |
||
554 |
priority:aNumber |
|
555 |
"set my priority" |
|
556 |
||
557 |
Processor changePriority:aNumber for:self. |
|
558 |
! |
|
559 |
||
3679 | 560 |
priorityRange |
3723 | 561 |
"return my dynamic priority range" |
3679 | 562 |
|
563 |
^ priorityRange |
|
564 |
||
3723 | 565 |
"Modified: / 3.8.1998 / 22:55:53 / cg" |
3679 | 566 |
! |
567 |
||
568 |
priorityRange:anInterval |
|
3723 | 569 |
"change my dynamic priority range" |
3679 | 570 |
|
571 |
priorityRange := anInterval |
|
572 |
||
3723 | 573 |
"Modified: / 3.8.1998 / 22:56:05 / cg" |
3679 | 574 |
! |
575 |
||
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
576 |
processGroupId |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
577 |
"return the processes processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
578 |
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
|
579 |
as the processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
580 |
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
|
581 |
group members are terminated together. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
582 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
583 |
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
|
584 |
killed when the parent terminates (windowgroup processes do this)." |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
585 |
|
1530
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
586 |
^ processGroupId |
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
587 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
588 |
"Created: 8.7.1996 / 13:47:47 / cg" |
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 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
591 |
processGroupId:aGroupLeadersProcessID |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
592 |
"set the processes processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
593 |
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
|
594 |
as the processGroup id. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
595 |
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
|
596 |
group members are terminated together. |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
597 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
598 |
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
|
599 |
killed when the parent terminates (windowgroup processes do this)." |
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
600 |
|
1530
dfa58f01505c
remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents:
1529
diff
changeset
|
601 |
processGroupId := aGroupLeadersProcessID |
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
602 |
|
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
603 |
"Created: 8.7.1996 / 13:47:53 / cg" |
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 |
|
818 | 606 |
restartable:aBoolean |
607 |
"set/clear, the restartable flag. |
|
608 |
Restartable processes will automatically be restarted by the |
|
609 |
ProcessorScheduler upon image restart. |
|
610 |
Others have to be restarted manually." |
|
611 |
||
612 |
startBlock isNil ifTrue:[ |
|
5450 | 613 |
self error:'cannot be made restartable when already started' mayProceed:true. |
614 |
^ self |
|
818 | 615 |
]. |
616 |
restartable := aBoolean |
|
617 |
||
618 |
"Modified: 23.12.1995 / 18:38:32 / cg" |
|
619 |
! |
|
620 |
||
621 |
singleStep:aBoolean |
|
622 |
singleStepping := aBoolean |
|
623 |
! |
|
624 |
||
625 |
startBlock |
|
626 |
"return the processes startup-block" |
|
627 |
||
628 |
^ startBlock |
|
629 |
! |
|
630 |
||
631 |
state |
|
632 |
"return a symbol describing the processes state" |
|
633 |
||
634 |
^ state |
|
635 |
! |
|
636 |
||
637 |
state:aSymbol |
|
638 |
"set the state - only to be used from scheduler" |
|
639 |
||
640 |
state := aSymbol |
|
641 |
! |
|
642 |
||
643 |
suspendedContext |
|
644 |
"return the processes suspended context |
|
645 |
- this is the context from which a process switch into the scheduler |
|
5088 | 646 |
or another process occured. |
647 |
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
|
648 |
had no chance to run yet, nil is returned. |
818 | 649 |
Typically, only the debugger is interested in this one." |
650 |
||
651 |
%{ /* NOCONTEXT */ |
|
652 |
OBJ i; |
|
653 |
||
1133 | 654 |
if (__isSmallInteger(i = __INST(id))) { |
5450 | 655 |
RETURN (__threadContext(__intVal(i))); |
818 | 656 |
} |
657 |
%}. |
|
658 |
^ nil |
|
5088 | 659 |
|
660 |
||
661 |
||
662 |
||
818 | 663 |
! ! |
664 |
||
665 |
!Process methodsFor:'accessing-change notifications'! |
|
666 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
667 |
addExitAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
668 |
"add aBlock to the processes exit actions. |
5088 | 669 |
This block will be evaluated right before the process dies, |
670 |
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
|
671 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
672 |
exitActions isNil ifTrue:[ |
5450 | 673 |
exitActions := OrderedCollection new |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
674 |
]. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
675 |
exitActions add:aBlock |
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 |
"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
|
678 |
! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
679 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
680 |
addSuspendAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
681 |
"add aBlock to the processes suspend actions. |
5088 | 682 |
This block will be evaluated when a process gets suspended. |
683 |
You may ask what that is useful for - it is useful to flush |
|
684 |
buffered graphic commands of a GUI process (i.e. to force xlib |
|
685 |
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
|
686 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
687 |
suspendActions isNil ifTrue:[ |
5450 | 688 |
suspendActions := OrderedCollection new |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
689 |
]. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
690 |
suspendActions add:aBlock |
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 |
"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
|
693 |
"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
|
694 |
! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
695 |
|
699 | 696 |
emergencySignalHandler |
697 |
"return the emergencySignalHandler block. |
|
698 |
See Signal>>documentation for more info." |
|
699 |
||
700 |
^ emergencySignalHandler |
|
701 |
! |
|
702 |
||
703 |
emergencySignalHandler:aOneArgBlock |
|
704 |
"set the emergencySignalHandler block. |
|
705 |
See Signal>>documentation for more info." |
|
706 |
||
707 |
emergencySignalHandler := aOneArgBlock |
|
708 |
! |
|
709 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
710 |
removeAllExitActions |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
711 |
"remove all exit actions." |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
712 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
713 |
exitActions := nil. |
699 | 714 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
715 |
"Created: 12.1.1997 / 00:36:02 / cg" |
699 | 716 |
! |
717 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
718 |
removeAllSuspendActions |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
719 |
"remove all suspend actions." |
699 | 720 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
721 |
suspendActions := nil. |
699 | 722 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
723 |
"Created: 12.1.1997 / 00:36:16 / cg" |
818 | 724 |
! ! |
699 | 725 |
|
818 | 726 |
!Process methodsFor:'accessing-stack'! |
699 | 727 |
|
728 |
maximumStackSize |
|
729 |
"returns the processes stack limit - i.e. the process will be |
|
730 |
interrupted with a recursionSignal-raise, if it ever |
|
731 |
needs more stack (in bytes) than this number" |
|
732 |
||
733 |
%{ /* NOCONTEXT */ |
|
734 |
extern int __threadMaxStackSize(); |
|
735 |
OBJ i; |
|
736 |
||
1133 | 737 |
if (__isSmallInteger(i = __INST(id))) { |
738 |
RETURN( __MKSMALLINT(__threadMaxStackSize(__intVal(i))) ); |
|
699 | 739 |
} |
740 |
%}. |
|
741 |
^ nil |
|
742 |
! |
|
743 |
||
744 |
setMaximumStackSize:limit |
|
745 |
"sets the processes stack limit - i.e. the process will be |
|
746 |
interrupted with a recursionSignal-raise, if it ever |
|
747 |
needs more stack (in bytes) than this number. |
|
748 |
Returns the old value." |
|
749 |
||
750 |
%{ /* NOCONTEXT */ |
|
751 |
extern int __threadSetMaxStackSize(); |
|
752 |
OBJ i; |
|
753 |
||
1133 | 754 |
if (__isSmallInteger(i = __INST(id)) |
699 | 755 |
&& __isSmallInteger(limit) ) { |
1133 | 756 |
RETURN ( __MKSMALLINT(__threadSetMaxStackSize(__intVal(i), __intVal(limit))) ); |
699 | 757 |
} |
758 |
%}. |
|
759 |
^ nil |
|
760 |
! |
|
761 |
||
712
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
762 |
setStackInitialSize:initial increment:increment safe:safe |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
763 |
"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
|
764 |
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
|
765 |
|
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
766 |
%{ /* NOCONTEXT */ |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
767 |
extern int __threadSetJunkSizes(); |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
768 |
OBJ i; |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
769 |
|
1133 | 770 |
if (__isSmallInteger(i = __INST(id)) |
712
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
771 |
&& __isSmallInteger(initial) |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
772 |
&& __isSmallInteger(increment) |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
773 |
&& __isSmallInteger(safe)) { |
1133 | 774 |
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
|
775 |
} |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
776 |
%}. |
40906c842cd2
added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
777 |
^ false |
699 | 778 |
! ! |
779 |
||
780 |
!Process methodsFor:'interrupts'! |
|
781 |
||
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
782 |
addInterruptAction:aBlock |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
783 |
"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
|
784 |
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
|
785 |
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
|
786 |
|
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
787 |
|wasBlocked| |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
788 |
|
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
789 |
wasBlocked := OperatingSystem blockInterrupts. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
790 |
interruptActions isNil ifTrue:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
791 |
interruptActions := OrderedCollection with:aBlock. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
792 |
] ifFalse:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
793 |
interruptActions addLast:aBlock. |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
794 |
]. |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
795 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
796 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
797 |
! |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
798 |
|
2725
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
799 |
blockInterrupts |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
800 |
"disable interrupt processing for the receiver process |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
801 |
- 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
|
802 |
soon as interrupts are reenabled via unblockInterrupts. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
803 |
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
|
804 |
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
|
805 |
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
|
806 |
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
|
807 |
affects interrupts for the receiver process |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
808 |
(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
|
809 |
|
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
810 |
|disabledBefore| |
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 := interruptsDisabled. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
813 |
interruptsDisabled := true. |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
814 |
^ disabledBefore ? false |
2726 | 815 |
|
816 |
" |
|
817 |
|p1| |
|
818 |
||
819 |
p1 := [ |
|
5450 | 820 |
Transcript showCR:'disabled ...'. |
821 |
Transcript showCR:Processor activeProcess blockInterrupts. |
|
822 |
Transcript showCR:'busy ...'. |
|
823 |
Delay waitForSeconds:10. |
|
824 |
Transcript showCR:'enabled ...'. |
|
825 |
Processor activeProcess unblockInterrupts. |
|
826 |
] forkAt:9. |
|
2726 | 827 |
|
828 |
p1 interruptWith:[Transcript showCR:'interrupted']. |
|
829 |
" |
|
2725
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
830 |
! |
f5419dbc5f32
allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
831 |
|
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
832 |
forceInterruptOnReturnOf:aContext |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
833 |
"helper entry for debugger. Force a stepInterrupt whenever aContext |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
834 |
returns either directly or via an unwind." |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
835 |
|
1728 | 836 |
aContext markForInterruptOnUnwind. |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
837 |
%{ |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
838 |
OBJ i; |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
839 |
|
1133 | 840 |
if (__isSmallInteger(i = __INST(id))) { |
5450 | 841 |
__threadContextStepInterrupt(__intVal(i), 1); |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
842 |
} |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
843 |
%} |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
844 |
|
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
845 |
! |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
846 |
|
5491 | 847 |
hasInterruptActions |
848 |
"return true, if there are any interrupt actions to evaluate |
|
849 |
(i.e. if the receiver has been interrupted)." |
|
850 |
||
851 |
^ interruptActions size > 0 |
|
852 |
! |
|
853 |
||
699 | 854 |
interrupt |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
855 |
"evaluate my interrupt-actions. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
856 |
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
|
857 |
after doing this." |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
858 |
|
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
859 |
|action wasBlocked| |
699 | 860 |
|
1165
c9108e9a4fdd
just to make certain: disable interrupts when removing interruptAction
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
861 |
[interruptActions size > 0] whileTrue:[ |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
862 |
wasBlocked := OperatingSystem blockInterrupts. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
863 |
action := interruptActions removeFirst. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
864 |
interruptActions size == 0 ifTrue:[interruptActions := nil]. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
865 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
866 |
|
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
867 |
action numArgs == 1 ifTrue:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
868 |
action value:thisContext sender |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
869 |
] ifFalse:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
870 |
action value |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
871 |
] |
699 | 872 |
]. |
873 |
! |
|
874 |
||
875 |
interruptWith:aBlock |
|
876 |
"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
|
877 |
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
|
878 |
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
|
879 |
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
|
880 |
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
|
881 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
882 |
Processor activeProcess == self ifTrue:[ |
5450 | 883 |
aBlock value |
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
884 |
] ifFalse:[ |
5450 | 885 |
self addInterruptAction:aBlock. |
886 |
Processor scheduleForInterrupt:self. |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
887 |
] |
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
888 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
889 |
"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
|
890 |
! |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
891 |
|
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
892 |
interruptedIn:aContext |
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
893 |
"evaluate my interrupt-actions. |
2724 | 894 |
This is indirectly called by the VM, when some #interruptWith: action |
895 |
was scheduled for the process, and the process is resumed. |
|
896 |
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
|
897 |
|
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
898 |
|action wasBlocked| |
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
899 |
|
2727 | 900 |
"/ the returned value here has a subtle effect: |
901 |
"/ if false, the interrupt is assumed to be not taken, |
|
902 |
"/ and will be redelivered. |
|
903 |
||
2724 | 904 |
interruptsDisabled == true ifTrue:[ |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
905 |
"/ no, I dont want interrupts right now; |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
906 |
"/ try again later. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
907 |
^ false |
2724 | 908 |
]. |
909 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
910 |
[interruptActions size > 0] whileTrue:[ |
5490
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
911 |
wasBlocked := OperatingSystem blockInterrupts. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
912 |
action := interruptActions removeFirst. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
913 |
interruptActions size == 0 ifTrue:[interruptActions := nil]. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
914 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
915 |
|
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
916 |
action numArgs == 1 ifTrue:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
917 |
action value:aContext |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
918 |
] ifFalse:[ |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
919 |
action value |
38880aca9320
race when manipulating interruptActions
Claus Gittinger <cg@exept.de>
parents:
5450
diff
changeset
|
920 |
] |
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
921 |
]. |
2724 | 922 |
^ true |
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
923 |
|
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
924 |
"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
|
925 |
"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
|
926 |
! |
699 | 927 |
|
1092
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
928 |
onResumeDo:aBlock |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
929 |
"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
|
930 |
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
|
931 |
(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
|
932 |
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
|
933 |
when it awakes." |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
934 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
935 |
self addInterruptAction:aBlock. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
936 |
Processor scheduleInterruptActionsOf:self. |
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
937 |
|
2a8acc60f5b5
added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents:
1086
diff
changeset
|
938 |
"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
|
939 |
"Modified: 8.3.1996 / 13:01:21 / cg" |
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
940 |
! |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
941 |
|
2857
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
942 |
stepInterruptHandler:anObject |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
943 |
"set the handler for stepInterrupts occurring in the receiver process. |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
944 |
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
|
945 |
stepInterrupts. Returns the previous handler. |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
946 |
Not for general use." |
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 |
%{ /* NOCONTEXT */ |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
949 |
extern OBJ __threadStepInterruptHandler(); |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
950 |
|
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
951 |
RETURN( __threadStepInterruptHandler(anObject) ); |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
952 |
%} |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
953 |
! |
2e9e294d679c
allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents:
2845
diff
changeset
|
954 |
|
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
955 |
unblockInterrupts |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
956 |
"enable interrupt processing for the receiver process |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
957 |
- if any interrupts are pending, these will be handled immediately. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
958 |
When unblocking interrupts, take care of nested block/unblock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
959 |
calls - you should only unblock after a blockcall if they where |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
960 |
really not blocked before. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
961 |
This is similar to OperatingSystem>>unblockInterrupts, but only |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
962 |
affects interrupts for the receiver process |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
963 |
(i.e. those which are installed via #interruptWith:)" |
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 |
interruptsDisabled := false. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
966 |
interruptActions size > 0 ifTrue:[ |
5450 | 967 |
Processor activeProcess == self ifTrue:[ |
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
968 |
self interrupt |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
969 |
] |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
970 |
] |
699 | 971 |
! ! |
972 |
||
973 |
!Process methodsFor:'monitoring'! |
|
974 |
||
975 |
numberOfStackBoundaryHits |
|
976 |
"internal monitoring only - will vanish" |
|
977 |
||
978 |
%{ /* NOCONTEXT */ |
|
979 |
extern int __threadNumberOfStackBoundaryHits(); |
|
980 |
int n; |
|
981 |
OBJ i; |
|
159 | 982 |
|
1133 | 983 |
if (__isSmallInteger(i = __INST(id))) { |
984 |
n = __threadNumberOfStackBoundaryHits(__intVal(i)); |
|
699 | 985 |
n &= 0x3FFFFFFF; |
1133 | 986 |
RETURN( __MKSMALLINT(n) ); |
699 | 987 |
} |
988 |
%}. |
|
989 |
^ nil |
|
990 |
! |
|
991 |
||
992 |
numberOfStackSegments |
|
993 |
"return the processes number of stack segments currently used. |
|
994 |
This method is for monitoring purposes only - it may vanish." |
|
995 |
||
996 |
%{ /* NOCONTEXT */ |
|
997 |
extern int __threadTotalStackSize(); |
|
998 |
OBJ i; |
|
999 |
||
1133 | 1000 |
if (__isSmallInteger(i = __INST(id))) { |
1001 |
RETURN( __MKSMALLINT(__threadStackSegments(__intVal(i))) ); |
|
699 | 1002 |
} |
1003 |
%}. |
|
1004 |
^ nil |
|
1005 |
! |
|
1006 |
||
1007 |
totalStackSize |
|
1008 |
"return the processes maximum used stack size. |
|
1009 |
This method is for monitoring purposes only - it may vanish." |
|
1010 |
||
1011 |
%{ /* NOCONTEXT */ |
|
1012 |
extern int __threadTotalStackSize(); |
|
1013 |
OBJ i; |
|
1014 |
||
1133 | 1015 |
if (__isSmallInteger(i = __INST(id))) { |
1016 |
RETURN( __MKSMALLINT(__threadTotalStackSize(__intVal(i))) ); |
|
699 | 1017 |
} |
1018 |
%}. |
|
1019 |
^ nil |
|
1020 |
! |
|
1021 |
||
1022 |
usedStackSize |
|
1023 |
"Return the processes current stack size. |
|
1024 |
This method is for monitoring purposes only - it may vanish." |
|
1025 |
||
1026 |
%{ /* NOCONTEXT */ |
|
1027 |
extern int __threadUsedStackSize(); |
|
1028 |
OBJ i; |
|
1029 |
||
1133 | 1030 |
if (__isSmallInteger(i = __INST(id))) { |
1031 |
RETURN( __MKSMALLINT(__threadUsedStackSize(__intVal(i))) ); |
|
699 | 1032 |
} |
1033 |
%}. |
|
1034 |
^ nil |
|
1035 |
! |
|
1036 |
||
1037 |
vmTrace:aBoolean |
|
1038 |
"turn on/off VM message tracing for the receiver. |
|
1039 |
This is meant for ST/X debugging, and may vanish. |
|
1040 |
Expect lots of output, once this is turned on." |
|
1041 |
||
1042 |
%{ /* NOCONTEXT */ |
|
1043 |
OBJ i; |
|
1044 |
||
1133 | 1045 |
if (__isSmallInteger(i = __INST(id))) { |
1046 |
__threadTracing(__intVal(i), aBoolean); |
|
699 | 1047 |
} |
1048 |
%}. |
|
1049 |
! ! |
|
1050 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1051 |
!Process methodsFor:'obsolete'! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1052 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1053 |
exitAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1054 |
"Obsoleted by addExitAction: / removeAllExitActions. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1055 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1056 |
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
|
1057 |
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
|
1058 |
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
|
1059 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1060 |
self obsoleteMethodWarning:'use addExitAction: / removeAllExitActions'. |
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 |
aBlock isNil ifTrue:[ |
5450 | 1063 |
^ self removeAllExitActions. |
2158
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 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1066 |
^ self addExitAction:aBlock |
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 |
"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
|
1069 |
"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
|
1070 |
! |
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 |
suspendAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1073 |
"Obsoleted by addSuspendAction: / removeAllSuspendActions. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1074 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1075 |
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
|
1076 |
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
|
1077 |
A nil argument removes all suspendActions." |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1078 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1079 |
self obsoleteMethodWarning:'use addSuspendAction: / removeAllSuspendActions'. |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1080 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1081 |
aBlock isNil ifTrue:[ |
5450 | 1082 |
^ self removeAllSuspendActions. |
2158
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 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1085 |
^ self addSuspendAction:aBlock |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1086 |
|
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1087 |
"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
|
1088 |
! ! |
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1089 |
|
699 | 1090 |
!Process methodsFor:'printing & storing'! |
1091 |
||
1092 |
printOn:aStream |
|
1093 |
"a little more info in my printed representation" |
|
1094 |
||
1095 |
aStream nextPutAll:state article; |
|
1096 |
space; |
|
1097 |
nextPutAll:state; |
|
1098 |
nextPutAll:' Process ('; |
|
1099 |
nextPutAll:self nameOrId; |
|
1100 |
nextPutAll:')' |
|
159 | 1101 |
! ! |
1102 |
||
1103 |
!Process methodsFor:'private'! |
|
1104 |
||
1105 |
for:aBlock priority:aPrio |
|
1106 |
"setup the new process - the receiver is not scheduled for |
|
1107 |
execution, to get it running, send it #resume" |
|
1108 |
||
339 | 1109 |
|nm active| |
159 | 1110 |
|
1111 |
prio := aPrio. |
|
1112 |
startBlock := aBlock. |
|
339 | 1113 |
restartable := false. |
159 | 1114 |
|
1115 |
(Processor newProcessFor:self) ifFalse:[ |
|
5450 | 1116 |
"for some reason, the Processor was unable to create |
1117 |
a VM process for me ...." |
|
1118 |
^ nil |
|
159 | 1119 |
]. |
1120 |
||
1121 |
" |
|
1122 |
give me a user-friendly name |
|
1123 |
" |
|
339 | 1124 |
active := Processor activeProcess. |
2268
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
1125 |
(nm := active name) notNil ifTrue:[ |
5450 | 1126 |
" |
1127 |
avoid name inflation |
|
1128 |
" |
|
1129 |
(nm endsWith:' sub') ifFalse:[ |
|
1130 |
nm := nm , ' [' , active id printString , '] sub' |
|
1131 |
]. |
|
1132 |
name := nm |
|
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
1133 |
]. |
4880 | 1134 |
processGroupId := creatorId := active id. |
1135 |
"/ since groupId is used to detect a systemProcess (0), |
|
1136 |
"/ do not allow a 0 here; need an explicit beSystemProcess. |
|
1137 |
processGroupId == 0 ifTrue:[processGroupId := nil]. |
|
1529
0ba3d19f90d6
set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
1138 |
|
2268
e7e1f98c3bce
allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents:
2262
diff
changeset
|
1139 |
"Modified: 25.1.1997 / 01:28:54 / cg" |
159 | 1140 |
! ! |
1141 |
||
699 | 1142 |
!Process methodsFor:'private scheduler access'! |
1 | 1143 |
|
699 | 1144 |
setId:idNumber state:stateSymbol |
1145 |
"set id and state - not for public use" |
|
375 | 1146 |
|
699 | 1147 |
id := idNumber. |
4880 | 1148 |
creatorId := 0. |
1149 |
processGroupId := nil. |
|
699 | 1150 |
state := stateSymbol. |
1844 | 1151 |
|
1152 |
"Modified: 30.10.1996 / 00:35:29 / cg" |
|
182 | 1153 |
! |
1154 |
||
159 | 1155 |
setPriority:aNumber |
1156 |
"set priority without telling processor - not for public use" |
|
1157 |
||
1158 |
prio := aNumber |
|
1159 |
! |
|
1160 |
||
1161 |
setStartBlock:aBlock |
|
1162 |
"set the receivers startup block" |
|
1163 |
||
1164 |
startBlock := aBlock |
|
1165 |
! |
|
13 | 1166 |
|
159 | 1167 |
setStateTo:newState if:oldState |
1168 |
state == oldState ifTrue:[state := newState] |
|
1169 |
! |
|
1170 |
||
1171 |
setStateTo:newState if:oldState1 or:oldState2 |
|
1172 |
(state == oldState1 or:[state == oldState2]) ifTrue:[state := newState] |
|
699 | 1173 |
! ! |
1174 |
||
818 | 1175 |
!Process methodsFor:'queries'! |
1176 |
||
5397 | 1177 |
isActive |
1178 |
"return true if I am the active process" |
|
1179 |
||
1180 |
^ Processor activeProcess == self |
|
1181 |
! |
|
1182 |
||
818 | 1183 |
isDead |
1184 |
"return true, iff the receiver is a dead process" |
|
1185 |
||
1186 |
^ (state isNil or:[state == #dead]) |
|
1187 |
||
1188 |
"Modified: 23.12.1995 / 18:35:29 / cg" |
|
1189 |
! |
|
1190 |
||
4874
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1191 |
isGUIProcess |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1192 |
"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
|
1193 |
I.e. a windowGroup process. |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1194 |
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
|
1195 |
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
|
1196 |
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
|
1197 |
|
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1198 |
^ processType == #gui |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1199 |
! |
2af584ce2793
added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents:
4735
diff
changeset
|
1200 |
|
818 | 1201 |
isRestartable |
1202 |
"return true, iff the receiver is restartable" |
|
1203 |
||
1204 |
^ restartable |
|
1205 |
! |
|
1206 |
||
1207 |
isSingleStepping |
|
1208 |
^ singleStepping |
|
1209 |
! |
|
1210 |
||
5643 | 1211 |
isStopped |
1212 |
"return true, iff the receiver is stopped" |
|
1213 |
||
1214 |
^ (state == #stopped) |
|
1215 |
||
1216 |
"Modified: 23.12.1995 / 18:35:29 / cg" |
|
1217 |
! |
|
1218 |
||
2636
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1219 |
isSystemProcess |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1220 |
"return true if aProcess is a system process, |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1221 |
which should not be suspended/terminated etc.." |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1222 |
|
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1223 |
^ (Processor isPureEventDriven |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1224 |
or:[id == 0 |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1225 |
or:[processGroupId == 0 |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1226 |
or:[(Display notNil and:[Display dispatchProcess == self]) |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1227 |
]]]) |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1228 |
|
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1229 |
" |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1230 |
Processor activeProcessIsSystemProcess |
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 |
"Created: 17.4.1997 / 12:57:37 / stefan" |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1234 |
! |
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1235 |
|
818 | 1236 |
nameOrId |
1237 |
"return a string to identify the process - either name or id" |
|
1238 |
||
1239 |
name notNil ifTrue:[^ name]. |
|
1240 |
^ id printString |
|
1241 |
! ! |
|
1242 |
||
699 | 1243 |
!Process methodsFor:'special'! |
1244 |
||
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1245 |
millisecondDelay:millis |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1246 |
"suspend the current process for some time. |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1247 |
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
|
1248 |
this blocks the whole smalltalk for the time delta; |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1249 |
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
|
1250 |
|
2636
8cb50e1b0688
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
2384
diff
changeset
|
1251 |
(self isSystemProcess) ifTrue:[ |
5450 | 1252 |
OperatingSystem millisecondDelay:millis |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1253 |
] ifFalse:[ |
5450 | 1254 |
Delay waitForMilliseconds:millis |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1255 |
] |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1256 |
|
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1257 |
"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
|
1258 |
"Modified: 17.4.1997 / 13:02:25 / stefan" |
772
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1259 |
! |
f86b117950c5
non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1260 |
|
699 | 1261 |
trapRestrictedMethods:trap |
1262 |
"Allow/deny the execution of restricted methods. |
|
1263 |
Process specific method restriction is not implemented yet, so this call is |
|
1264 |
redirected to ObjectMemory and causes a system wide restriction. |
|
1265 |
||
1266 |
Notice: method restriction is a nonstandard feature, not supported |
|
1267 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1268 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1269 |
It may change or even vanish (if it shows to be not useful)." |
|
1270 |
||
1271 |
^ObjectMemory trapRestrictedMethods:trap |
|
1272 |
||
1273 |
" |
|
1274 |
Processor activeProcess trapRestrictedMethods:true |
|
1275 |
Processor activeProcess trapRestrictedMethods:false |
|
1276 |
" |
|
1277 |
||
1278 |
"Created: 8.11.1995 / 19:45:04 / stefan" |
|
1279 |
! |
|
1280 |
||
1281 |
uninterruptablyDo:aBlock |
|
1282 |
"execute aBlock with interrupts blocked. |
|
1283 |
This does not prevent preemption by a higher priority processes |
|
1284 |
if any becomes runnable due to the evaluation of aBlock |
|
1285 |
(i.e. if a semaphore is signalled there)." |
|
1286 |
||
1287 |
"we must keep track of blocking-state if this is called nested" |
|
2302 | 1288 |
(OperatingSystem blockInterrupts) ifTrue:[ |
5450 | 1289 |
"/ already blocked |
1290 |
^ aBlock value |
|
2302 | 1291 |
]. |
699 | 1292 |
|
2302 | 1293 |
^ aBlock valueNowOrOnUnwindDo:[OperatingSystem unblockInterrupts] |
159 | 1294 |
! |
1295 |
||
699 | 1296 |
waitUntilSuspended |
1297 |
"wait until the receiver is suspended." |
|
1298 |
||
5377 | 1299 |
self isDead ifFalse:[ |
5450 | 1300 |
[ |
1301 |
"/ must check again - interrupt could have happened |
|
1302 |
"/ and process already terminated. |
|
1303 |
self isDead ifFalse:[ |
|
1304 |
suspendSemaphore isNil ifTrue:[ |
|
1305 |
suspendSemaphore := Semaphore new name:'process suspend' |
|
1306 |
]. |
|
1307 |
suspendSemaphore wait |
|
1308 |
] |
|
1309 |
] valueUninterruptably |
|
5377 | 1310 |
] |
699 | 1311 |
|
1946
370f57e569dc
oops - race in waitUntilSuspended & waitUntilTerminated
Claus Gittinger <cg@exept.de>
parents:
1844
diff
changeset
|
1312 |
"Modified: 8.11.1996 / 23:05:24 / cg" |
699 | 1313 |
! |
1314 |
||
1315 |
waitUntilTerminated |
|
1316 |
"wait until the receiver is terminated. |
|
1317 |
This method allows another process to wait till the receiver finishes." |
|
1318 |
||
1033 | 1319 |
|sema| |
699 | 1320 |
|
5377 | 1321 |
self isDead ifFalse:[ |
5450 | 1322 |
[ |
1323 |
"/ must check again - interrupt could have happened |
|
1324 |
"/ and process already terminated. |
|
1325 |
self isDead ifFalse:[ |
|
1326 |
sema := Semaphore new name:'process termination'. |
|
1327 |
self addExitAction:[sema signal]. |
|
1328 |
sema wait. |
|
1329 |
] |
|
1330 |
] valueUninterruptably |
|
5377 | 1331 |
] |
1033 | 1332 |
|
1789 | 1333 |
" |
1334 |
|p| |
|
1335 |
||
1336 |
p := [10 timesRepeat:[100 factorial]] forkAt:4. |
|
1337 |
||
1338 |
Transcript showCR:'now waiting ...'. |
|
1339 |
p waitUntilTerminated. |
|
1340 |
Transcript showCR:'done.' |
|
1341 |
" |
|
1342 |
||
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1343 |
"Modified: 12.1.1997 / 00:40:59 / cg" |
699 | 1344 |
! |
1345 |
||
4735
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1346 |
waitUntilTerminatedWithTimeout:secondsOrNil |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1347 |
"wait until the receiver is terminated or (if non-nil) until |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1348 |
the time period exired. Returns true if a timeout occurred. |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1349 |
This method allows another process to wait till the receiver finishes |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1350 |
(optionally) within some time." |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1351 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1352 |
|sema didTimeout| |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1353 |
|
5377 | 1354 |
self isDead ifFalse:[ |
5450 | 1355 |
[ |
1356 |
"/ must check again - interrupt could have happened |
|
1357 |
"/ and process already terminated. |
|
1358 |
self isDead ifFalse:[ |
|
1359 |
sema := Semaphore new name:'process termination'. |
|
1360 |
self addExitAction:[sema signal]. |
|
1361 |
secondsOrNil isNil ifTrue:[ |
|
1362 |
sema wait |
|
1363 |
] ifFalse:[ |
|
1364 |
didTimeout := (sema waitWithTimeout:secondsOrNil) isNil |
|
1365 |
] |
|
1366 |
] |
|
1367 |
] valueUninterruptably. |
|
5377 | 1368 |
]. |
1369 |
^ didTimeout == true |
|
4735
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1370 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1371 |
" |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1372 |
|p| |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1373 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1374 |
p := [10 timesRepeat:[10000 factorial]] forkAt:4. |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1375 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1376 |
Transcript showCR:'now waiting ...'. |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1377 |
(p waitUntilTerminatedWithTimeout:2) ifTrue:[ |
5450 | 1378 |
Transcript showCR:'timeout occurred.' |
4735
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 |
" |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1381 |
|
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1382 |
"Modified: 12.1.1997 / 00:40:59 / cg" |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1383 |
! |
f4aad6d584d1
added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents:
4646
diff
changeset
|
1384 |
|
699 | 1385 |
withLowerPriorityDo:aBlock |
1386 |
"execute aBlock at a lower priority. This can be used to perform |
|
1387 |
time-consuming operations at a more user-friendly priority." |
|
159 | 1388 |
|
699 | 1389 |
^ self withPriority:(prio - 1) do:aBlock |
1390 |
||
1391 |
" |
|
1392 |
Processor activeProcess withLowerPriorityDo:[3000 factorial] |
|
1393 |
" |
|
1394 |
! |
|
1395 |
||
1396 |
withPriority:aPrio do:aBlock |
|
1397 |
"execute aBlock at another priority. This can be used to perform |
|
1398 |
time-consuming operations at a more user-friendly priority, |
|
1399 |
or some critical action at a higher priority. Do not use too high |
|
1400 |
of a priority to avoid locking up the system (event processing takes place |
|
1401 |
at 24)" |
|
1402 |
||
1403 |
|oldprio| |
|
1404 |
||
1405 |
oldprio := prio. |
|
1406 |
self priority:aPrio. |
|
1407 |
||
1408 |
^ aBlock valueNowOrOnUnwindDo:[ |
|
1409 |
self priority:oldprio |
|
1410 |
] |
|
1411 |
||
1412 |
" |
|
1413 |
Processor activeProcess withPriority:7 do:[3000 factorial] |
|
1414 |
" |
|
1415 |
"be careful - even ^C wont work until done: |
|
1416 |
Processor activeProcess withPriority:25 do:[3000 factorial] |
|
1417 |
" |
|
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1418 |
! |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1419 |
|
4433 | 1420 |
withPriority:lowPrio to:highPrio do:aBlock |
1421 |
"execute aBlock at a priority range. This can be used to perform |
|
1422 |
time-consuming operations at a more user-friendly priority, |
|
1423 |
or some critical action at a higher priority. Do not use too high |
|
1424 |
of a priority to avoid locking up the system (event processing takes place |
|
1425 |
at 24)" |
|
1426 |
||
1427 |
|oldprio oldRange| |
|
1428 |
||
1429 |
oldprio := prio. |
|
1430 |
oldRange := priorityRange. |
|
1431 |
self priorityRange:(lowPrio to:highPrio). |
|
1432 |
self priority:lowPrio. |
|
1433 |
||
1434 |
^ aBlock valueNowOrOnUnwindDo:[ |
|
5450 | 1435 |
self priorityRange:oldRange. |
1436 |
self priority:oldprio. |
|
4433 | 1437 |
] |
1438 |
||
1439 |
" |
|
1440 |
Processor activeProcess withPriority:7 to:8 do:[3000 factorial] |
|
1441 |
" |
|
1442 |
! |
|
1443 |
||
2839
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1444 |
withSystemBackgroundPriorityDo:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1445 |
"execute aBlock at system background priority. |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1446 |
This can be used to perform |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1447 |
background operations at a more user-friendly priority." |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1448 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1449 |
^ self withPriority:(Processor systemBackgroundPriority) do:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1450 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1451 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1452 |
Processor activeProcess withSystemBackgroundPriorityDo:[3000 factorial] |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1453 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1454 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1455 |
"Created: 7.8.1997 / 12:56:23 / cg" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1456 |
! |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1457 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1458 |
withUserBackgroundPriorityDo:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1459 |
"execute aBlock at background priority. This can be used to perform |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1460 |
time-consuming operations at a more user-friendly priority." |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1461 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1462 |
^ self withPriority:(Processor userBackgroundPriority) do:aBlock |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1463 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1464 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1465 |
Processor activeProcess withUserBackgroundPriorityDo:[3000 factorial] |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1466 |
" |
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1467 |
|
22c472b4d24f
added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents:
2727
diff
changeset
|
1468 |
"Created: 6.8.1997 / 15:40:02 / cg" |
202 | 1469 |
! ! |
1470 |
||
5256 | 1471 |
!Process methodsFor:'startup'! |
116 | 1472 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1473 |
imageRestart |
699 | 1474 |
"restart the process from the beginning. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1475 |
This is sent by the ProcessorScheduler at image restart time, |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1476 |
to all restartable processes." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1477 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1478 |
|savedGroupId| |
699 | 1479 |
|
1480 |
"/ ('restart process ' , id printString) errorPrintNL. |
|
1481 |
||
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1482 |
savedGroupId := processGroupId. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1483 |
|
699 | 1484 |
(Processor newProcessFor:self withId:id) ifFalse:[ |
5450 | 1485 |
"for some reason, the Processor was unable to create |
1486 |
a VM process for me ...." |
|
699 | 1487 |
|
5450 | 1488 |
('Process [warning]: process ' , id printString , ' failed to restart.') errorPrintCR. |
1489 |
^ nil |
|
699 | 1490 |
]. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1491 |
processGroupId := savedGroupId. |
699 | 1492 |
self resume |
1086 | 1493 |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1494 |
"Created: 28.10.1996 / 20:32:34 / cg" |
2130
b9e7e1cf98bd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1495 |
"Modified: 10.1.1997 / 18:01:13 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1496 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1497 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1498 |
restart |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1499 |
"restart the process from the beginning. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1500 |
This is only possible, if its restartable." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1501 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1502 |
restartable ifFalse:[ |
5450 | 1503 |
^ self error:'process is not restartable' mayProceed:true |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1504 |
]. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1505 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1506 |
self interruptWith:[RestartSignal raise] |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1507 |
|
2158
aab75d6439d0
renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1508 |
"Modified: 12.1.1997 / 00:54:32 / cg" |
699 | 1509 |
! |
1510 |
||
116 | 1511 |
start |
159 | 1512 |
"start the process - this is sent by the VM to the process to get |
1513 |
the process up and running. |
|
329 | 1514 |
Sending #start to the process (instead of directly executing the startBlock) |
1515 |
allows more flexible handling of processes, since anything that responds |
|
1516 |
to #start can be handled transparently by the VM then ..." |
|
159 | 1517 |
|
1518 |
|block| |
|
116 | 1519 |
|
159 | 1520 |
(block := startBlock) notNil ifTrue:[ |
5450 | 1521 |
"/ |
1522 |
"/ just for your convenience ... |
|
1523 |
"/ |
|
1524 |
name isNil ifTrue:[ |
|
1525 |
name := '(' , block displayString , ')' |
|
1526 |
]. |
|
1527 |
restartable ~~ true ifTrue:[startBlock := nil]. |
|
1839 | 1528 |
|
5450 | 1529 |
[ |
1530 |
"/ |
|
1531 |
"/ handle Process-Termination, Process-Restart and Abort |
|
1532 |
"/ |
|
1533 |
CoughtSignals handle:[:ex | |
|
1534 |
ex signal == RestartSignal ifTrue:[ |
|
1535 |
ex restart |
|
1536 |
]. |
|
1537 |
ex return |
|
1538 |
] do:[ |
|
1539 |
exceptionHandlerSet isNil ifTrue:[ |
|
1540 |
exceptionHandlerSet := ExceptionHandlerSet new. |
|
1541 |
]. |
|
1542 |
"/ |
|
1543 |
"/ block is the one which received the fork some time ago... |
|
1544 |
"/ |
|
1545 |
exceptionHandlerSet handleDo:block |
|
1546 |
] |
|
1547 |
] valueOnUnwindDo:[self terminateNoSignal]. |
|
202 | 1548 |
|
5450 | 1549 |
self terminateNoSignal. |
159 | 1550 |
] ifFalse:[ |
5450 | 1551 |
"is this artificial restriction useful ?" |
1552 |
self error:'a process cannot be started twice' mayProceed:true |
|
116 | 1553 |
] |
1475 | 1554 |
|
1839 | 1555 |
"Modified: 28.10.1996 / 21:06:45 / cg" |
1 | 1556 |
! ! |
1557 |
||
1558 |
!Process methodsFor:'suspend / resume'! |
|
1559 |
||
5592 | 1560 |
abort |
1561 |
"raise an obortSignal in the receiver process. |
|
1562 |
Most processes willing to handle this will return to some save state |
|
1563 |
(typically, some kind of event loop). |
|
1564 |
If not handled, this will result in termination of the process." |
|
1565 |
||
1566 |
Processor activeProcess == self ifTrue:[ |
|
1567 |
Object abortSignal raiseRequest |
|
1568 |
] ifFalse:[ |
|
1569 |
self interruptWith:[ |
|
1570 |
Object abortSignal raiseRequest |
|
1571 |
]. |
|
1572 |
] |
|
1573 |
! |
|
1574 |
||
699 | 1575 |
resume |
1576 |
"resume the receiver process" |
|
1577 |
||
4002
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1578 |
state == #stopped ifTrue:[ |
5450 | 1579 |
state := #run. |
4002
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1580 |
]. |
699 | 1581 |
Processor resume:self |
1582 |
! |
|
1583 |
||
1584 |
resumeForSingleSend |
|
1585 |
"resume the receiver process, but only let it execute a single send." |
|
1586 |
||
1587 |
Processor resumeForSingleSend:self |
|
1588 |
! |
|
1589 |
||
326 | 1590 |
stop |
1591 |
"suspend the receiver process - will continue to run when a resume is sent. |
|
1592 |
A stopped process will not be resumed for interrupt processing." |
|
1593 |
||
3679 | 1594 |
"/ state := #stopped. |
1595 |
self suspendWithState:#stopped |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1596 |
|
3679 | 1597 |
"Modified: / 13.12.1995 / 13:22:58 / stefan" |
1598 |
"Modified: / 27.7.1998 / 23:37:15 / cg" |
|
326 | 1599 |
! |
1600 |
||
1 | 1601 |
suspend |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1602 |
"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
|
1603 |
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
|
1604 |
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
|
1605 |
a suspend (see wait code in Semaphore). |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1606 |
Use #stop for a hard-suspend, which is not affected by interrupts." |
13 | 1607 |
|
1474 | 1608 |
self suspendWithState:#suspended |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1609 |
|
1474 | 1610 |
"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
|
1611 |
! |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1612 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1613 |
suspendWithState:aStateSymbol |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1614 |
"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
|
1615 |
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
|
1616 |
in the ProcessMonitor (instead of #suspended). |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1617 |
(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
|
1618 |
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
|
1619 |
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
|
1620 |
a suspend (see wait code in Semaphore). |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1621 |
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
|
1622 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1623 |
suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1624 |
suspendActions notNil ifTrue:[ |
5450 | 1625 |
suspendActions do:[:action | action value] |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1626 |
]. |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1627 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1628 |
" |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1629 |
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
|
1630 |
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
|
1631 |
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
|
1632 |
(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
|
1633 |
" |
4002
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1634 |
(state == #active |
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1635 |
or:[state == #run |
341a896cb334
allow stopping a waiting process
Claus Gittinger <cg@exept.de>
parents:
3785
diff
changeset
|
1636 |
or:[aStateSymbol == #stopped]]) ifTrue:[ |
5450 | 1637 |
state := aStateSymbol. |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1638 |
]. |
1 | 1639 |
Processor suspend:self |
1640 |
! |
|
1641 |
||
1642 |
terminate |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1643 |
"terminate the receiver process. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1644 |
Termination is done by raising the terminateSignal in the receiver process, |
2689 | 1645 |
which can be caught. |
375 | 1646 |
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
|
1647 |
will be performed before the process is really terminated. |
dff1649c072c
resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents:
4002
diff
changeset
|
1648 |
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
|
1649 |
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
|
1650 |
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
|
1651 |
done." |
10 | 1652 |
|
2888
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
1653 |
|wasBlocked| |
3e8b5166d90f
a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents:
2857
diff
changeset
|
1654 |
|
3293
3f52fbf6b94c
oops - a self-terminating process did not evaluate its
Claus Gittinger <cg@exept.de>
parents:
3094
diff
changeset
|
1655 |
Processor activeProcess ~~ self ifTrue:[ |
5450 | 1656 |
"/ if the receiver had no chance to execute yet, |
1657 |
"/ 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
|
1658 |
|
5450 | 1659 |
wasBlocked := OperatingSystem blockInterrupts. |
1660 |
[ |
|
1661 |
state == #osWait ifTrue:[ |
|
1662 |
self terminateNoSignal. |
|
1663 |
^ self. |
|
1664 |
]. |
|
3776
87eda283dab1
fix terminate while in osWait (win32)
Claus Gittinger <cg@exept.de>
parents:
3723
diff
changeset
|
1665 |
|
5450 | 1666 |
self suspendedContext isNil ifTrue:[ |
1667 |
self terminateNoSignal. |
|
1668 |
^ self |
|
1669 |
] |
|
1670 |
] valueNowOrOnUnwindDo:[ |
|
1671 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts] |
|
1672 |
]. |
|
3293
3f52fbf6b94c
oops - a self-terminating process did not evaluate its
Claus Gittinger <cg@exept.de>
parents:
3094
diff
changeset
|
1673 |
|
5450 | 1674 |
self interruptWith:[ |
1675 |
Signal noHandlerSignal handle:[:ex | |
|
1676 |
ex parameter signal == TerminateSignal ifTrue:[ |
|
1677 |
ex return. |
|
1678 |
]. |
|
1679 |
ex reject. |
|
1680 |
] do:[ |
|
1681 |
TerminateSignal raise. |
|
1682 |
]. |
|
1683 |
self terminateNoSignal. |
|
1684 |
]. |
|
1685 |
self resume |
|
3293
3f52fbf6b94c
oops - a self-terminating process did not evaluate its
Claus Gittinger <cg@exept.de>
parents:
3094
diff
changeset
|
1686 |
] ifFalse:[ |
5450 | 1687 |
"/ 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
|
1688 |
|
5450 | 1689 |
Signal noHandlerSignal handle:[:ex | |
1690 |
ex parameter signal == TerminateSignal ifTrue:[ |
|
1691 |
ex return. |
|
1692 |
]. |
|
1693 |
ex reject. |
|
1694 |
] do:[ |
|
1695 |
TerminateSignal raise. |
|
1696 |
]. |
|
1697 |
self terminateNoSignal. |
|
159 | 1698 |
] |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1699 |
|
3776
87eda283dab1
fix terminate while in osWait (win32)
Claus Gittinger <cg@exept.de>
parents:
3723
diff
changeset
|
1700 |
"Modified: / 24.8.1998 / 18:29:46 / cg" |
159 | 1701 |
! |
1702 |
||
4875 | 1703 |
terminateAllGUISubprocesses |
1704 |
"terminate all the receivers gui subprocesses and their children as well |
|
1705 |
(i.e. all processes in the receivers process group, except for |
|
1706 |
the receiver itself)." |
|
1707 |
||
5377 | 1708 |
id isNil ifTrue:[ |
5450 | 1709 |
"/ problem: |
1710 |
"/ if receiver is already dead, its id is nil. |
|
1711 |
"/ children are found by looking for processes with a parentID identical to |
|
1712 |
"/ mine - ifNil, system processes are found, which is probably not what you |
|
1713 |
"/ want ... |
|
1714 |
"/ FIX: remember the id (or dont nil it when terminating) |
|
1715 |
"/ requires VM changes. |
|
1716 |
self error:'process is already dead - cannot determine child processes'. |
|
1717 |
^ self |
|
5377 | 1718 |
]. |
4875 | 1719 |
ProcessorScheduler knownProcesses do:[:aProcess | |
5450 | 1720 |
aProcess ~~ self ifTrue:[ |
1721 |
aProcess processGroupId == id ifTrue:[ |
|
1722 |
aProcess isGUIProcess ifTrue:[ |
|
1723 |
aProcess terminateWithAllGUISubprocesses |
|
1724 |
] |
|
1725 |
] |
|
1726 |
] |
|
4875 | 1727 |
]. |
1728 |
||
1729 |
"Created: / 28.10.1996 / 20:43:32 / cg" |
|
1730 |
"Modified: / 3.11.1997 / 00:28:06 / cg" |
|
1731 |
! |
|
1732 |
||
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1733 |
terminateAllSubprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1734 |
"terminate all the receivers subprocesses and their children as well |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1735 |
(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
|
1736 |
the receiver itself)." |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1737 |
|
5377 | 1738 |
id isNil ifTrue:[ |
5450 | 1739 |
"/ problem: |
1740 |
"/ if receiver is already dead, its id is nil. |
|
1741 |
"/ children are found by looking for processes with a parentID identical to |
|
1742 |
"/ mine - ifNil, system processes are found, which is probably not what you |
|
1743 |
"/ want ... |
|
1744 |
"/ FIX: remember the id (or dont nil it when terminating) |
|
1745 |
"/ requires VM changes. |
|
1746 |
self error:'process is already dead - cannot determine child processes'. |
|
1747 |
^ self |
|
5377 | 1748 |
]. |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1749 |
ProcessorScheduler knownProcesses do:[:aProcess | |
5450 | 1750 |
aProcess ~~ self ifTrue:[ |
1751 |
("aProcess processGroupId == processGroupId |
|
1752 |
or:["aProcess processGroupId == id"]") ifTrue:[ |
|
1753 |
aProcess terminateWithAllSubprocesses |
|
1754 |
] |
|
1755 |
] |
|
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1756 |
]. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1757 |
|
3094
647219dc860b
avoid endless recursion in terminateAllSubProcesses
Claus Gittinger <cg@exept.de>
parents:
3013
diff
changeset
|
1758 |
"Created: / 28.10.1996 / 20:43:32 / cg" |
647219dc860b
avoid endless recursion in terminateAllSubProcesses
Claus Gittinger <cg@exept.de>
parents:
3013
diff
changeset
|
1759 |
"Modified: / 3.11.1997 / 00:28:06 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1760 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1761 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1762 |
terminateGroup |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1763 |
"terminate the receiver with all of its created subprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1764 |
(i.e. all processes in the receivers process group)." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1765 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1766 |
self terminateSubprocesses. |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1767 |
self terminate |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1768 |
|
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1769 |
"Created: 8.7.1996 / 14:04:15 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1770 |
"Modified: 28.10.1996 / 20:42:00 / cg" |
1531
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1771 |
! |
2a61dad6c7ce
added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents:
1530
diff
changeset
|
1772 |
|
159 | 1773 |
terminateNoSignal |
2197 | 1774 |
"hard-terminate the receiver process without sending a terminateSignal |
375 | 1775 |
or performing any unwind-handling. |
2197 | 1776 |
However, exit-actions are performed. |
1777 |
This is useful in case of emergency, when a buggy terminationHandler |
|
1778 |
prevents you from getting a process to terminate." |
|
375 | 1779 |
|
1780 |
|block| |
|
159 | 1781 |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1782 |
"/ this is treated like the final suspend |
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1783 |
suspendActions notNil ifTrue:[ |
5450 | 1784 |
[suspendActions isEmpty] whileFalse:[ |
1785 |
block := suspendActions removeFirst. |
|
1786 |
block value. |
|
1787 |
] |
|
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1788 |
]. |
375 | 1789 |
exitActions notNil ifTrue:[ |
5450 | 1790 |
[exitActions isEmpty] whileFalse:[ |
1791 |
block := exitActions removeFirst. |
|
1792 |
block value. |
|
1793 |
] |
|
375 | 1794 |
]. |
329 | 1795 |
suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. |
159 | 1796 |
Processor terminateNoSignal:self |
752
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1797 |
|
0259dd855289
new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents:
712
diff
changeset
|
1798 |
"Modified: 13.12.1995 / 13:40:14 / stefan" |
2384 | 1799 |
"Modified: 12.2.1997 / 12:41:38 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1800 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1801 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1802 |
terminateSubprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1803 |
"terminate all the receivers subprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1804 |
(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
|
1805 |
the receiver itself)." |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1806 |
|
5377 | 1807 |
id isNil ifTrue:[ |
5450 | 1808 |
"/ problem: |
1809 |
"/ if receiver is already dead, its id is nil. |
|
1810 |
"/ children are found by looking for processes with a parentID identical to |
|
1811 |
"/ mine - ifNil, system processes are found, which is probably not what you |
|
1812 |
"/ want ... |
|
1813 |
"/ FIX: remember the id (or dont nil it when terminating) |
|
1814 |
"/ requires VM changes. |
|
1815 |
self error:'process is already dead - cannot determine child processes'. |
|
1816 |
^ self |
|
5377 | 1817 |
]. |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1818 |
ProcessorScheduler knownProcesses do:[:aProcess | |
5450 | 1819 |
aProcess ~~ self ifTrue:[ |
1820 |
(aProcess processGroupId == processGroupId |
|
1821 |
or:[aProcess processGroupId == id]) ifTrue:[ |
|
1822 |
aProcess terminate |
|
1823 |
] |
|
1824 |
] |
|
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1825 |
]. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1826 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1827 |
"Created: 28.10.1996 / 20:41:49 / cg" |
2891 | 1828 |
"Modified: 26.8.1997 / 03:09:57 / cg" |
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1829 |
! |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1830 |
|
4875 | 1831 |
terminateWithAllGUISubprocesses |
1832 |
"terminate the receiver with all of its created gui subprocesses and their gui children |
|
1833 |
(i.e. all processes in the receivers process group)." |
|
1834 |
||
1835 |
self terminateAllGUISubprocesses. |
|
1836 |
self terminate |
|
1837 |
||
1838 |
"Modified: 28.10.1996 / 20:42:00 / cg" |
|
1839 |
"Created: 28.10.1996 / 20:44:07 / cg" |
|
1840 |
! |
|
1841 |
||
1837
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1842 |
terminateWithAllSubprocesses |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1843 |
"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
|
1844 |
(i.e. all processes in the receivers process group)." |
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 |
self terminateAllSubprocesses. |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1847 |
self terminate |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1848 |
|
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1849 |
"Modified: 28.10.1996 / 20:42:00 / cg" |
7e3b67a1adab
more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1850 |
"Created: 28.10.1996 / 20:44:07 / cg" |
1 | 1851 |
! ! |
1852 |
||
1784
af6446feffae
optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
1853 |
!Process class methodsFor:'documentation'! |
159 | 1854 |
|
699 | 1855 |
version |
5643 | 1856 |
^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.116 2000-09-28 19:25:55 cg Exp $' |
159 | 1857 |
! ! |
699 | 1858 |
Process initialize! |