class: SemaphoreMonitor
changed: #updateStatus:
colorize lines
add waiting process priorities
--- a/SemaphoreMonitor.st Fri Feb 08 15:10:27 2013 +0100
+++ b/SemaphoreMonitor.st Fri Feb 08 19:42:22 2013 +0100
@@ -9,9 +9,6 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
-
-
"{ Package: 'stx:libtool' }"
SystemStatusMonitor subclass:#SemaphoreMonitor
@@ -127,21 +124,25 @@
list add:(String new:self titleLine size withAll:$-).
semaphores validElementsDo:[:aSemaphore |
- |waiters waitersNames nm id str owner|
+ |waiters waitersNames nm id str owner color line count|
"/ need a copy - it may change while being enumerated
-
- waiters := aSemaphore waitingProcesses copy.
+ [
+ count := aSemaphore count.
+ waiters := aSemaphore waitingProcesses copy.
+ ] valueUninterruptably.
str := '' writeStream.
[
waiters notNil ifTrue:[
waiters do:[:aProcess |
str nextPut:$[.
- str nextPutAll:(aProcess id printString).
+ aProcess id printOn:str.
str nextPutAll:' '''.
str nextPutAll:(aProcess name contractTo:40).
- str nextPutAll:''']'.
+ str nextPutAll:'''<'.
+ aProcess priority printOn:str.
+ str nextPutAll:'>]'.
str space.
].
]
@@ -163,18 +164,35 @@
] ifFalse:[
owner := owner printStringLeftPaddedTo:5
].
- list add:(
- (id printStringPaddedTo:6)
+ line := (id printStringPaddedTo:6)
, ' '
, ((nm contractTo:25) paddedTo:25)
, ' '
- , (aSemaphore count printStringLeftPaddedTo:3)
+ , (count printStringLeftPaddedTo:3)
, ' '
, owner printString
, ' '
, (waiters size printStringLeftPaddedTo:3)
, ' '
- , waitersNames).
+ , waitersNames.
+
+ count > 0 ifTrue:[
+ waiters size > 0 ifTrue:[
+ "this happens if a low priority process is ready to run but didn't wake up yet"
+ color := Color red.
+"/ self beep.
+ ] ifFalse:[
+ "fine, this semaphore is available"
+ color := Color blue.
+ ].
+ line := line colorizeAllWith:color.
+ ] ifFalse:[
+ waiters size > 0 ifTrue:[
+ line := line colorizeAllWith:Color brown.
+ ].
+ ].
+
+ list add:line.
oldSelection notNil ifTrue:[
(oldSelection includes:id) ifTrue:[
newSelection add:list size.
@@ -357,5 +375,6 @@
!SemaphoreMonitor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/SemaphoreMonitor.st,v 1.16 2002-11-15 11:40:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SemaphoreMonitor.st,v 1.17 2013-02-08 18:42:22 stefan Exp $'
! !
+