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