SystemStatusMonitor.st
changeset 2488 65689c6d5bd6
parent 2410 292d61292ac8
child 2699 dcb83b594b14
equal deleted inserted replaced
2487:4ac80975b91d 2488:65689c6d5bd6
    65 
    65 
    66 !SystemStatusMonitor methodsFor:'drawing'!
    66 !SystemStatusMonitor methodsFor:'drawing'!
    67 
    67 
    68 updateView
    68 updateView
    69     self updateList.
    69     self updateList.
    70     self updateStatus
    70     self updateStatus:nil
    71 
    71 
    72     "Created: 23.1.1997 / 02:27:05 / cg"
    72     "Created: / 23.1.1997 / 02:27:05 / cg"
       
    73     "Modified: / 14.12.1999 / 20:47:37 / cg"
    73 ! !
    74 ! !
    74 
    75 
    75 !SystemStatusMonitor methodsFor:'events'!
    76 !SystemStatusMonitor methodsFor:'events'!
    76 
    77 
    77 canHandle:key
    78 canHandle:key
   115     listUpdateDelay := 5.
   116     listUpdateDelay := 5.
   116 
   117 
   117     "/ event mode is no longer used;
   118     "/ event mode is no longer used;
   118     "/ this event support may vanish
   119     "/ this event support may vanish
   119     Processor isPureEventDriven ifTrue:[
   120     Processor isPureEventDriven ifTrue:[
   120 	updateBlock := [self updateStatus].
   121         updateBlock := [self updateStatus:nil].
   121 	listUpdateBlock := [self updateList].
   122         listUpdateBlock := [self updateList].
   122     ].
   123     ].
   123 
   124 
   124     "
   125     "
   125      ProcessMonitor open
   126      ProcessMonitor open
   126     "
   127     "
   127 
   128 
   128     "Modified: / 5.8.1998 / 13:06:04 / cg"
   129     "Modified: / 14.12.1999 / 20:47:57 / cg"
   129 !
   130 !
   130 
   131 
   131 mapped
   132 mapped
   132     super mapped.
   133     super mapped.
   133     self updateStatus.
   134     self updateStatus:nil.
   134     self updateList.
   135     self updateList.
   135 
   136 
   136     "Created: 23.1.1997 / 02:30:05 / cg"
   137     "Created: / 23.1.1997 / 02:30:05 / cg"
       
   138     "Modified: / 14.12.1999 / 20:47:54 / cg"
   137 !
   139 !
   138 
   140 
   139 realize
   141 realize
   140     super realize.
   142     super realize.
   141 
   143 
   153     "Created: 23.1.1997 / 02:30:43 / cg"
   155     "Created: 23.1.1997 / 02:30:43 / cg"
   154 !
   156 !
   155 
   157 
   156 startUpdateProcess
   158 startUpdateProcess
   157     updateBlock notNil ifTrue:[
   159     updateBlock notNil ifTrue:[
   158 	Processor addTimedBlock:updateBlock afterSeconds:updateDelay.
   160         Processor addTimedBlock:updateBlock afterSeconds:updateDelay.
   159 	Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay.
   161         Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay.
   160     ] ifFalse:[
   162     ] ifFalse:[
   161 	updateProcess := [
   163         updateProcess := [
   162 	    [
   164             [
   163 		|id cnt myDelay|
   165                 |id cnt myDelay|
   164 
   166 
   165 		myDelay := Delay forSeconds:0.5.
   167                 myDelay := Delay forSeconds:0.5.
   166 
   168 
   167 		"
   169                 "
   168 		 every 20ms, we look which process runs;
   170                  every 20ms, we look which process runs;
   169 		 every half second, the status is updated.
   171                  every half second, the status is updated.
   170 		 every 5 seconds, the list of processes is
   172                  every 5 seconds, the list of processes is
   171 		 built up again
   173                  built up again
   172 		"
   174                 "
   173 		[true] whileTrue:[
   175                 [true] whileTrue:[
   174 		    1 to:9 do:[:i |
   176                     1 to:9 do:[:i |
   175 "/                        cpuUsages := IdentityDictionary new.
   177 "/                        cpuUsages := IdentityDictionary new.
   176 "/                        1 to:25 do:[:i |
   178 "/                        1 to:25 do:[:i |
   177 "/                            (Delay forSeconds:0.02) wait.
   179 "/                            (Delay forSeconds:0.02) wait.
   178 "/                            id := Processor interruptedProcess id.
   180 "/                            id := Processor interruptedProcess id.
   179 "/                            cnt := cpuUsages at:id ifAbsent:[0].
   181 "/                            cnt := cpuUsages at:id ifAbsent:[0].
   180 "/                            cpuUsages at:id put:cnt + 1.
   182 "/                            cpuUsages at:id put:cnt + 1.
   181 "/                        ].
   183 "/                        ].
   182 			myDelay wait.
   184                         myDelay wait.
   183 			self updateStatus.
   185                         self updateStatus:nil.
   184 		    ].
   186                     ].
   185 		    myDelay wait.
   187                     myDelay wait.
   186 		    self updateList.
   188                     self updateList.
   187 		]
   189                 ]
   188 	    ] valueOnUnwindDo:[
   190             ] valueOnUnwindDo:[
   189 		updateProcess := nil
   191                 updateProcess := nil
   190 	    ]
   192             ]
   191 	]  forkAt:(Processor userSchedulingPriority + 1).
   193         ]  forkAt:(Processor userSchedulingPriority + 1).
   192 	updateProcess name:'monitor [' , 
   194         updateProcess name:'monitor [' , 
   193 			   Processor activeProcess id printString ,
   195                            Processor activeProcess id printString ,
   194 			   '] update'.
   196                            '] update'.
   195 	"
   197         "
   196 	 raise my own priority
   198          raise my own priority
   197 	"
   199         "
   198 	Processor activeProcess priority:(Processor userSchedulingPriority + 2)
   200         Processor activeProcess priority:(Processor userSchedulingPriority + 2)
   199     ].
   201     ].
   200 
   202 
   201     "Created: 23.1.1997 / 02:30:58 / cg"
   203     "Created: / 23.1.1997 / 02:30:58 / cg"
   202     "Modified: 24.1.1997 / 21:40:11 / cg"
   204     "Modified: / 14.12.1999 / 20:47:50 / cg"
   203 ! !
   205 ! !
   204 
   206 
   205 !SystemStatusMonitor methodsFor:'queries'!
   207 !SystemStatusMonitor methodsFor:'queries'!
   206 
   208 
   207 preferredExtent
   209 preferredExtent
   214 ! !
   216 ! !
   215 
   217 
   216 !SystemStatusMonitor class methodsFor:'documentation'!
   218 !SystemStatusMonitor class methodsFor:'documentation'!
   217 
   219 
   218 version
   220 version
   219     ^ '$Header: /cvs/stx/stx/libtool/SystemStatusMonitor.st,v 1.9 1999-09-23 12:45:18 stefan Exp $'
   221     ^ '$Header: /cvs/stx/stx/libtool/SystemStatusMonitor.st,v 1.10 1999-12-14 20:15:32 cg Exp $'
   220 ! !
   222 ! !