modes.tcl
3.13 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#
# 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.
#
###
### modes.tcl
###
FileSourced modes.tcl
if ![info exists modesByPID] {
set modesByPID 0
}
timing create modes
log [timing fields]
proc modesSwitch args {
global PROCESS PID CPU CELL M RUNNING_HIVE PARAM
global modesByPID
if $modesByPID {
set args [linsert $args 0 PID$PID($CPU)]
}
if [info exists RUNNING_HIVE] {
eval timing switch modes ${CELL}_$PID($CPU) cell$CELL $args
} elseif { $PARAM(MACHINE.Count) == 1 } {
eval timing switch modes $PID($CPU) $args
} else {
eval timing switch modes $M($CPU)_$PID($CPU) machine$M($CPU) $args
}
}
###
### Initialization based on current state
###
annotation set simos enter {
if [inUserMode] {
modesSwitch
} elseif {$PROCESS($CPU) == "idle"} {
modesSwitch kernel idle
} elseif {($SIMOS(ISA)=="ALPHA") && ($pc & 1)} {
modesSwitch kernel pal
} else {
modesSwitch kernel
}
}
###
### The Annotations
###
if {$SIMOS(ISA)=="ALPHA"} {
annotation set osEvent switchIn {
modesSwitch kernel kernel
}
} else {
annotation set osEvent switchIn {
modesSwitch kernel
}
}
annotation set osEvent procexit {
if [info exists RUNNING_HIVE] {
timing terminate modes ${CELL}_$PID($CPU)
} elseif { $PARAM(MACHINE.Count) == 1 } {
timing terminate modes $PID($CPU)
} else {
timing terminate modes $M($CPU)_$PID($CPU)
}
}
proc foobar { msg } {
global CYCLES pc
if {$CYCLES > 6152856} {
log "Modes $CYCLES pc= [format %-20s $pc] top=[timing current modes] action $msg\n"
}
}
annotation set osEvent startKernel {
#foobar "startKernel"
timing start modes kernel
}
annotation set osEvent endKernel {
#foobar "endKernel"
timing end modes kernel
}
if {$SIMOS(ISA)=="ALPHA"} {
annotation set osEvent startPal {
#foobar startPal
timing start modes pal
}
annotation set osEvent endPal {
timing end modes pal
#foobar endPal
set cur [timing current modes]
# poped too far
if {$cur=="ROOT" && ![inUserMode]} {
#console "endPal cur=$cur exc=$IPR(0x10b) inUserMode=[inUserMode] \n"
timing start modes kernel
}
}
}
annotation set osEvent startIdle {
#foobar "startIdle"
if { [timing current modes] != "idle"} {
timing start modes idle
}
}
annotation set osEvent endIdle {
#foobar "endIdle"
timing end modes idle
}
annotation set osEvent startSync {
timing start modes sync
}
annotation set osEvent endSync {
timing end modes sync
}
if [info exists RUNNING_HIVE] {
annotation set osEvent startRpc {
timing start modes rpcwait
}
annotation set osEvent endRpc {
timing end modes rpcwait
}
}
###
### Need to dump to stats
###
annotation set simos periodic {
log [timing dump modes]
}
annotation set simos exit {
timing exit modes
log [timing dump modes]
}