gem5  v19.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  * 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 "sim/process.hh"
40 
41 class EndQuiesceEvent;
42 class FunctionProfile;
43 class ProfileNode;
44 namespace Kernel {
45  class Statistics;
46 }
47 
48 class Checkpoint;
49 
52 
59 struct ThreadState : public Serializable {
61 
62  ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
63 
64  virtual ~ThreadState();
65 
66  void serialize(CheckpointOut &cp) const override;
67 
68  void unserialize(CheckpointIn &cp) override;
69 
70  int cpuId() const { return baseCpu->cpuId(); }
71 
72  uint32_t socketId() const { return baseCpu->socketId(); }
73 
74  ContextID contextId() const { return _contextId; }
75 
76  void setContextId(ContextID id) { _contextId = id; }
77 
78  void setThreadId(ThreadID id) { _threadId = id; }
79 
80  ThreadID threadId() const { return _threadId; }
81 
82  Tick readLastActivate() const { return lastActivate; }
83 
84  Tick readLastSuspend() const { return lastSuspend; }
85 
92  void initMemProxies(ThreadContext *tc);
93 
94  void dumpFuncProfile();
95 
96  EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
97 
98  void profileClear();
99 
100  void profileSample();
101 
102  Kernel::Statistics *getKernelStats() { return kernelStats; }
103 
104  PortProxy &getPhysProxy();
105 
106  PortProxy &getVirtProxy();
107 
108  Process *getProcessPtr() { return process; }
109 
111  {
112  process = p;
118  if (virtProxy) {
119  delete virtProxy;
120  virtProxy = NULL;
121  initMemProxies(NULL);
122  }
123  }
124 
128  Counter readFuncExeInst() const { return funcExeInst; }
129 
133  void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
134 
136  Status status() const { return _status; }
137 
139  void setStatus(Status new_status) { _status = new_status; }
140 
141  public:
142 
153 
158 
161 
162  protected:
164 
165  // Pointer to the base CPU.
167 
168  // system wide HW context id
170 
171  // Index of hardware thread context on the CPU that this represents.
173 
174  public:
177 
180 
181  public:
186 
188 
189  protected:
191 
195 
199 
200  public:
201  /*
202  * number of executed instructions, for matching with syscall trace
203  * points in EIO files.
204  */
206 
207  //
208  // Count failed store conditionals so we can warn of apparent
209  // application deadlock situations.
211 };
212 
213 #endif // __CPU_THREAD_STATE_HH__
A TranslatingPortProxy in FS mode translates a virtual address to a physical address and then calls t...
void setContextId(ContextID id)
Definition: thread_state.hh:76
Tick readLastActivate() const
Definition: thread_state.hh:82
Struct for holding general thread state that is needed across CPU models.
Definition: thread_state.hh:59
Tick readLastSuspend() const
Definition: thread_state.hh:84
ProfileNode * profileNode
EndQuiesceEvent * getQuiesceEvent()
Definition: thread_state.hh:96
FunctionProfile * profile
Tick lastActivate
Last time activate was called on this thread.
uint32_t socketId() const
Definition: thread_state.hh:72
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:78
Definition: cprintf.cc:42
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:2508
EndQuiesceEvent * quiesceEvent
Bitfield< 33 > id
Counter numInst
Number of instructions committed.
ThreadContext::Status Status
Definition: thread_state.hh:60
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:74
void setProcessPtr(Process *p)
uint64_t Tick
Tick count type.
Definition: types.hh:63
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()
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:80
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
int64_t Counter
Statistics counter type.
Definition: types.hh:58
Basic support for object serialization.
Definition: serialize.hh:153
ThreadContext::Status _status
This object is a proxy for a port or other object which implements the functional response protocol...
Definition: port_proxy.hh:82
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Process * getProcessPtr()
std::ostream CheckpointOut
Definition: serialize.hh:68
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:70
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:231
Counter numOp
Number of ops (including micro ops) committed.
ThreadID _threadId

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13