gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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/profile.hh"
36 #include "cpu/thread_context.hh"
37 #include "sim/process.hh"
38 
39 class EndQuiesceEvent;
40 class FunctionProfile;
41 class ProfileNode;
42 namespace Kernel {
43  class Statistics;
44 }
45 
46 class Checkpoint;
47 
54 struct ThreadState : public Serializable {
56 
57  ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
58 
59  virtual ~ThreadState();
60 
61  void serialize(CheckpointOut &cp) const override;
62 
63  void unserialize(CheckpointIn &cp) override;
64 
65  int cpuId() const { return baseCpu->cpuId(); }
66 
67  uint32_t socketId() const { return baseCpu->socketId(); }
68 
69  ContextID contextId() const { return _contextId; }
70 
71  void setContextId(ContextID id) { _contextId = id; }
72 
73  void setThreadId(ThreadID id) { _threadId = id; }
74 
75  ThreadID threadId() const { return _threadId; }
76 
77  Tick readLastActivate() const { return lastActivate; }
78 
79  Tick readLastSuspend() const { return lastSuspend; }
80 
87  void initMemProxies(ThreadContext *tc);
88 
89  void dumpFuncProfile();
90 
91  EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
92 
93  void profileClear();
94 
95  void profileSample();
96 
97  Kernel::Statistics *getKernelStats() { return kernelStats; }
98 
99  PortProxy &getPhysProxy();
100 
101  PortProxy &getVirtProxy();
102 
103  Process *getProcessPtr() { return process; }
104 
105  void setProcessPtr(Process *p) { process = p; }
106 
110  Counter readFuncExeInst() const { return funcExeInst; }
111 
115  void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
116 
118  Status status() const { return _status; }
119 
121  void setStatus(Status new_status) { _status = new_status; }
122 
123  public:
124 
135 
140 
143 
144  protected:
146 
147  // Pointer to the base CPU.
149 
150  // system wide HW context id
152 
153  // Index of hardware thread context on the CPU that this represents.
155 
156  public:
159 
162 
163  public:
168 
170 
171  protected:
173 
177 
181 
182  public:
183  /*
184  * number of executed instructions, for matching with syscall trace
185  * points in EIO files.
186  */
188 
189  //
190  // Count failed store conditionals so we can warn of apparent
191  // application deadlock situations.
193 };
194 
195 #endif // __CPU_THREAD_STATE_HH__
void setContextId(ContextID id)
Definition: thread_state.hh:71
Tick readLastActivate() const
Definition: thread_state.hh:77
Struct for holding general thread state that is needed across CPU models.
Definition: thread_state.hh:54
Tick readLastSuspend() const
Definition: thread_state.hh:79
ProfileNode * profileNode
EndQuiesceEvent * getQuiesceEvent()
Definition: thread_state.hh:91
FunctionProfile * profile
Tick lastActivate
Last time activate was called on this thread.
uint32_t socketId() const
Definition: thread_state.hh:67
Counter readFuncExeInst() const
Reads the number of instructions functionally executed and committed.
Tick lastSuspend
Last time suspend was called on this thread.
Counter funcExeInst
void setThreadId(ThreadID id)
Definition: thread_state.hh:73
Definition: cprintf.cc:40
Stats::Scalar numMemRefs
Stat for number of memory references.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Event for timing out quiesce instruction.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
EndQuiesceEvent * quiesceEvent
Bitfield< 33 > id
Counter numInst
Number of instructions committed.
ThreadContext::Status Status
Definition: thread_state.hh:55
void setStatus(Status new_status)
Sets the status of this thread.
Process * process
void setFuncExeInst(Counter new_val)
Sets the total number of instructions functionally executed and committed.
ContextID contextId() const
Definition: thread_state.hh:69
void setProcessPtr(Process *p)
uint64_t Tick
Tick count type.
Definition: types.hh:61
PortProxy * physProxy
A port proxy outgoing only for functional accesses to physical addresses.
Stats::Scalar numInsts
Stat for number instructions committed.
Kernel::Statistics * kernelStats
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Kernel::Statistics * getKernelStats()
Definition: thread_state.hh:97
Counter startNumLoad
The number of simulated loads committed prior to this run.
Stats::Scalar numOps
Stat for number ops (including micro ops) committed.
ThreadID threadId() const
Definition: thread_state.hh:75
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
int64_t Counter
Statistics counter type.
Definition: types.hh:56
Basic support for object serialization.
Definition: serialize.hh:166
ThreadContext::Status _status
This object is a proxy for a port or other object which implements the functional response protocol...
Definition: port_proxy.hh:80
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:225
Process * getProcessPtr()
std::ostream CheckpointOut
Definition: serialize.hh:63
BaseCPU * baseCpu
Counter numLoad
Number of simulated loads, used for tracking events based on the number of loads committed.
void unserialize(ThreadContext &tc, CheckpointIn &cp)
unsigned storeCondFailures
int cpuId() const
Definition: thread_state.hh:65
Bitfield< 0 > p
Status status() const
Returns the status of this thread.
ContextID _contextId
PortProxy * virtProxy
A translating port proxy, outgoing only, for functional accesse to virtual addresses.
int ContextID
Globally unique thread context ID.
Definition: types.hh:229
Counter numOp
Number of ops (including micro ops) committed.
ThreadID _threadId

Generated on Thu May 28 2020 16:21:31 for gem5 by doxygen 1.8.13