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