gem5  v20.1.0.0
thread_state.hh
Go to the documentation of this file.
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 
29 #ifndef __CPU_THREAD_STATE_HH__
30 #define __CPU_THREAD_STATE_HH__
31 
32 #include "arch/types.hh"
33 #include "config/the_isa.hh"
34 #include "cpu/base.hh"
35 #include "cpu/thread_context.hh"
36 #include "sim/process.hh"
37 
38 class Checkpoint;
39 
46 struct ThreadState : public Serializable {
48 
49  ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
50 
51  virtual ~ThreadState();
52 
53  void serialize(CheckpointOut &cp) const override;
54 
55  void unserialize(CheckpointIn &cp) override;
56 
57  int cpuId() const { return baseCpu->cpuId(); }
58 
59  uint32_t socketId() const { return baseCpu->socketId(); }
60 
61  ContextID contextId() const { return _contextId; }
62 
64 
65  void setThreadId(ThreadID id) { _threadId = id; }
66 
67  ThreadID threadId() const { return _threadId; }
68 
69  Tick readLastActivate() const { return lastActivate; }
70 
71  Tick readLastSuspend() const { return lastSuspend; }
72 
79  void initMemProxies(ThreadContext *tc);
80 
82 
84 
85  Process *getProcessPtr() { return process; }
86 
88 
92  Counter readFuncExeInst() const { return funcExeInst; }
93 
97  void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
98 
100  Status status() const { return _status; }
101 
103  void setStatus(Status new_status) { _status = new_status; }
104 
105  public:
106 
111  // Defining the stat group
113  {
114  ThreadStateStats(BaseCPU *cpu, ThreadState *thread);
121  } threadStats;
122 
127 
130 
131  protected:
133 
134  // Pointer to the base CPU.
136 
137  // system wide HW context id
139 
140  // Index of hardware thread context on the CPU that this represents.
142 
143  public:
146 
149 
150  protected:
152 
156 
160 
161  public:
162  /*
163  * number of executed instructions, for matching with syscall trace
164  * points in EIO files.
165  */
167 
168  //
169  // Count failed store conditionals so we can warn of apparent
170  // application deadlock situations.
172 };
173 
174 #endif // __CPU_THREAD_STATE_HH__
ThreadState::ThreadStateStats::numInsts
Stats::Scalar numInsts
Stat for number instructions committed.
Definition: thread_state.hh:116
ThreadState::setProcessPtr
void setProcessPtr(Process *p)
Definition: thread_state.hh:87
ThreadState::funcExeInst
Counter funcExeInst
Definition: thread_state.hh:166
ThreadState::getProcessPtr
Process * getProcessPtr()
Definition: thread_state.hh:85
Process
Definition: process.hh:65
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
ThreadState::lastActivate
Tick lastActivate
Last time activate was called on this thread.
Definition: thread_state.hh:145
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
ThreadState::virtProxy
PortProxy * virtProxy
A translating port proxy, outgoing only, for functional accesse to virtual addresses.
Definition: thread_state.hh:159
ThreadState::_threadId
ThreadID _threadId
Definition: thread_state.hh:141
ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:231
ThreadState::socketId
uint32_t socketId() const
Definition: thread_state.hh:59
ThreadState::ThreadStateStats
Definition: thread_state.hh:112
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
ThreadState::setStatus
void setStatus(Status new_status)
Sets the status of this thread.
Definition: thread_state.hh:103
ThreadState::setThreadId
void setThreadId(ThreadID id)
Definition: thread_state.hh:65
BaseCPU::socketId
uint32_t socketId() const
Reads this CPU's Socket ID.
Definition: base.hh:181
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
ThreadState
Struct for holding general thread state that is needed across CPU models.
Definition: thread_state.hh:46
ThreadState::_status
ThreadContext::Status _status
Definition: thread_state.hh:132
Counter
int64_t Counter
Statistics counter type.
Definition: types.hh:58
cp
Definition: cprintf.cc:40
ThreadState::numLoad
Counter numLoad
Number of simulated loads, used for tracking events based on the number of loads committed.
Definition: thread_state.hh:126
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ThreadState::numOp
Counter numOp
Number of ops (including micro ops) committed.
Definition: thread_state.hh:110
ThreadState::lastSuspend
Tick lastSuspend
Last time suspend was called on this thread.
Definition: thread_state.hh:148
ThreadState::getPhysProxy
PortProxy & getPhysProxy()
Definition: thread_state.cc:107
ThreadState::numInst
Counter numInst
Number of instructions committed.
Definition: thread_state.hh:108
process.hh
ThreadState::setFuncExeInst
void setFuncExeInst(Counter new_val)
Sets the total number of instructions functionally executed and committed.
Definition: thread_state.hh:97
ThreadState::physProxy
PortProxy * physProxy
A port proxy outgoing only for functional accesses to physical addresses.
Definition: thread_state.hh:155
ThreadState::process
Process * process
Definition: thread_state.hh:151
ThreadState::setContextId
void setContextId(ContextID id)
Definition: thread_state.hh:63
ThreadState::ThreadState
ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
Definition: thread_state.cc:41
ThreadContext::Status
Status
Definition: thread_context.hh:98
ThreadState::baseCpu
BaseCPU * baseCpu
Definition: thread_state.hh:135
ThreadState::ThreadStateStats::numOps
Stats::Scalar numOps
Stat for number ops (including micro ops) committed.
Definition: thread_state.hh:118
BaseCPU
Definition: cpu_dummy.hh:43
ThreadState::status
Status status() const
Returns the status of this thread.
Definition: thread_state.hh:100
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
ThreadState::ThreadStateStats::numMemRefs
Stats::Scalar numMemRefs
Stat for number of memory references.
Definition: thread_state.hh:120
ThreadState::initMemProxies
void initMemProxies(ThreadContext *tc)
Initialise the physical and virtual port proxies and tie them to the data port of the CPU.
Definition: thread_state.cc:83
base.hh
ThreadState::~ThreadState
virtual ~ThreadState()
Definition: thread_state.cc:51
ThreadState::getVirtProxy
PortProxy & getVirtProxy()
Definition: thread_state.cc:115
ThreadState::storeCondFailures
unsigned storeCondFailures
Definition: thread_state.hh:171
Stats::Group
Statistics container.
Definition: group.hh:83
ThreadState::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: thread_state.cc:71
ThreadState::readLastSuspend
Tick readLastSuspend() const
Definition: thread_state.hh:71
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
ThreadState::_contextId
ContextID _contextId
Definition: thread_state.hh:138
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ThreadState::threadId
ThreadID threadId() const
Definition: thread_state.hh:67
ThreadState::ThreadStateStats::ThreadStateStats
ThreadStateStats(BaseCPU *cpu, ThreadState *thread)
Definition: thread_state.cc:121
CheckpointIn
Definition: serialize.hh:67
ThreadState::readLastActivate
Tick readLastActivate() const
Definition: thread_state.hh:69
thread_context.hh
ThreadState::threadStats
ThreadState::ThreadStateStats threadStats
ThreadState::contextId
ContextID contextId() const
Definition: thread_state.hh:61
BaseCPU::cpuId
int cpuId() const
Reads this CPU's ID.
Definition: base.hh:178
ArmISA::id
Bitfield< 33 > id
Definition: miscregs_types.hh:247
ThreadState::Status
ThreadContext::Status Status
Definition: thread_state.hh:47
ThreadState::cpuId
int cpuId() const
Definition: thread_state.hh:57
ThreadState::startNumLoad
Counter startNumLoad
The number of simulated loads committed prior to this run.
Definition: thread_state.hh:129
ThreadState::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: thread_state.cc:60
ThreadState::readFuncExeInst
Counter readFuncExeInst() const
Reads the number of instructions functionally executed and committed.
Definition: thread_state.hh:92

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17