sema_stats.tcl
2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
####
#### sema_stats.tcl
####
##
## module init
##
proc semaStatsDump {} {
global ssSema semaRa semaFree
log "SEMASTATS: start\n"
foreach sema [array names semaRa] {
set ra [symbol find kernel [lindex $semaRa($sema) 1]]
log "SEMAINIT: $sema $semaRa($sema) $ra\n"
}
foreach sema [array names semaFree] {
set ra [symbol find kernel $semaFree($sema)]
log "SEMAFREE: $sema $semaFree($sema) $ra\n"
}
foreach sema [array names ssSema] {
set l [symbol find kernel $sema]
if [string match "end+*" $l] {
set l $sema
}
log "SEMASTATS: sema $l "
log "[statistics list ssSemaWait($sema)]\n"
}
log "SEMASTATS: end\n"
}
annotation set simos exit {
semaStatsDump
}
annotation set simos sigusr {
semaStatsDump
}
##
## helper routines
##
proc semaStatsWait {sema proc} {
global CPU CYCLES ssSemaStart ssSema
set ssSemaStart($sema,$proc) $CYCLES
if ![info exists "ssSema($sema)"] {
set "ssSema($sema)" 1
statistics create ssSemaWait($sema)
}
}
proc semaStatsAcquire {sema proc} {
global CPU CYCLES ssSemaStart
if [info exists ssSemaStart($sema,$proc)] {
statistics entry ssSemaWait($sema) [expr $CYCLES-$ssSemaStart($sema,$proc)]
set ssSemaStart($sema,$proc) 0
}
}
##
## the annotations
##
annotation set pc kernel:sema.c:semaaddproc:START {
semaStatsWait $a0 $a1
}
annotation set pc kernel:sema.c:semarmproc:START {
if {([info exists ssSemaStart($a0,$a1)]) && ($ssSemaStart($a0,$a1) != 0) } {
semaStatsAcquire $a0 $a1
}
}
annotation set pc kernel:sema.c:semadq:START {
set semaDq($CPU) $a0
}
annotation set pc kernel:sema.c:semadq:END {
semaStatsAcquire [hex $semaDq($CPU)] $v0
}
# tracking inits of semaphores
annotation set pc kernel::initsema:START {
if {![info exists semaRa($a0)]} {
set semaRa($a0) "I $ra none"
}
}
annotation set pc kernel::initnsema_lifo:START {
if {![info exists semaRa($a0)]} {
set semaRa($a0) "L $ra [symbol read ::((char*)$a2)]"
}
}
annotation set pc kernel::initsema_mutex:START {
if {![info exists semaRa($a0)]} {
set semaRa($a0) "M $ra none"
}
}
annotation set pc kernel::initnsema_mutex:START {
if {![info exists semaRa($a0)]} {
set semaRa($a0) "MN $ra [symbol read ::((char*)$a1)]"
}
}
annotation set pc kernel::initnsema:START {
if {![info exists semaRa($a0)]} {
set semaRa($a0) "N $ra [symbol read ::((char*)$a2)]"
}
}
annotation set pc kernel::freesema:START {
if {![info exists semaFree($a0)]} {
set semaFree($a0) $ra
}
}