author | Claus Gittinger <cg@exept.de> |
Wed, 28 Feb 1996 15:43:10 +0100 | |
changeset 409 | 86125c414826 |
parent 322 | e3ccd5e431df |
child 413 | 715a6a18f825 |
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 |
||
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
158 |
|oldList list line dIndex con interrupted plist aProcess nm st c c0 n found sender running| |
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 := ' *'. |
|
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
198 |
running := true. |
208 | 199 |
] ifFalse:[ |
200 |
c := ' '. |
|
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
201 |
running := false. |
208 | 202 |
]. |
203 |
line := line , c , (st printStringPaddedTo:9). |
|
204 |
line := line , (aProcess priority printStringLeftPaddedTo:3). |
|
205 |
line := line , (aProcess usedStackSize printStringLeftPaddedTo:11). |
|
143 | 206 |
|
208 | 207 |
n := aProcess numberOfStackSegments. |
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
208 |
true "showDetail" ifTrue:[ |
208 | 209 |
con := aProcess suspendedContext. |
210 |
con isNil ifTrue:[ |
|
211 |
aProcess == Processor activeProcess ifTrue:[ |
|
212 |
con := thisContext |
|
213 |
] |
|
214 |
]. |
|
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
215 |
]. |
208 | 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 |
c := con. |
|
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
241 |
running ifFalse:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
242 |
"/ search for a semaphore-wait in the top 10 contexts |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
243 |
|
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
244 |
found := false. |
208 | 245 |
1 to:10 do:[:n | |
246 |
found ifFalse:[ |
|
247 |
c notNil ifTrue:[ |
|
409
86125c414826
dont send #isMemberOf: to the receiver (could be nil-subclass)
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
248 |
(c receiver class == Semaphore) ifTrue:[ |
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
249 |
c selector == #wait ifTrue:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
250 |
found := true. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
251 |
] |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
252 |
]. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
253 |
c := c sender. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
254 |
] |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
255 |
] |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
256 |
]. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
257 |
found ifFalse:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
258 |
c := con. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
259 |
1 to:10 do:[:n | |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
260 |
found ifFalse:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
261 |
c notNil ifTrue:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
262 |
(c receiver ~~ Processor) ifTrue:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
263 |
found := true. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
264 |
] ifFalse:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
265 |
c := c sender. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
266 |
] |
208 | 267 |
] |
268 |
] |
|
269 |
] |
|
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
270 |
]. |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
271 |
found ifFalse:[ |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
272 |
c := con |
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
273 |
]. |
208 | 274 |
]. |
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
275 |
|
208 | 276 |
[c notNil and:[c isBlockContext]] whileTrue:[ |
277 |
c := c home |
|
278 |
]. |
|
279 |
c notNil ifTrue:[ |
|
280 |
n := c receiver class name , '>>' , c selector. |
|
281 |
line := line , ' ' , n |
|
282 |
] |
|
283 |
]. |
|
284 |
list add:line. |
|
285 |
processes at:dIndex put:aProcess. |
|
286 |
dIndex := dIndex + 1 |
|
287 |
] |
|
288 |
]. |
|
289 |
]. |
|
290 |
dIndex to:processes size do:[:index | |
|
291 |
processes at:index put:nil |
|
292 |
] |
|
293 |
]. |
|
294 |
"avoid flicker" |
|
295 |
(oldList notNil and:[oldList size == list size]) ifTrue:[ |
|
296 |
list keysAndValuesDo:[:idx :entry | |
|
297 |
(oldList at:idx) ~= entry ifTrue:[ |
|
298 |
listView at:idx put:entry |
|
299 |
] |
|
300 |
] |
|
301 |
] ifFalse:[ |
|
302 |
listView setList:list. |
|
303 |
"the first two entries cannot be selected" |
|
304 |
listView attributeAt:1 put:#disabled. |
|
305 |
listView attributeAt:2 put:#disabled. |
|
314
728eab568865
Flush output when updating display.
Stefan Vogel <sv@exept.de>
parents:
208
diff
changeset
|
306 |
]. |
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
307 |
listView flush |
85 | 308 |
]. |
309 |
updateBlock notNil ifTrue:[ |
|
208 | 310 |
Processor removeTimedBlock:updateBlock. |
311 |
Processor addTimedBlock:updateBlock afterSeconds:updateDelay |
|
85 | 312 |
] |
322
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
313 |
|
e3ccd5e431df
fixed context display (dont search for suspending context in running processes)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
314 |
"Modified: 23.12.1995 / 17:40:21 / cg" |
85 | 315 |
! |
316 |
||
317 |
updateView |
|
318 |
self updateList. |
|
319 |
self updateStatus |
|
19 | 320 |
! ! |
321 |
||
143 | 322 |
!ProcessMonitor methodsFor:'events'! |
323 |
||
208 | 324 |
canHandle:key |
325 |
^ key == #InspectIt |
|
326 |
! |
|
327 |
||
143 | 328 |
keyPress:key x:x y:y |
329 |
<resource: #keyboard ( #InspectIt ) > |
|
330 |
||
331 |
key == #InspectIt ifTrue:[ |
|
332 |
^ self inspectProcess. |
|
333 |
]. |
|
334 |
^ super keyPress:key x:x y:y |
|
335 |
! ! |
|
336 |
||
19 | 337 |
!ProcessMonitor methodsFor:'initialization'! |
338 |
||
339 |
initialize |
|
107 | 340 |
|v| |
19 | 341 |
|
342 |
super initialize. |
|
343 |
||
45 | 344 |
hideDead := true. |
109 | 345 |
showDetail := Smalltalk at:#SystemDebugging ifAbsent:false. |
45 | 346 |
|
110 | 347 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true in:self. |
19 | 348 |
v origin:0.0@0.0 corner:1.0@1.0. |
85 | 349 |
|
350 |
"/ self extent:(font widthOf:self titleLine) + v scrollBar width @ 100. |
|
351 |
||
19 | 352 |
listView := v scrolledView. |
353 |
listView font:font. |
|
98 | 354 |
listView menuHolder:self; menuPerformer:self; menuMessage:#processMenu. |
45 | 355 |
|
19 | 356 |
listView multipleSelectOk:true. |
97 | 357 |
listView delegate:(KeyboardForwarder toView:self). |
19 | 358 |
|
359 |
updateDelay := 0.5. |
|
360 |
listUpdateDelay := 5. |
|
45 | 361 |
|
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
362 |
"/ event mode is no longer used; |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
363 |
"/ this event support may vanish |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
364 |
ProcessorScheduler isPureEventDriven ifTrue:[ |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
365 |
updateBlock := [self updateStatus]. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
366 |
listUpdateBlock := [self updateList]. |
19 | 367 |
]. |
45 | 368 |
|
19 | 369 |
device hasColors ifTrue:[ |
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
370 |
runColor := Color green. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
371 |
suspendedColor := Color yellow. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
372 |
waitColor := Color red. |
19 | 373 |
] ifFalse:[ |
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
374 |
runColor := suspendedColor := waitColor := Color black |
19 | 375 |
] |
376 |
||
45 | 377 |
" |
378 |
ProcessMonitor open |
|
379 |
" |
|
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
380 |
|
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
381 |
"Modified: 22.12.1995 / 22:50:58 / cg" |
19 | 382 |
! |
383 |
||
85 | 384 |
mapped |
385 |
super mapped. |
|
386 |
self updateStatus. |
|
387 |
self updateList. |
|
388 |
! |
|
389 |
||
208 | 390 |
realize |
391 |
super realize. |
|
392 |
waitColor := waitColor on:device. |
|
393 |
runColor := runColor on:device. |
|
394 |
suspendedColor := suspendedColor on:device. |
|
395 |
||
396 |
self startUpdateProcess. |
|
397 |
! |
|
398 |
||
315
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
399 |
reinitialize |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
400 |
updateProcess := nil. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
401 |
super reinitialize. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
402 |
self startUpdateProcess. |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
403 |
|
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
404 |
"Created: 22.12.1995 / 22:48:37 / cg" |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
405 |
"Modified: 22.12.1995 / 22:51:14 / cg" |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
406 |
! |
8a86faf847d1
create a new updateProcess when restarted
Claus Gittinger <cg@exept.de>
parents:
314
diff
changeset
|
407 |
|
93 | 408 |
startUpdateProcess |
19 | 409 |
updateBlock notNil ifTrue:[ |
90 | 410 |
Processor addTimedBlock:updateBlock afterSeconds:updateDelay. |
411 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay. |
|
19 | 412 |
] ifFalse:[ |
90 | 413 |
updateProcess := [ |
414 |
Process terminateSignal handle:[:ex | |
|
415 |
updateProcess := nil |
|
416 |
] do:[ |
|
417 |
|id cnt| |
|
56 | 418 |
|
90 | 419 |
" |
420 |
every 20ms, we look which process runs; |
|
421 |
every half second, the status is updated. |
|
422 |
every 5 seconds, the list of processes is |
|
423 |
built up again |
|
424 |
" |
|
425 |
[true] whileTrue:[ |
|
426 |
1 to:9 do:[:i | |
|
85 | 427 |
"/ cpuUsages := IdentityDictionary new. |
428 |
"/ 1 to:25 do:[:i | |
|
429 |
"/ (Delay forSeconds:0.02) wait. |
|
430 |
"/ id := Processor interruptedProcess id. |
|
431 |
"/ cnt := cpuUsages at:id ifAbsent:[0]. |
|
432 |
"/ cpuUsages at:id put:cnt + 1. |
|
433 |
"/ ]. |
|
90 | 434 |
(Delay forSeconds:0.5) wait. |
435 |
self updateStatus. |
|
436 |
]. |
|
437 |
(Delay forSeconds:0.5) wait. |
|
438 |
self updateList. |
|
439 |
] |
|
440 |
] |
|
441 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
442 |
updateProcess name:'monitor [' , |
|
443 |
Processor activeProcess id printString , |
|
444 |
'] update'. |
|
445 |
" |
|
446 |
raise my own priority |
|
447 |
" |
|
448 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2) |
|
19 | 449 |
]. |
450 |
! ! |
|
451 |
||
452 |
!ProcessMonitor methodsFor:'menu actions'! |
|
453 |
||
208 | 454 |
abortProcess |
455 |
"abort (raise AbortSignal in) the selected process" |
|
456 |
||
457 |
self selectedProcessesDo:[:p | |
|
458 |
p interruptWith:[AbortSignal raise] |
|
459 |
] |
|
460 |
! |
|
461 |
||
462 |
debugProcess |
|
463 |
"open a debugger on the selected process" |
|
464 |
||
465 |
self selectedProcessesDo:[:p | |
|
466 |
Debugger openOn:p |
|
467 |
] |
|
468 |
! |
|
469 |
||
470 |
detail |
|
471 |
showDetail := showDetail not. |
|
472 |
self updateView |
|
473 |
! |
|
474 |
||
475 |
hideDead:aBoolean |
|
476 |
hideDead := aBoolean |
|
477 |
! |
|
478 |
||
479 |
inspectProcess |
|
480 |
"open an inspector on the selected process" |
|
481 |
||
482 |
self selectedProcessesSend:#inspect |
|
483 |
! |
|
484 |
||
485 |
lowerPrio |
|
486 |
"lower the selected processes priority" |
|
487 |
||
488 |
self selectedProcessesDo:[:p | |
|
489 |
p priority:(p priority - 1) |
|
490 |
] |
|
491 |
! |
|
492 |
||
85 | 493 |
processMenu |
494 |
|labels selectors m| |
|
495 |
||
109 | 496 |
device ctrlDown ifTrue:[ |
110 | 497 |
labels := resources array:#( |
109 | 498 |
'\c detail' |
499 |
). |
|
500 |
selectors := #( |
|
501 |
detail |
|
502 |
). |
|
503 |
] ifFalse:[ |
|
504 |
labels := resources array:#( |
|
505 |
'inspect' |
|
506 |
'debug' |
|
507 |
'-' |
|
508 |
'resume' |
|
509 |
'suspend' |
|
510 |
'stop' |
|
511 |
'abort' |
|
512 |
'terminate' |
|
513 |
'-' |
|
514 |
'raise prio' |
|
515 |
'lower prio' |
|
516 |
). |
|
517 |
selectors := #( |
|
518 |
inspectProcess |
|
519 |
debugProcess |
|
520 |
nil |
|
521 |
resumeProcess |
|
522 |
suspendProcess |
|
523 |
stopProcess |
|
524 |
abortProcess |
|
525 |
terminateProcess |
|
526 |
nil |
|
527 |
raisePrio |
|
528 |
lowerPrio |
|
529 |
). |
|
530 |
updateProcess isNil ifTrue:[ |
|
531 |
labels := (resources array:#('update' '-')) , labels. |
|
532 |
selectors := #(updateView nil) , selectors |
|
533 |
]. |
|
85 | 534 |
]. |
535 |
||
536 |
m := PopUpMenu labels:labels |
|
90 | 537 |
selectors:selectors. |
85 | 538 |
|
109 | 539 |
m checkToggleAt:#detail put:showDetail. |
85 | 540 |
^ m |
541 |
! |
|
19 | 542 |
|
208 | 543 |
raisePrio |
544 |
"raise the selected processes priority" |
|
143 | 545 |
|
546 |
self selectedProcessesDo:[:p | |
|
208 | 547 |
p priority:(p priority + 1) |
143 | 548 |
] |
549 |
! |
|
550 |
||
551 |
resumeProcess |
|
552 |
"resume the selected process (i.e. let it run) " |
|
553 |
||
554 |
self selectedProcessesSend:#resume |
|
555 |
! |
|
556 |
||
92 | 557 |
stopProcess |
558 |
"stop the selected process - not even interrupts will wake it up" |
|
559 |
||
560 |
self selectedProcessesSend:#stop |
|
561 |
! |
|
562 |
||
19 | 563 |
suspendProcess |
92 | 564 |
"suspend the selected process - interrupts will let it run again" |
565 |
||
58 | 566 |
self selectedProcessesSend:#suspend |
85 | 567 |
! |
45 | 568 |
|
208 | 569 |
terminateProcess |
570 |
"terminate the selected process" |
|
92 | 571 |
|
208 | 572 |
self selectedProcessesSend:#terminate |
19 | 573 |
! ! |
574 |
||
143 | 575 |
!ProcessMonitor methodsFor:'private'! |
576 |
||
577 |
selectedProcessesDo:aBlock |
|
578 |
|p nr sel| |
|
85 | 579 |
|
143 | 580 |
sel := listView selection. |
581 |
sel isNil ifTrue:[^ self]. |
|
582 |
(sel isKindOf:Collection) ifTrue:[ |
|
583 |
sel do:[:n | |
|
584 |
nr := n - 2. "for headlines" |
|
585 |
nr notNil ifTrue:[ |
|
586 |
nr > 0 ifTrue:[ |
|
587 |
p := processes at:nr. |
|
588 |
p notNil ifTrue:[ |
|
589 |
aBlock value:p |
|
590 |
] |
|
591 |
] |
|
592 |
] |
|
593 |
] |
|
85 | 594 |
] ifFalse:[ |
143 | 595 |
nr := sel - 2. "for headlines" |
596 |
nr notNil ifTrue:[ |
|
597 |
nr > 0 ifTrue:[ |
|
598 |
p := processes at:nr. |
|
599 |
p notNil ifTrue:[ |
|
600 |
aBlock value:p |
|
601 |
] |
|
602 |
] |
|
603 |
] |
|
85 | 604 |
]. |
143 | 605 |
! |
606 |
||
607 |
selectedProcessesSend:aSelector |
|
608 |
self selectedProcessesDo:[:p | |
|
609 |
p perform:aSelector |
|
610 |
]. |
|
611 |
self updateView. |
|
85 | 612 |
! ! |
613 |
||
614 |
!ProcessMonitor methodsFor:'queries'! |
|
615 |
||
105 | 616 |
preferredExtent |
85 | 617 |
^ (font widthOf:self titleLine) + 40 @ 100 |
618 |
! ! |
|
208 | 619 |
|
620 |
!ProcessMonitor class methodsFor:'documentation'! |
|
621 |
||
622 |
version |
|
409
86125c414826
dont send #isMemberOf: to the receiver (could be nil-subclass)
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
623 |
^ '$Header: /cvs/stx/stx/libtool/Attic/ProcMonitor.st,v 1.30 1996-02-28 14:43:10 cg Exp $'! ! |