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