thread_state.hh (9101:d39368c6f502) thread_state.hh (10110:580b47334a97)
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Kevin Lim
29 */
30
31#ifndef __CPU_THREAD_STATE_HH__
32#define __CPU_THREAD_STATE_HH__
33
34#include "arch/types.hh"
35#include "config/the_isa.hh"
36#include "cpu/base.hh"
37#include "cpu/profile.hh"
38#include "cpu/thread_context.hh"
39#include "mem/mem_object.hh"
40#include "sim/process.hh"
41
42class EndQuiesceEvent;
43class FunctionProfile;
44class ProfileNode;
45namespace TheISA {
46 namespace Kernel {
47 class Statistics;
48 }
49}
50
51class Checkpoint;
52
53/**
54 * Struct for holding general thread state that is needed across CPU
55 * models. This includes things such as pointers to the process,
56 * memory, quiesce events, and certain stats. This can be expanded
57 * to hold more thread-specific stats within it.
58 */
59struct ThreadState {
60 typedef ThreadContext::Status Status;
61
62 ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
63
64 virtual ~ThreadState();
65
66 void serialize(std::ostream &os);
67
68 void unserialize(Checkpoint *cp, const std::string &section);
69
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Kevin Lim
29 */
30
31#ifndef __CPU_THREAD_STATE_HH__
32#define __CPU_THREAD_STATE_HH__
33
34#include "arch/types.hh"
35#include "config/the_isa.hh"
36#include "cpu/base.hh"
37#include "cpu/profile.hh"
38#include "cpu/thread_context.hh"
39#include "mem/mem_object.hh"
40#include "sim/process.hh"
41
42class EndQuiesceEvent;
43class FunctionProfile;
44class ProfileNode;
45namespace TheISA {
46 namespace Kernel {
47 class Statistics;
48 }
49}
50
51class Checkpoint;
52
53/**
54 * Struct for holding general thread state that is needed across CPU
55 * models. This includes things such as pointers to the process,
56 * memory, quiesce events, and certain stats. This can be expanded
57 * to hold more thread-specific stats within it.
58 */
59struct ThreadState {
60 typedef ThreadContext::Status Status;
61
62 ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
63
64 virtual ~ThreadState();
65
66 void serialize(std::ostream &os);
67
68 void unserialize(Checkpoint *cp, const std::string &section);
69
70 int cpuId() { return baseCpu->cpuId(); }
70 int cpuId() const { return baseCpu->cpuId(); }
71
71
72 int contextId() { return _contextId; }
72 int contextId() const { return _contextId; }
73
74 void setContextId(int id) { _contextId = id; }
75
76 void setThreadId(ThreadID id) { _threadId = id; }
77
73
74 void setContextId(int id) { _contextId = id; }
75
76 void setThreadId(ThreadID id) { _threadId = id; }
77
78 ThreadID threadId() { return _threadId; }
78 ThreadID threadId() const { return _threadId; }
79
79
80 Tick readLastActivate() { return lastActivate; }
80 Tick readLastActivate() const { return lastActivate; }
81
81
82 Tick readLastSuspend() { return lastSuspend; }
82 Tick readLastSuspend() const { return lastSuspend; }
83
84 /**
85 * Initialise the physical and virtual port proxies and tie them to
86 * the data port of the CPU.
87 *
88 * @param tc ThreadContext for the virtual-to-physical translation
89 */
90 void initMemProxies(ThreadContext *tc);
91
92 void dumpFuncProfile();
93
94 EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
95
96 void profileClear();
97
98 void profileSample();
99
100 TheISA::Kernel::Statistics *getKernelStats() { return kernelStats; }
101
102 PortProxy &getPhysProxy();
103
104 FSTranslatingPortProxy &getVirtProxy();
105
106 Process *getProcessPtr() { return process; }
107
108 SETranslatingPortProxy &getMemProxy();
109
110 /** Reads the number of instructions functionally executed and
111 * committed.
112 */
113 Counter readFuncExeInst() { return funcExeInst; }
114
115 /** Sets the total number of instructions functionally executed
116 * and committed.
117 */
118 void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
119
120 /** Returns the status of this thread. */
121 Status status() const { return _status; }
122
123 /** Sets the status of this thread. */
124 void setStatus(Status new_status) { _status = new_status; }
125
126 public:
127
128 /** Number of instructions committed. */
129 Counter numInst;
130 /** Stat for number instructions committed. */
131 Stats::Scalar numInsts;
132 /** Number of ops (including micro ops) committed. */
133 Counter numOp;
134 /** Stat for number ops (including micro ops) committed. */
135 Stats::Scalar numOps;
136 /** Stat for number of memory references. */
137 Stats::Scalar numMemRefs;
138
139 /** Number of simulated loads, used for tracking events based on
140 * the number of loads committed.
141 */
142 Counter numLoad;
143
144 /** The number of simulated loads committed prior to this run. */
145 Counter startNumLoad;
146
147 protected:
148 ThreadContext::Status _status;
149
150 // Pointer to the base CPU.
151 BaseCPU *baseCpu;
152
153 // system wide HW context id
154 int _contextId;
155
156 // Index of hardware thread context on the CPU that this represents.
157 ThreadID _threadId;
158
159 public:
160 /** Last time activate was called on this thread. */
161 Tick lastActivate;
162
163 /** Last time suspend was called on this thread. */
164 Tick lastSuspend;
165
166 public:
167 FunctionProfile *profile;
168 ProfileNode *profileNode;
169 Addr profilePC;
170 EndQuiesceEvent *quiesceEvent;
171
172 TheISA::Kernel::Statistics *kernelStats;
173
174 protected:
175 Process *process;
176
177 /** A port proxy outgoing only for functional accesses to physical
178 * addresses.*/
179 PortProxy *physProxy;
180
181 /** A translating port proxy, outgoing only, for functional
182 * accesse to virtual addresses. */
183 FSTranslatingPortProxy *virtProxy;
184 SETranslatingPortProxy *proxy;
185
186 public:
187 /*
188 * number of executed instructions, for matching with syscall trace
189 * points in EIO files.
190 */
191 Counter funcExeInst;
192
193 //
194 // Count failed store conditionals so we can warn of apparent
195 // application deadlock situations.
196 unsigned storeCondFailures;
197};
198
199#endif // __CPU_THREAD_STATE_HH__
83
84 /**
85 * Initialise the physical and virtual port proxies and tie them to
86 * the data port of the CPU.
87 *
88 * @param tc ThreadContext for the virtual-to-physical translation
89 */
90 void initMemProxies(ThreadContext *tc);
91
92 void dumpFuncProfile();
93
94 EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
95
96 void profileClear();
97
98 void profileSample();
99
100 TheISA::Kernel::Statistics *getKernelStats() { return kernelStats; }
101
102 PortProxy &getPhysProxy();
103
104 FSTranslatingPortProxy &getVirtProxy();
105
106 Process *getProcessPtr() { return process; }
107
108 SETranslatingPortProxy &getMemProxy();
109
110 /** Reads the number of instructions functionally executed and
111 * committed.
112 */
113 Counter readFuncExeInst() { return funcExeInst; }
114
115 /** Sets the total number of instructions functionally executed
116 * and committed.
117 */
118 void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
119
120 /** Returns the status of this thread. */
121 Status status() const { return _status; }
122
123 /** Sets the status of this thread. */
124 void setStatus(Status new_status) { _status = new_status; }
125
126 public:
127
128 /** Number of instructions committed. */
129 Counter numInst;
130 /** Stat for number instructions committed. */
131 Stats::Scalar numInsts;
132 /** Number of ops (including micro ops) committed. */
133 Counter numOp;
134 /** Stat for number ops (including micro ops) committed. */
135 Stats::Scalar numOps;
136 /** Stat for number of memory references. */
137 Stats::Scalar numMemRefs;
138
139 /** Number of simulated loads, used for tracking events based on
140 * the number of loads committed.
141 */
142 Counter numLoad;
143
144 /** The number of simulated loads committed prior to this run. */
145 Counter startNumLoad;
146
147 protected:
148 ThreadContext::Status _status;
149
150 // Pointer to the base CPU.
151 BaseCPU *baseCpu;
152
153 // system wide HW context id
154 int _contextId;
155
156 // Index of hardware thread context on the CPU that this represents.
157 ThreadID _threadId;
158
159 public:
160 /** Last time activate was called on this thread. */
161 Tick lastActivate;
162
163 /** Last time suspend was called on this thread. */
164 Tick lastSuspend;
165
166 public:
167 FunctionProfile *profile;
168 ProfileNode *profileNode;
169 Addr profilePC;
170 EndQuiesceEvent *quiesceEvent;
171
172 TheISA::Kernel::Statistics *kernelStats;
173
174 protected:
175 Process *process;
176
177 /** A port proxy outgoing only for functional accesses to physical
178 * addresses.*/
179 PortProxy *physProxy;
180
181 /** A translating port proxy, outgoing only, for functional
182 * accesse to virtual addresses. */
183 FSTranslatingPortProxy *virtProxy;
184 SETranslatingPortProxy *proxy;
185
186 public:
187 /*
188 * number of executed instructions, for matching with syscall trace
189 * points in EIO files.
190 */
191 Counter funcExeInst;
192
193 //
194 // Count failed store conditionals so we can warn of apparent
195 // application deadlock situations.
196 unsigned storeCondFailures;
197};
198
199#endif // __CPU_THREAD_STATE_HH__