--- a/ProcessMonitorV2.st Mon May 16 06:49:42 2016 +0200
+++ b/ProcessMonitorV2.st Tue May 17 07:04:09 2016 +0200
@@ -18,19 +18,22 @@
hasSelectionHolder showProcessId showGroup showState showPrio
showUsedStack showTotalStack showCurrentSegment showSwitch
showWhere showInstrumentation showApplication showWindowTitle
- currentSortOrder processTable showDead sortBlock
- selectionRestartable updateListDelayTime updateContentsDelayTime
- enableDecreaseListDelayTime enableDecreaseContentsDelayTime
- enableIncreaseListDelayTime enableIncreaseContentsDelayTime
- listUpdateDelay updateDelay updateBlock listUpdateBlock
- updateProcess visibleBlock allowModifications tableMenu
+ currentSortOrder processTable showDeadHolder sortBlock
+ selectionRestartable updateListDelayTimeHolder
+ updateContentsDelayTimeHolder enableDecreaseListDelayTime
+ enableDecreaseContentsDelayTime enableIncreaseListDelayTime
+ enableIncreaseContentsDelayTime listUpdateDelay updateDelay
+ updateBlock listUpdateBlock updateProcess visibleBlock
+ allowModifications tableMenu
hasSelectionWithApplicationProcessHolder
hasSelectionAndProcessIsApplicationProcessHolder
hasSelectionWithStoppedProcessHolder
hasSelectionAndProcessIsStoppedHolder
hasSelectionWithGUIProcessHolder
hasSelectionWithDisabledInstrumentationHolder
- hasSelectionWithEnabledInstrumentationHolder'
+ hasSelectionWithEnabledInstrumentationHolder interruptCountHolder
+ timerActionCountHolder lastInterruptCount lastTimerActionCount
+ lastUpdateTimestamp'
classVariableNames:''
poolDictionaries:''
category:'Monitors-ST/X'
@@ -240,6 +243,19 @@
processCurrentSegment
'The address range of the current stack segment'
+
+#interruptCount
+'Interrupts per second'
+
+#listUpdateInterval
+'Interval to update the list of processes'
+
+#timerActionCount
+'Timer actions per second'
+
+#updateInterval
+'Interval to update the status of processes'
+
)
"Modified: / 05-06-2007 / 18:35:47 / cg"
@@ -945,141 +961,181 @@
<resource: #canvas>
- ^
- #(FullSpec
- name: windowSpec
- window:
- (WindowSpec
- label: 'ProcessMonitor'
- name: 'ProcessMonitor'
- min: (Point 10 10)
- bounds: (Rectangle 0 0 791 358)
- menu: mainMenu
- icon: defaultIcon
- )
- component:
- (SpecCollection
- collection: (
- (MenuPanelSpec
- name: 'ToolBar1'
- layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0)
- menu: toolBarMainMenu
- textDefault: true
- )
- (DataSetSpec
- name: 'ProcessTable'
- layout: (LayoutFrame 0 0.0 32 0.0 0 1.0 -23 1)
- model: selectedProcesses
- menu: tableMenu
- hasHorizontalScrollBar: true
- hasVerticalScrollBar: true
- dataList: processList
- useIndex: false
- doubleClickSelector: doubleClickedAt:
- columnHolder: tableColumns
- multipleSelectOk: true
- verticalSpacing: 0
- postBuildCallback: postBuildProcessTable:
- )
- (LabelSpec
- label: 'Update Contents Delay (s):'
- name: 'ContentsUpdateLabel'
- layout: (LayoutFrame -593 1 -20 1 -402 1 0 1)
- translateLabel: true
- adjust: right
- )
- (ViewSpec
- name: 'Box1'
- layout: (LayoutFrame -396 1 -22 1 -306 1 0 1)
- level: 0
- component:
- (SpecCollection
- collection: (
- (ArrowButtonSpec
- name: 'ArrowButton3'
- layout: (LayoutFrame 68 0 0 0 89 0 20 0)
- model: increaseupdateContentsDelayTime
- enableChannel: enableIncreaseContentsDelayTime
- isTriggerOnDown: true
- autoRepeat: true
- actionValue: ''
- direction: up
- )
- (InputFieldSpec
- name: 'EntryField2'
- layout: (LayoutFrame 22 0 0 0 66 0 20 0)
- model: updateContentsDelayTime
- acceptOnReturn: true
- acceptOnTab: true
- acceptOnLostFocus: true
- acceptOnPointerLeave: false
- )
- (ArrowButtonSpec
- name: 'ArrowButton4'
- layout: (LayoutFrame 0 0 0 0 20 0 20 0)
- model: decreaseupdateContentsDelayTime
- enableChannel: enableDecreaseContentsDelayTime
- isTriggerOnDown: true
- autoRepeat: true
- actionValue: ''
- direction: down
- )
- )
-
- )
- )
- (LabelSpec
- label: 'Update List Delay (s):'
- name: 'ListUpdateLabel'
- layout: (LayoutFrame -301 1 -20 1 -110 1 0 1)
- translateLabel: true
- adjust: right
- )
- (ViewSpec
- name: 'Box2'
- layout: (LayoutFrame -103 1 -21 1 0 1 1 1)
- level: 0
- component:
- (SpecCollection
- collection: (
- (ArrowButtonSpec
- name: 'ArrowButton5'
- layout: (LayoutFrame 68 0 0 0 89 0 20 0)
- model: increaseupdateListDelayTime
- enableChannel: enableIncreaseListDelayTime
- isTriggerOnDown: true
- autoRepeat: true
- actionValue: ''
- direction: up
- )
- (InputFieldSpec
- name: 'EntryField3'
- layout: (LayoutFrame 22 0 0 0 66 0 20 0)
- model: updateListDelayTime
- acceptOnReturn: true
- acceptOnTab: true
- acceptOnLostFocus: true
- acceptOnPointerLeave: false
- )
- (ArrowButtonSpec
- name: 'ArrowButton6'
- layout: (LayoutFrame 0 0 0 0 20 0 20 0)
- model: decreaseupdateListDelayTime
- enableChannel: enableDecreaseListDelayTime
- isTriggerOnDown: true
- autoRepeat: true
- actionValue: ''
- direction: down
- )
- )
-
- )
- keepSpaceForOSXResizeHandleH: true
- )
- )
-
- )
- )
+ ^
+ #(FullSpec
+ name: windowSpec
+ window:
+ (WindowSpec
+ label: 'ProcessMonitor'
+ name: 'ProcessMonitor'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 791 358)
+ menu: mainMenu
+ icon: defaultIcon
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (MenuPanelSpec
+ name: 'ToolBar1'
+ layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0)
+ menu: toolBarMainMenu
+ textDefault: true
+ )
+ (DataSetSpec
+ name: 'ProcessTable'
+ layout: (LayoutFrame 0 0.0 32 0.0 0 1.0 -25 1)
+ model: selectedProcesses
+ menu: tableMenu
+ hasHorizontalScrollBar: true
+ hasVerticalScrollBar: true
+ dataList: processList
+ useIndex: false
+ doubleClickSelector: doubleClickedAt:
+ columnHolder: tableColumns
+ multipleSelectOk: true
+ verticalSpacing: 0
+ postBuildCallback: postBuildProcessTable:
+ )
+ (LabelSpec
+ label: 'IRQ:'
+ name: 'Label1'
+ layout: (LayoutFrame 0 0 -24 1 50 0 0 1)
+ activeHelpKey: interruptCount
+ translateLabel: true
+ adjust: left
+ )
+ (LabelSpec
+ name: 'Label2'
+ layout: (LayoutFrame 50 0 -24 1 100 0 0 1)
+ activeHelpKey: interruptCount
+ translateLabel: true
+ labelChannel: interruptCountHolder
+ adjust: left
+ )
+ (LabelSpec
+ label: 'TMR:'
+ name: 'Label3'
+ layout: (LayoutFrame 100 0 -24 1 150 0 0 1)
+ activeHelpKey: timerActionCount
+ translateLabel: true
+ adjust: left
+ )
+ (LabelSpec
+ name: 'Label4'
+ layout: (LayoutFrame 150 0 -24 1 200 0 0 1)
+ activeHelpKey: timerActionCount
+ translateLabel: true
+ labelChannel: timerActionCountHolder
+ adjust: left
+ )
+ (LabelSpec
+ label: 'Update Interval (s):'
+ name: 'ContentsUpdateLabel'
+ layout: (LayoutFrame -593 1 -24 1 -402 1 0 1)
+ activeHelpKey: updateInterval
+ translateLabel: true
+ adjust: right
+ )
+ (ViewSpec
+ name: 'Box1'
+ layout: (LayoutFrame -396 1 -24 1 -306 1 0 1)
+ activeHelpKey: updateInterval
+ level: 0
+ component:
+ (SpecCollection
+ collection: (
+ (ArrowButtonSpec
+ name: 'ArrowButton3'
+ layout: (LayoutFrame 68 0 0 0 89 0 20 0)
+ translateLabel: true
+ model: increaseupdateContentsDelayTime
+ enableChannel: enableIncreaseContentsDelayTime
+ isTriggerOnDown: true
+ autoRepeat: true
+ actionValue: ''
+ direction: up
+ )
+ (InputFieldSpec
+ name: 'EntryField2'
+ layout: (LayoutFrame 22 0 0 0 66 0 22 0)
+ model: updateContentsDelayTimeHolder
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnLostFocus: true
+ acceptOnPointerLeave: false
+ )
+ (ArrowButtonSpec
+ name: 'ArrowButton4'
+ layout: (LayoutFrame 0 0 0 0 20 0 20 0)
+ translateLabel: true
+ model: decreaseupdateContentsDelayTime
+ enableChannel: enableDecreaseContentsDelayTime
+ isTriggerOnDown: true
+ autoRepeat: true
+ actionValue: ''
+ direction: down
+ )
+ )
+
+ )
+ )
+ (LabelSpec
+ label: 'Processlist:'
+ name: 'ListUpdateLabel'
+ layout: (LayoutFrame -301 1 -24 1 -110 1 0 1)
+ activeHelpKey: listUpdateInterval
+ translateLabel: true
+ adjust: right
+ )
+ (ViewSpec
+ name: 'Box2'
+ layout: (LayoutFrame -103 1 -24 1 -16 1 0 1)
+ activeHelpKey: listUpdateInterval
+ level: 0
+ component:
+ (SpecCollection
+ collection: (
+ (ArrowButtonSpec
+ name: 'ArrowButton5'
+ layout: (LayoutFrame 68 0 0 0 89 0 20 0)
+ translateLabel: true
+ model: increaseupdateListDelayTime
+ enableChannel: enableIncreaseListDelayTime
+ isTriggerOnDown: true
+ autoRepeat: true
+ actionValue: ''
+ direction: up
+ )
+ (InputFieldSpec
+ name: 'EntryField3'
+ layout: (LayoutFrame 22 0 0 0 66 0 22 0)
+ model: updateListDelayTimeHolder
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnLostFocus: true
+ acceptOnPointerLeave: false
+ )
+ (ArrowButtonSpec
+ name: 'ArrowButton6'
+ layout: (LayoutFrame 0 0 0 0 20 0 20 0)
+ translateLabel: true
+ model: decreaseupdateListDelayTime
+ enableChannel: enableDecreaseListDelayTime
+ isTriggerOnDown: true
+ autoRepeat: true
+ actionValue: ''
+ direction: down
+ )
+ )
+
+ )
+ keepSpaceForOSXResizeHandleH: true
+ )
+ )
+
+ )
+ )
! !
!ProcessMonitorV2 class methodsFor:'menu specs'!
@@ -1718,84 +1774,84 @@
^
#(Menu
- (
- (MenuItem
- label: 'Id'
- hideMenuOnActivated: false
- indication: showProcessId
- )
- (MenuItem
- label: 'Group'
- hideMenuOnActivated: false
- indication: showGroup
- )
- (MenuItem
- label: 'Instrumentation'
- hideMenuOnActivated: false
- indication: showInstrumentation
- )
- (MenuItem
- label: 'State'
- hideMenuOnActivated: false
- indication: showState
- )
- (MenuItem
- label: 'Prio'
- hideMenuOnActivated: false
- indication: showPrio
- )
- (MenuItem
- label: 'Used Stack'
- hideMenuOnActivated: false
- indication: showUsedStack
- )
- (MenuItem
- label: 'Total Stack'
- hideMenuOnActivated: false
- indication: showTotalStack
- )
- (MenuItem
- label: 'Current-Segment'
- hideMenuOnActivated: false
- indication: showCurrentSegment
- )
- (MenuItem
- label: 'Switch'
- hideMenuOnActivated: false
- indication: showSwitch
- )
- (MenuItem
- label: 'Where'
- hideMenuOnActivated: false
- indication: showWhere
- )
- (MenuItem
- label: 'Application'
- hideMenuOnActivated: false
- indication: showApplication
- )
- (MenuItem
- label: 'Window Title'
- hideMenuOnActivated: false
- indication: showWindowTitle
- )
- (MenuItem
- label: '-'
- )
- (MenuItem
- label: 'Show Dead Processes'
- indication: showDead
- )
- (MenuItem
- label: '-'
- )
- (MenuItem
- label: 'Update'
- itemValue: updateView
- )
- )
- nil
- nil
+ (
+ (MenuItem
+ label: 'Id'
+ hideMenuOnActivated: false
+ indication: showProcessId
+ )
+ (MenuItem
+ label: 'Group'
+ hideMenuOnActivated: false
+ indication: showGroup
+ )
+ (MenuItem
+ label: 'Instrumentation'
+ hideMenuOnActivated: false
+ indication: showInstrumentation
+ )
+ (MenuItem
+ label: 'State'
+ hideMenuOnActivated: false
+ indication: showState
+ )
+ (MenuItem
+ label: 'Prio'
+ hideMenuOnActivated: false
+ indication: showPrio
+ )
+ (MenuItem
+ label: 'Used Stack'
+ hideMenuOnActivated: false
+ indication: showUsedStack
+ )
+ (MenuItem
+ label: 'Total Stack'
+ hideMenuOnActivated: false
+ indication: showTotalStack
+ )
+ (MenuItem
+ label: 'Current-Segment'
+ hideMenuOnActivated: false
+ indication: showCurrentSegment
+ )
+ (MenuItem
+ label: 'Switch'
+ hideMenuOnActivated: false
+ indication: showSwitch
+ )
+ (MenuItem
+ label: 'Where'
+ hideMenuOnActivated: false
+ indication: showWhere
+ )
+ (MenuItem
+ label: 'Application'
+ hideMenuOnActivated: false
+ indication: showApplication
+ )
+ (MenuItem
+ label: 'Window Title'
+ hideMenuOnActivated: false
+ indication: showWindowTitle
+ )
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
+ label: 'Show Dead Processes'
+ indication: showDeadHolder
+ )
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
+ label: 'Update'
+ itemValue: updateView
+ )
+ )
+ nil
+ nil
)
! !
@@ -2081,14 +2137,14 @@
!
decreaseupdateContentsDelayTime
-
- self updateContentsDelayTime value:((self scaledUpdateContentsDelayTime - 0.1) asFixedPoint:1).
+ updateDelay := (self scaledUpdateContentsDelayTime - 0.1) asFixedPoint:1.
+ self updateContentsDelayTimeHolder value:updateDelay.
self evaluateEnableInDecreaseButtons.
!
decreaseupdateListDelayTime
-
- self updateListDelayTime value:((self scaledUpdateListDelayTime - 0.1) asFixedPoint:1).
+ listUpdateDelay := (self scaledUpdateListDelayTime - 0.1) asFixedPoint:1.
+ self updateListDelayTimeHolder value:listUpdateDelay.
self evaluateEnableInDecreaseButtons.
!
@@ -2099,13 +2155,15 @@
!
evaluateEnableInDecreaseButtons
-
- | contDelaySmallerListDelay |
-
- contDelaySmallerListDelay := (self scaledUpdateContentsDelayTime < (self scaledUpdateListDelayTime)).
- self enableDecreaseContentsDelayTime value:((self scaledUpdateContentsDelayTime <= 0.5) not).
- self enableDecreaseListDelayTime value:contDelaySmallerListDelay.
- self enableIncreaseContentsDelayTime value:contDelaySmallerListDelay.
+ | contentsDelaySmallerThanListDelay |
+
+ updateDelay := self scaledUpdateContentsDelayTime.
+ listUpdateDelay := self scaledUpdateListDelayTime.
+
+ contentsDelaySmallerThanListDelay := (updateDelay < listUpdateDelay).
+ self enableDecreaseContentsDelayTime value:(updateDelay > 0.5).
+ self enableDecreaseListDelayTime value:contentsDelaySmallerThanListDelay.
+ self enableIncreaseContentsDelayTime value:contentsDelaySmallerThanListDelay.
!
getProcessList
@@ -2114,24 +2172,24 @@
|coll|
- self showDead value ifTrue:[
- coll := Process allSubInstances asOrderedCollection.
+ self showDeadHolder value ifTrue:[
+ coll := Process allSubInstances asOrderedCollection.
] ifFalse:[
- coll := ProcessorScheduler knownProcesses asOrderedCollection.
- coll add:Processor scheduler.
+ coll := ProcessorScheduler knownProcesses asOrderedCollection.
+ coll add:Processor scheduler.
].
^ coll
!
increaseupdateContentsDelayTime
-
- self updateContentsDelayTime value:((self scaledUpdateContentsDelayTime + 0.1) asFixedPoint:1).
+ updateDelay := (self scaledUpdateContentsDelayTime + 0.1) asFixedPoint:1.
+ self updateContentsDelayTimeHolder value:updateDelay.
self evaluateEnableInDecreaseButtons.
!
increaseupdateListDelayTime
-
- self updateListDelayTime value:((self scaledUpdateListDelayTime + 0.1) asFixedPoint:1).
+ listUpdateDelay := (self scaledUpdateListDelayTime + 0.1) asFixedPoint:1.
+ self updateListDelayTimeHolder value:listUpdateDelay.
self evaluateEnableInDecreaseButtons.
!
@@ -2174,6 +2232,14 @@
^ currentSortOrder
!
+interruptCountHolder
+
+ interruptCountHolder isNil ifTrue:[
+ interruptCountHolder := '-' asValue.
+ ].
+ ^ interruptCountHolder.
+!
+
isNotTimeslicing
^ self isTimeslicing not
@@ -2196,31 +2262,33 @@
scaledUpdateContentsDelayTime
- ^ self updateContentsDelayTime value asFloat asFixedPoint:1.
+ ^ self updateContentsDelayTimeHolder value asFloat asFixedPoint:1.
!
scaledUpdateListDelayTime
- ^ self updateListDelayTime value asFloat asFixedPoint:1.
+ ^ self updateListDelayTimeHolder value asFloat asFixedPoint:1.
!
selectedProcesses
selectedProcesses isNil ifTrue:[
- selectedProcesses := ValueHolder new.
- selectedProcesses addDependent:self.
+ selectedProcesses := ValueHolder new.
+ selectedProcesses onChangeSend:#selectionChanged to:self.
+ "/ selectedProcesses addDependent:self.
].
^ selectedProcesses.
!
-showDead
+showDeadHolder
"return/create the 'showDead' value holder (automatically generated)"
- showDead isNil ifTrue:[
- showDead := false asValue.
- showDead addDependent:self.
+ showDeadHolder isNil ifTrue:[
+ showDeadHolder := false asValue.
+ showDeadHolder onChangeSend:#updateList to:self.
+ "/ showDead addDependent:self.
].
- ^ showDead
+ ^ showDeadHolder
!
sortBlock
@@ -2246,22 +2314,30 @@
^ tableColumns.
!
-updateContentsDelayTime
-
- updateContentsDelayTime isNil ifTrue:[
- updateContentsDelayTime := updateDelay asValue.
- updateContentsDelayTime onChangeSend:#evaluateEnableInDecreaseButtons to:self.
+timerActionCountHolder
+
+ timerActionCountHolder isNil ifTrue:[
+ timerActionCountHolder := '-' asValue.
].
- ^ updateContentsDelayTime.
+ ^ timerActionCountHolder.
!
-updateListDelayTime
-
- updateListDelayTime isNil ifTrue:[
- updateListDelayTime := listUpdateDelay asValue.
- updateListDelayTime onChangeSend:#evaluateEnableInDecreaseButtons to:self.
+updateContentsDelayTimeHolder
+
+ updateContentsDelayTimeHolder isNil ifTrue:[
+ updateContentsDelayTimeHolder := updateDelay asValue.
+ updateContentsDelayTimeHolder onChangeSend:#evaluateEnableInDecreaseButtons to:self.
].
- ^ updateListDelayTime.
+ ^ updateContentsDelayTimeHolder.
+!
+
+updateListDelayTimeHolder
+
+ updateListDelayTimeHolder isNil ifTrue:[
+ updateListDelayTimeHolder := listUpdateDelay asValue.
+ updateListDelayTimeHolder onChangeSend:#evaluateEnableInDecreaseButtons to:self.
+ ].
+ ^ updateListDelayTimeHolder.
! !
!ProcessMonitorV2 methodsFor:'aspects-column'!
@@ -2578,17 +2654,9 @@
"stub code automatically generated - please change as required"
changedObject == builder window ifTrue:[
- something == #visibility ifTrue:[
- self updateList.
- ].
- ].
- changedObject == self selectedProcesses ifTrue:[
- self selectionChanged.
- ^ self
- ].
- changedObject == self showDead ifTrue:[
- self updateList.
- ^ self
+ something == #visibility ifTrue:[
+ self updateList.
+ ].
].
super update:something with:aParameter from:changedObject
!
@@ -2710,14 +2778,14 @@
showDetail := (Smalltalk at:#SystemDebugging ifAbsent:false).
updateSema := Semaphore forMutualExclusion.
- updateDelay := 0.5.
- listUpdateDelay := 5.0.
+ updateDelay := 1.0 "0.5" asFixedPoint:1. "/ seconds
+ listUpdateDelay := 5.0 asFixedPoint:1.
"/ event mode is no longer used;
"/ this event support may vanish
Processor isPureEventDriven ifTrue:[
- updateBlock := [self updateStatus:nil].
- listUpdateBlock := [self updateList].
+ updateBlock := [self updateStatus:nil].
+ listUpdateBlock := [self updateList].
].
"Modified: / 17-08-2011 / 11:39:13 / cg"
@@ -3426,9 +3494,9 @@
wg := self windowGroupOfProcess:aProcess.
wg notNil ifTrue:[
- (topViews := wg topViews) notEmptyOrNil ifTrue:[
- ^ '"',topViews first label,'"'.
- ].
+ (topViews := wg topViews) notEmptyOrNil ifTrue:[
+ ^ '"',(topViews first label ? '<nil>'),'"'.
+ ].
].
^ ''.
@@ -3557,44 +3625,44 @@
startUpdateProcess
updateBlock notNil ifTrue:[
- Processor addTimedBlock:updateBlock afterSeconds:self scaledUpdateContentsDelayTime.
- Processor addTimedBlock:listUpdateBlock afterSeconds:self scaledUpdateListDelayTime.
+ Processor addTimedBlock:updateBlock afterSeconds:updateDelay.
+ Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay.
] ifFalse:[
- "after a restart, updateProcess is a dead process"
- self assert:(updateProcess isNil or:[updateProcess isDead]).
-
- updateProcess := [
- [
- |id cnt myDelay|
-
- myDelay := Delay forSeconds:self scaledUpdateContentsDelayTime.
-
- "
- every updateDelay (0.5), we look which process runs;
- every half second, the status is updated.
- every listUpdateDelay (5s), the list of processes is
- built up again
- "
- [true] whileTrue:[
- myDelay delay:self scaledUpdateContentsDelayTime * 1000.
- ((self scaledUpdateListDelayTime // self scaledUpdateContentsDelayTime) max:2) - 1 timesRepeat:[
- myDelay wait.
- self updateStatus:nil.
- ].
- myDelay wait.
- self updateList.
- ]
- ] ifCurtailed:[
- updateProcess := nil
- ]
- ] forkAt:(Processor userSchedulingPriority + 1).
- updateProcess name:'monitor [' ,
- Processor activeProcess id printString ,
- '] update'.
- "
- raise my own priority
- "
- Processor activeProcess priority:(Processor userSchedulingPriority + 2)
+ "after a restart, updateProcess is a dead process"
+ self assert:(updateProcess isNil or:[updateProcess isDead]).
+
+ updateProcess := [
+ [
+ |id cnt myDelay|
+
+ myDelay := Delay forSeconds:updateDelay.
+
+ "
+ every updateDelay (0.5), we look which process runs;
+ every half second, the status is updated.
+ every listUpdateDelay (5s), the list of processes is
+ built up again
+ "
+ [true] whileTrue:[
+ myDelay delay:updateDelay * 1000.
+ ((listUpdateDelay // updateDelay) max:2) - 1 timesRepeat:[
+ myDelay wait.
+ self updateStatus:nil.
+ ].
+ myDelay wait.
+ self updateList.
+ ]
+ ] ifCurtailed:[
+ updateProcess := nil
+ ]
+ ] forkAt:(Processor userSchedulingPriority + 1).
+ updateProcess name:'monitor [' ,
+ Processor activeProcess id printString ,
+ '] update'.
+ "
+ raise my own priority
+ "
+ Processor activeProcess priority:(Processor userSchedulingPriority + 2)
].
!
@@ -3736,114 +3804,159 @@
!
updateList
-
+ "recompute the list of processes"
+
|newList|
processTable shown ifTrue:[
- newList := self getProcessList.
- visibleBlock notNil ifTrue:[
- newList := newList select:visibleBlock
- ].
- self updateStatus:newList.
+ newList := self getProcessList.
+ visibleBlock notNil ifTrue:[
+ newList := newList select:visibleBlock
+ ].
+ self updateStatus:newList.
].
updateBlock notNil ifTrue:[
- Processor removeTimedBlock:listUpdateBlock.
- Processor addTimedBlock:listUpdateBlock afterSeconds:self scaledUpdateListDelayTime.
+ Processor removeTimedBlock:listUpdateBlock.
+ Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
].
!
updateStatus:newProcessList
-
|startTime endTime deltaT|
-
startTime := Timestamp now.
updateSema critical:[
- self updateTable:newProcessList.
+ self updateTable:newProcessList.
].
endTime := Timestamp now.
+
+ lastUpdateTimestamp notNil ifTrue:[
+ |timeDelta newInterruptCount newTimerActionCount n nPerSecond s|
+
+ timeDelta := (endTime - lastUpdateTimestamp) asMilliseconds / 1000.0.
+
+ "/ update the interrupt counts
+ newInterruptCount := Processor interruptCounter.
+ newTimerActionCount := Processor timedActionCounter.
+ lastInterruptCount notNil ifTrue:[
+ "/ attention - these are modulu counters.
+ newInterruptCount >= lastInterruptCount ifTrue:[
+ n := newInterruptCount-lastInterruptCount.
+ n == 0 ifTrue:[
+ "/ the common case
+ s := '0'
+ ] ifFalse:[
+ nPerSecond := n / timeDelta.
+ s := (nPerSecond asInteger "asFixedPoint:1") printString
+ ].
+ self interruptCountHolder value:s
+ ].
+ ].
+ lastTimerActionCount notNil ifTrue:[
+ "/ attention - these are modulu counters.
+ newTimerActionCount >= lastTimerActionCount ifTrue:[
+ n := newTimerActionCount-lastTimerActionCount.
+ n == 0 ifTrue:[
+ "/ the common case
+ s := '0'
+ ] ifFalse:[
+ nPerSecond := n / timeDelta.
+ s := (nPerSecond asInteger "asFixedPoint:1") printString
+ ].
+ self timerActionCountHolder value:s
+ ].
+ ].
+
+ lastInterruptCount := newInterruptCount.
+ lastTimerActionCount := newTimerActionCount.
+ ].
+ lastUpdateTimestamp := endTime.
+
+ "/ a check, in case the computation took longer than 20%
+ "/ of the delay time. Then increase the update interval.
+ "/ This is to avoid that the processMonitor creates too much overhead
+ "/ (in case we have many processes)
deltaT := (endTime millisecondDeltaFrom:startTime) / 1000.0.
-"/ Transcript show:deltaT; show:' ' ; showCR:(self scaledUpdateContentsDelayTime / 10.0).
- deltaT > (self scaledUpdateContentsDelayTime / 5) ifTrue:[
- "/ the update took longer than 20% - make delay longer, to reduce cpu load.
- self updateContentsDelayTime value:(self scaledUpdateContentsDelayTime * 2).
- "/ Transcript show:'+++ '; showCR:self scaledUpdateContentsDelayTime.
- ] ifFalse:[
-"/ self scaledUpdateContentsDelayTime > 0.5 ifTrue:[
-"/ deltaT < (self scaledUpdateContentsDelayTime / 20) ifTrue:[
-"/ "/ the update took less than 5% - make delay smaller for better animation.
-"/ self updateContentsDelayTime value:((self scaledUpdateContentsDelayTime / 2) max:0.5).
-"/ "/ Transcript show:'--- ';showCR:self scaledUpdateContentsDelayTime.
-"/ ].
-"/ ].
+ "/ Transcript show:deltaT; show:' ' ; showCR:(self scaledUpdateContentsDelayTime / 10.0).
+ deltaT > (updateDelay / 5) ifTrue:[
+ "/ the update took longer than 20% - make delay longer, to reduce cpu load.
+ updateDelay := updateDelay * 2.
+ self updateContentsDelayTimeHolder value:updateDelay.
+ "/ Transcript show:'+++ '; showCR:self scaledUpdateContentsDelayTime.
].
+
updateBlock notNil ifTrue:[
- Processor removeTimedBlock:updateBlock.
- Processor addTimedBlock:updateBlock afterSeconds:self scaledUpdateContentsDelayTime.
+ Processor removeTimedBlock:updateBlock.
+ Processor addTimedBlock:updateBlock afterSeconds:updateDelay.
]
!
updateTable:newProcessList
- |oldSelection newList sel diff weakProcessList|
-
- processTable shown ifTrue:[
-"/ Transcript showCR:('update the table', Timestamp now printString, 'with new list:', newProcessList notNil asString).
- sel := self selectedProcesses value.
- sel notNil ifTrue:[
- oldSelection := OrderedCollection new.
- sel do:[:proItem|
- proItem processInstance notNil ifTrue:[
- oldSelection add:(proItem processInstance)
- ].
- ].
- ].
-"/ Transcript showCR:'oldSelection on catch in updateTable: ', (oldSelection isEmptyOrNil ifTrue:['nil'] ifFalse:[oldSelection first printString]).
- newProcessList isNil ifTrue:[
- newList := OrderedCollection new.
- processList do:[:oldItem |
- | newItem |
- (self showDead value
- or:[oldItem processInstance notNil
- and:[oldItem processInstance isDead not]]) ifTrue:[
- newItem := oldItem copy.
- self fillItemInformationIn:newItem.
- newList add:newItem.
- ]
- ].
- ] ifFalse:[
- "/ remove dead processes if not shown
- newList := OrderedCollection new.
- weakProcessList := WeakArray withAll:newProcessList.
- weakProcessList keysAndValuesDo:[:indexInWeakArray :procOrNilOrZero |
- "/ in a weakarray, dead entries are 0
- (procOrNilOrZero notNil and:[procOrNilOrZero class ~~ SmallInteger]) ifTrue:[
- (procOrNilOrZero isDead not or:[self showDead value]) ifTrue:[
- | processItem |
- processItem := ProcessItem new.
- self fillItemInformationIn:processItem with:procOrNilOrZero inArray:weakProcessList atIndex:indexInWeakArray.
- newList add:processItem.
- ]
- ]
- ].
- ].
- newList sort:self sortBlock.
- newList doWithIndex:[:newItem :index|
- | oldItem |
- oldItem := processList at:index ifAbsent:nil.
- oldItem isNil ifTrue:[
- processList add:newItem beforeIndex:index
- ] ifFalse:[
- self updateChangedItem:oldItem newItem:newItem atIndex:index
- ]
- ].
- diff := processList size - newList size.
- diff > 0 ifTrue:[
- processList removeLast:diff
- ].
+ |oldSelection newList sel diff weakProcessList showDead|
+
+ processTable shown ifFalse:[^ self].
+
+ showDead := self showDeadHolder value.
+
+ "/ Transcript showCR:('update the table', Timestamp now printString, 'with new list:', newProcessList notNil asString).
+ sel := self selectedProcesses value.
+ sel notNil ifTrue:[
+ oldSelection := OrderedCollection new.
+ sel do:[:proItem|
+ proItem processInstance notNil ifTrue:[
+ oldSelection add:(proItem processInstance)
+ ].
+ ].
+ ].
+
+ newList := OrderedCollection new.
+
+ "/ Transcript showCR:'oldSelection on catch in updateTable: ', (oldSelection isEmptyOrNil ifTrue:['nil'] ifFalse:[oldSelection first printString]).
+ newProcessList isNil ifTrue:[
+ processList do:[:oldItem |
+ | newItem process|
+ (showDead
+ or:[
+ (process := oldItem processInstance) notNil
+ and:[process isDead not]]
+ ) ifTrue:[
+ newItem := oldItem copy.
+ self fillItemInformationIn:newItem.
+ newList add:newItem.
+ ]
+ ].
+ ] ifFalse:[
+ "/ remove dead processes if not shown
+ weakProcessList := WeakArray withAll:newProcessList.
+ weakProcessList keysAndValuesDo:[:indexInWeakArray :procOrNilOrZero |
+ "/ in a weakarray, dead entries are 0
+ (procOrNilOrZero notNil and:[procOrNilOrZero class ~~ SmallInteger]) ifTrue:[
+ (procOrNilOrZero isDead not or:[showDead]) ifTrue:[
+ | processItem |
+ processItem := ProcessItem new.
+ self fillItemInformationIn:processItem with:procOrNilOrZero inArray:weakProcessList atIndex:indexInWeakArray.
+ newList add:processItem.
+ ]
+ ]
+ ].
+ ].
+ newList sort:self sortBlock.
+ newList doWithIndex:[:newItem :index|
+ | oldItem |
+ oldItem := processList at:index ifAbsent:nil.
+ oldItem isNil ifTrue:[
+ processList add:newItem beforeIndex:index
+ ] ifFalse:[
+ self updateChangedItem:oldItem newItem:newItem atIndex:index
+ ]
+ ].
+ diff := processList size - newList size.
+ diff > 0 ifTrue:[
+ processList removeLast:diff
+ ].
"/ Transcript showCR:'oldSelection on set in updateTable: ', (oldSelection isEmptyOrNil ifTrue:['nil'] ifFalse:[oldSelection first printString]).
- self changeSelectionToProcesses:oldSelection.
- ].
+ self changeSelectionToProcesses:oldSelection.
! !
!ProcessMonitorV2::ProcessItem methodsFor:'accessing'!