author | Claus Gittinger <cg@exept.de> |
Fri, 22 Dec 1995 22:53:46 +0100 | |
changeset 315 | 8a86faf847d1 |
parent 314 | 728eab568865 |
child 322 | e3ccd5e431df |
permissions | -rw-r--r-- |
52 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
93 | 13 |
SimpleView subclass:#ProcessMonitor |
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
14 |
instanceVariableNames:'listView processes listUpdateDelay updateDelay updateBlock |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
15 |
listUpdateBlock updateProcess hideDead runColor suspendedColor |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
16 |
waitColor cpuUsages showDetail' |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
17 |
classVariableNames:'' |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
18 |
poolDictionaries:'' |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
19 |
category:'Interface-Tools' |
19 | 20 |
! |
21 |
||
52 | 22 |
!ProcessMonitor class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
This view shows smalltalks (light-weight) processes, and also offers |
|
41 |
a popup menu for various useful operations on them. |
|
42 |
Especially 'debug' is useful, to see what a process is currently |
|
43 |
doing. |
|
85 | 44 |
|
52 | 45 |
The information shown is: |
90 | 46 |
id - the numeric id of the process |
47 |
name - the name (if any) of the process |
|
48 |
(the name has no semantic meaning; it exists for the processMonitor only) |
|
49 |
state - what is it doing; |
|
50 |
wait - waiting on a semaphore |
|
51 |
eventWait - waiting on a view-event semaphore |
|
52 |
ioWait - waiting on an io-semaphore |
|
53 |
timeWait - waiting for a time-semaphore |
|
54 |
run - run, but currently not scheduled |
|
55 |
active - really running (this info is useless, since at |
|
56 |
update time, its always the update process which is |
|
57 |
running) |
|
58 |
suspended - suspended; not waiting on a semaphore |
|
59 |
light - not yet started (i.e. has no stack yet) |
|
52 | 60 |
|
90 | 61 |
prio - the processes priority (1..30) |
62 |
usedStack - the current stack use |
|
63 |
totalStack - the stack currently allocated (i.e. the maximum ever needed) |
|
52 | 64 |
" |
65 |
! ! |
|
66 |
||
56 | 67 |
!ProcessMonitor class methodsFor:'defaults'! |
19 | 68 |
|
56 | 69 |
defaultIcon |
70 |
|i| |
|
19 | 71 |
|
93 | 72 |
i := Image fromFile:'ProcMon.xbm'. |
56 | 73 |
i notNil ifTrue:[^ i]. |
85 | 74 |
^ StandardSystemView defaultIcon |
208 | 75 |
! |
76 |
||
77 |
defaultLabel |
|
78 |
^ 'Process Monitor' |
|
85 | 79 |
! ! |
80 |
||
81 |
!ProcessMonitor class methodsFor:'startup'! |
|
82 |
||
83 |
open |
|
84 |
|top monitor| |
|
85 |
||
86 |
top := StandardSystemView new. |
|
87 |
monitor := self origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
105 | 88 |
top extent:monitor preferredExtent. |
85 | 89 |
top label:self defaultLabel. |
90 |
top icon:self defaultIcon. |
|
91 |
top open |
|
92 |
||
93 |
" |
|
94 |
ProcessMonitor open |
|
95 |
" |
|
96 |
! ! |
|
97 |
||
143 | 98 |
!ProcessMonitor methodsFor:'destroying'! |
99 |
||
100 |
destroy |
|
101 |
updateBlock notNil ifTrue:[ |
|
102 |
Processor removeTimedBlock:updateBlock. |
|
103 |
Processor removeTimedBlock:listUpdateBlock. |
|
104 |
] ifFalse:[ |
|
105 |
updateProcess notNil ifTrue:[updateProcess terminate] |
|
106 |
]. |
|
107 |
super destroy |
|
108 |
! ! |
|
109 |
||
85 | 110 |
!ProcessMonitor methodsFor:'drawing'! |
111 |
||
112 |
titleLine |
|
109 | 113 |
showDetail ifTrue:[ |
143 | 114 |
^ 'id name state prio usedStack totalStack current-segment switches where'. |
109 | 115 |
]. |
143 | 116 |
^ 'id name state prio usedStack where'. |
85 | 117 |
! |
118 |
||
119 |
updateList |
|
120 |
"update list of processes" |
|
121 |
||
122 |
|newList| |
|
123 |
||
124 |
shown ifTrue:[ |
|
208 | 125 |
showDetail ifTrue:[ |
126 |
newList := Process allInstances asOrderedCollection. |
|
127 |
] ifFalse:[ |
|
128 |
newList := ProcessorScheduler knownProcesses asOrderedCollection. |
|
129 |
]. |
|
130 |
newList := newList select:[:p | p id notNil]. |
|
85 | 131 |
|
208 | 132 |
"sort by id - take care of nil ids of dead processes" |
133 |
newList sort:[:p1 :p2 | |
|
134 |
|id1 id2| |
|
85 | 135 |
|
208 | 136 |
(p1 isNil or:[(id1 := p1 id) isNil]) |
137 |
ifTrue:[true] |
|
138 |
ifFalse:[ |
|
139 |
(p2 isNil or:[(id2 := p2 id) isNil]) |
|
140 |
ifTrue:[false] |
|
141 |
ifFalse:[id1 < id2] |
|
142 |
] |
|
143 |
]. |
|
144 |
newList ~= processes ifTrue:[ |
|
145 |
processes := WeakArray withAll:newList. |
|
146 |
self updateStatus |
|
147 |
]. |
|
85 | 148 |
]. |
149 |
updateBlock notNil ifTrue:[ |
|
208 | 150 |
Processor removeTimedBlock:listUpdateBlock. |
151 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay |
|
85 | 152 |
]. |
153 |
! |
|
154 |
||
155 |
updateStatus |
|
156 |
"update status display of processes" |
|
157 |
||
166 | 158 |
|oldList list line dIndex con interrupted plist aProcess nm st c c0 n found sender| |
85 | 159 |
|
160 |
shown ifTrue:[ |
|
208 | 161 |
oldList := listView list. |
162 |
processes notNil ifTrue:[ |
|
163 |
list := OrderedCollection new. |
|
164 |
list add:self titleLine. |
|
165 |
list add:(String new:self titleLine size withAll:$-). |
|
85 | 166 |
|
208 | 167 |
interrupted := Processor interruptedProcess. |
85 | 168 |
|
208 | 169 |
dIndex := 1. |
170 |
1 to:processes size do:[:index | |
|
171 |
|totalStack| |
|
85 | 172 |
|
208 | 173 |
aProcess := processes at:index. |
174 |
aProcess notNil ifTrue:[ |
|
175 |
(aProcess id notNil or:[hideDead not]) ifTrue:[ |
|
176 |
line := aProcess id printStringPaddedTo:5. |
|
177 |
(nm := aProcess name) isNil ifFalse:[ |
|
178 |
nm := nm printString |
|
179 |
] ifTrue:[ |
|
180 |
nm := ' ' |
|
181 |
]. |
|
182 |
nm size >= 29 ifTrue:[ |
|
183 |
nm := (nm contractTo:28) , ' ' |
|
184 |
] ifFalse:[ |
|
185 |
nm := (nm printStringPaddedTo:29). |
|
186 |
]. |
|
187 |
line := line , nm. |
|
85 | 188 |
"/ n := cpuUsages at:(aProcess id) ifAbsent:[0]. |
189 |
"/ n ~~ 0 ifTrue:[ |
|
190 |
"/ line := line , ((n * 4) printStringLeftPaddedTo:3) |
|
191 |
"/ ] ifFalse:[ |
|
192 |
"/ line := line , ' ' |
|
193 |
"/ ]. |
|
208 | 194 |
st := aProcess state. |
195 |
(st == #run |
|
196 |
and:[aProcess == interrupted]) ifTrue:[ |
|
197 |
c := ' *'. |
|
198 |
] ifFalse:[ |
|
199 |
c := ' '. |
|
200 |
]. |
|
201 |
line := line , c , (st printStringPaddedTo:9). |
|
202 |
line := line , (aProcess priority printStringLeftPaddedTo:3). |
|
203 |
line := line , (aProcess usedStackSize printStringLeftPaddedTo:11). |
|
143 | 204 |
|
208 | 205 |
n := aProcess numberOfStackSegments. |
206 |
"/ n == 0 ifTrue:[ |
|
207 |
"/ con := nil |
|
208 |
"/ ] ifFalse:[ |
|
209 |
con := aProcess suspendedContext. |
|
210 |
con isNil ifTrue:[ |
|
211 |
aProcess == Processor activeProcess ifTrue:[ |
|
212 |
con := thisContext |
|
213 |
] |
|
214 |
]. |
|
215 |
"/ ]. |
|
216 |
showDetail ifTrue:[ |
|
217 |
aProcess id == 0 ifTrue:[ |
|
218 |
line := line , ('unlimited' leftPaddedTo:13). |
|
219 |
] ifFalse:[ |
|
220 |
line := line , (aProcess totalStackSize printStringLeftPaddedTo:10). |
|
221 |
line := line , '(' , n printString , ')'. |
|
222 |
]. |
|
223 |
con notNil ifTrue:[ |
|
224 |
line := line , ' '. |
|
225 |
line := line , (((ObjectMemory addressOf:con) printStringRadix:16) leftPaddedTo:8 with:$0). |
|
226 |
line := line , ' .. '. |
|
227 |
c := con. |
|
228 |
[(sender := c sender) notNil] whileTrue:[ |
|
229 |
c := sender |
|
230 |
]. |
|
231 |
line := line , (((ObjectMemory addressOf:c) printStringRadix:16) leftPaddedTo:8 with:$0). |
|
232 |
] ifFalse:[ |
|
233 |
line := line , (String new:20) |
|
234 |
]. |
|
235 |
line := line , ' '. |
|
236 |
line := line , (aProcess numberOfStackBoundaryHits printStringLeftPaddedTo:5). |
|
237 |
]. |
|
143 | 238 |
|
208 | 239 |
con notNil ifTrue:[ |
240 |
"/ search for a semaphore-wait in the top 10 contexts |
|
241 |
found := false. |
|
242 |
c := con. |
|
243 |
1 to:10 do:[:n | |
|
244 |
found ifFalse:[ |
|
245 |
c notNil ifTrue:[ |
|
246 |
(c receiver isMemberOf:Semaphore) ifTrue:[ |
|
247 |
c selector == #wait ifTrue:[ |
|
248 |
found := true. |
|
249 |
] |
|
250 |
]. |
|
251 |
c := c sender. |
|
252 |
] |
|
253 |
] |
|
254 |
]. |
|
255 |
found ifFalse:[ |
|
256 |
c := con. |
|
257 |
1 to:10 do:[:n | |
|
258 |
found ifFalse:[ |
|
259 |
c notNil ifTrue:[ |
|
260 |
(c receiver ~~ Processor) ifTrue:[ |
|
261 |
found := true. |
|
262 |
] ifFalse:[ |
|
263 |
c := c sender. |
|
264 |
] |
|
265 |
] |
|
266 |
] |
|
267 |
] |
|
268 |
]. |
|
269 |
found ifFalse:[ |
|
270 |
c := con |
|
271 |
]. |
|
272 |
[c notNil and:[c isBlockContext]] whileTrue:[ |
|
273 |
c := c home |
|
274 |
]. |
|
275 |
c notNil ifTrue:[ |
|
276 |
n := c receiver class name , '>>' , c selector. |
|
277 |
line := line , ' ' , n |
|
278 |
] |
|
279 |
]. |
|
280 |
list add:line. |
|
281 |
processes at:dIndex put:aProcess. |
|
282 |
dIndex := dIndex + 1 |
|
283 |
] |
|
284 |
]. |
|
285 |
]. |
|
286 |
dIndex to:processes size do:[:index | |
|
287 |
processes at:index put:nil |
|
288 |
] |
|
289 |
]. |
|
290 |
"avoid flicker" |
|
291 |
(oldList notNil and:[oldList size == list size]) ifTrue:[ |
|
292 |
list keysAndValuesDo:[:idx :entry | |
|
293 |
(oldList at:idx) ~= entry ifTrue:[ |
|
294 |
listView at:idx put:entry |
|
295 |
] |
|
296 |
] |
|
297 |
] ifFalse:[ |
|
298 |
listView setList:list. |
|
299 |
"the first two entries cannot be selected" |
|
300 |
listView attributeAt:1 put:#disabled. |
|
301 |
listView attributeAt:2 put:#disabled. |
|
314
728eab568865
Flush output when updating display.
Stefan Vogel <sv@exept.de>
parents:
208
diff
changeset
|
302 |
]. |
728eab568865
Flush output when updating display.
Stefan Vogel <sv@exept.de>
parents:
208
diff
changeset
|
303 |
listView flush |
85 | 304 |
]. |
305 |
updateBlock notNil ifTrue:[ |
|
208 | 306 |
Processor removeTimedBlock:updateBlock. |
307 |
Processor addTimedBlock:updateBlock afterSeconds:updateDelay |
|
85 | 308 |
] |
309 |
! |
|
310 |
||
311 |
updateView |
|
312 |
self updateList. |
|
313 |
self updateStatus |
|
19 | 314 |
! ! |
315 |
||
143 | 316 |
!ProcessMonitor methodsFor:'events'! |
317 |
||
208 | 318 |
canHandle:key |
319 |
^ key == #InspectIt |
|
320 |
! |
|
321 |
||
143 | 322 |
keyPress:key x:x y:y |
323 |
<resource: #keyboard ( #InspectIt ) > |
|
324 |
||
325 |
key == #InspectIt ifTrue:[ |
|
326 |
^ self inspectProcess. |
|
327 |
]. |
|
328 |
^ super keyPress:key x:x y:y |
|
329 |
! ! |
|
330 |
||
19 | 331 |
!ProcessMonitor methodsFor:'initialization'! |
332 |
||
333 |
initialize |
|
107 | 334 |
|v| |
19 | 335 |
|
336 |
super initialize. |
|
337 |
||
45 | 338 |
hideDead := true. |
109 | 339 |
showDetail := Smalltalk at:#SystemDebugging ifAbsent:false. |
45 | 340 |
|
110 | 341 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true in:self. |
19 | 342 |
v origin:0.0@0.0 corner:1.0@1.0. |
85 | 343 |
|
344 |
"/ self extent:(font widthOf:self titleLine) + v scrollBar width @ 100. |
|
345 |
||
19 | 346 |
listView := v scrolledView. |
347 |
listView font:font. |
|
98 | 348 |
listView menuHolder:self; menuPerformer:self; menuMessage:#processMenu. |
45 | 349 |
|
19 | 350 |
listView multipleSelectOk:true. |
97 | 351 |
listView delegate:(KeyboardForwarder toView:self). |
19 | 352 |
|
353 |
updateDelay := 0.5. |
|
354 |
listUpdateDelay := 5. |
|
45 | 355 |
|
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
356 |
"/ event mode is no longer used; |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
357 |
"/ this event support may vanish |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
358 |
ProcessorScheduler isPureEventDriven ifTrue:[ |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
359 |
updateBlock := [self updateStatus]. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
360 |
listUpdateBlock := [self updateList]. |
19 | 361 |
]. |
45 | 362 |
|
19 | 363 |
device hasColors ifTrue:[ |
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
364 |
runColor := Color green. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
365 |
suspendedColor := Color yellow. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
366 |
waitColor := Color red. |
19 | 367 |
] ifFalse:[ |
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
368 |
runColor := suspendedColor := waitColor := Color black |
19 | 369 |
] |
370 |
||
45 | 371 |
" |
372 |
ProcessMonitor open |
|
373 |
" |
|
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
374 |
|
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
375 |
"Modified: 22.12.1995 / 22:50:58 / cg" |
19 | 376 |
! |
377 |
||
85 | 378 |
mapped |
379 |
super mapped. |
|
380 |
self updateStatus. |
|
381 |
self updateList. |
|
382 |
! |
|
383 |
||
208 | 384 |
realize |
385 |
super realize. |
|
386 |
waitColor := waitColor on:device. |
|
387 |
runColor := runColor on:device. |
|
388 |
suspendedColor := suspendedColor on:device. |
|
389 |
||
390 |
self startUpdateProcess. |
|
391 |
! |
|
392 |
||
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
393 |
reinitialize |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
394 |
updateProcess := nil. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
395 |
super reinitialize. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
396 |
self startUpdateProcess. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
397 |
|
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
398 |
"Created: 22.12.1995 / 22:48:37 / cg" |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
399 |
"Modified: 22.12.1995 / 22:51:14 / cg" |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
400 |
! |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
401 |
|
93 | 402 |
startUpdateProcess |
19 | 403 |
updateBlock notNil ifTrue:[ |
90 | 404 |
Processor addTimedBlock:updateBlock afterSeconds:updateDelay. |
405 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay. |
|
19 | 406 |
] ifFalse:[ |
90 | 407 |
updateProcess := [ |
408 |
Process terminateSignal handle:[:ex | |
|
409 |
updateProcess := nil |
|
410 |
] do:[ |
|
411 |
|id cnt| |
|
56 | 412 |
|
90 | 413 |
" |
414 |
every 20ms, we look which process runs; |
|
415 |
every half second, the status is updated. |
|
416 |
every 5 seconds, the list of processes is |
|
417 |
built up again |
|
418 |
" |
|
419 |
[true] whileTrue:[ |
|
420 |
1 to:9 do:[:i | |
|
85 | 421 |
"/ cpuUsages := IdentityDictionary new. |
422 |
"/ 1 to:25 do:[:i | |
|
423 |
"/ (Delay forSeconds:0.02) wait. |
|
424 |
"/ id := Processor interruptedProcess id. |
|
425 |
"/ cnt := cpuUsages at:id ifAbsent:[0]. |
|
426 |
"/ cpuUsages at:id put:cnt + 1. |
|
427 |
"/ ]. |
|
90 | 428 |
(Delay forSeconds:0.5) wait. |
429 |
self updateStatus. |
|
430 |
]. |
|
431 |
(Delay forSeconds:0.5) wait. |
|
432 |
self updateList. |
|
433 |
] |
|
434 |
] |
|
435 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
436 |
updateProcess name:'monitor [' , |
|
437 |
Processor activeProcess id printString , |
|
438 |
'] update'. |
|
439 |
" |
|
440 |
raise my own priority |
|
441 |
" |
|
442 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2) |
|
19 | 443 |
]. |
444 |
! ! |
|
445 |
||
446 |
!ProcessMonitor methodsFor:'menu actions'! |
|
447 |
||
208 | 448 |
abortProcess |
449 |
"abort (raise AbortSignal in) the selected process" |
|
450 |
||
451 |
self selectedProcessesDo:[:p | |
|
452 |
p interruptWith:[AbortSignal raise] |
|
453 |
] |
|
454 |
! |
|
455 |
||
456 |
debugProcess |
|
457 |
"open a debugger on the selected process" |
|
458 |
||
459 |
self selectedProcessesDo:[:p | |
|
460 |
Debugger openOn:p |
|
461 |
] |
|
462 |
! |
|
463 |
||
464 |
detail |
|
465 |
showDetail := showDetail not. |
|
466 |
self updateView |
|
467 |
! |
|
468 |
||
469 |
hideDead:aBoolean |
|
470 |
hideDead := aBoolean |
|
471 |
! |
|
472 |
||
473 |
inspectProcess |
|
474 |
"open an inspector on the selected process" |
|
475 |
||
476 |
self selectedProcessesSend:#inspect |
|
477 |
! |
|
478 |
||
479 |
lowerPrio |
|
480 |
"lower the selected processes priority" |
|
481 |
||
482 |
self selectedProcessesDo:[:p | |
|
483 |
p priority:(p priority - 1) |
|
484 |
] |
|
485 |
! |
|
486 |
||
85 | 487 |
processMenu |
488 |
|labels selectors m| |
|
489 |
||
109 | 490 |
device ctrlDown ifTrue:[ |
110 | 491 |
labels := resources array:#( |
109 | 492 |
'\c detail' |
493 |
). |
|
494 |
selectors := #( |
|
495 |
detail |
|
496 |
). |
|
497 |
] ifFalse:[ |
|
498 |
labels := resources array:#( |
|
499 |
'inspect' |
|
500 |
'debug' |
|
501 |
'-' |
|
502 |
'resume' |
|
503 |
'suspend' |
|
504 |
'stop' |
|
505 |
'abort' |
|
506 |
'terminate' |
|
507 |
'-' |
|
508 |
'raise prio' |
|
509 |
'lower prio' |
|
510 |
). |
|
511 |
selectors := #( |
|
512 |
inspectProcess |
|
513 |
debugProcess |
|
514 |
nil |
|
515 |
resumeProcess |
|
516 |
suspendProcess |
|
517 |
stopProcess |
|
518 |
abortProcess |
|
519 |
terminateProcess |
|
520 |
nil |
|
521 |
raisePrio |
|
522 |
lowerPrio |
|
523 |
). |
|
524 |
updateProcess isNil ifTrue:[ |
|
525 |
labels := (resources array:#('update' '-')) , labels. |
|
526 |
selectors := #(updateView nil) , selectors |
|
527 |
]. |
|
85 | 528 |
]. |
529 |
||
530 |
m := PopUpMenu labels:labels |
|
90 | 531 |
selectors:selectors. |
85 | 532 |
|
109 | 533 |
m checkToggleAt:#detail put:showDetail. |
85 | 534 |
^ m |
535 |
! |
|
19 | 536 |
|
208 | 537 |
raisePrio |
538 |
"raise the selected processes priority" |
|
143 | 539 |
|
540 |
self selectedProcessesDo:[:p | |
|
208 | 541 |
p priority:(p priority + 1) |
143 | 542 |
] |
543 |
! |
|
544 |
||
545 |
resumeProcess |
|
546 |
"resume the selected process (i.e. let it run) " |
|
547 |
||
548 |
self selectedProcessesSend:#resume |
|
549 |
! |
|
550 |
||
92 | 551 |
stopProcess |
552 |
"stop the selected process - not even interrupts will wake it up" |
|
553 |
||
554 |
self selectedProcessesSend:#stop |
|
555 |
! |
|
556 |
||
19 | 557 |
suspendProcess |
92 | 558 |
"suspend the selected process - interrupts will let it run again" |
559 |
||
58 | 560 |
self selectedProcessesSend:#suspend |
85 | 561 |
! |
45 | 562 |
|
208 | 563 |
terminateProcess |
564 |
"terminate the selected process" |
|
92 | 565 |
|
208 | 566 |
self selectedProcessesSend:#terminate |
19 | 567 |
! ! |
568 |
||
143 | 569 |
!ProcessMonitor methodsFor:'private'! |
570 |
||
571 |
selectedProcessesDo:aBlock |
|
572 |
|p nr sel| |
|
85 | 573 |
|
143 | 574 |
sel := listView selection. |
575 |
sel isNil ifTrue:[^ self]. |
|
576 |
(sel isKindOf:Collection) ifTrue:[ |
|
577 |
sel do:[:n | |
|
578 |
nr := n - 2. "for headlines" |
|
579 |
nr notNil ifTrue:[ |
|
580 |
nr > 0 ifTrue:[ |
|
581 |
p := processes at:nr. |
|
582 |
p notNil ifTrue:[ |
|
583 |
aBlock value:p |
|
584 |
] |
|
585 |
] |
|
586 |
] |
|
587 |
] |
|
85 | 588 |
] ifFalse:[ |
143 | 589 |
nr := sel - 2. "for headlines" |
590 |
nr notNil ifTrue:[ |
|
591 |
nr > 0 ifTrue:[ |
|
592 |
p := processes at:nr. |
|
593 |
p notNil ifTrue:[ |
|
594 |
aBlock value:p |
|
595 |
] |
|
596 |
] |
|
597 |
] |
|
85 | 598 |
]. |
143 | 599 |
! |
600 |
||
601 |
selectedProcessesSend:aSelector |
|
602 |
self selectedProcessesDo:[:p | |
|
603 |
p perform:aSelector |
|
604 |
]. |
|
605 |
self updateView. |
|
85 | 606 |
! ! |
607 |
||
608 |
!ProcessMonitor methodsFor:'queries'! |
|
609 |
||
105 | 610 |
preferredExtent |
85 | 611 |
^ (font widthOf:self titleLine) + 40 @ 100 |
612 |
! ! |
|
208 | 613 |
|
614 |
!ProcessMonitor class methodsFor:'documentation'! |
|
615 |
||
616 |
version |
|
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
617 |
^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.28 1995-12-22 21:53:46 cg Exp $'! ! |