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