gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "mem/mem_object.hh"
40 #include "sim/process.hh"
41 
42 class EndQuiesceEvent;
43 class FunctionProfile;
44 class ProfileNode;
45 namespace TheISA {
46  namespace Kernel {
47  class Statistics;
48  }
49 }
50 
51 class Checkpoint;
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 
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 
97 
98  void profileClear();
99 
100  void profileSample();
101 
102  TheISA::Kernel::Statistics *getKernelStats() { return kernelStats; }
103 
105 
107 
109 
111  {
112  process = p;
118  if (proxy) {
119  delete proxy;
120  proxy = NULL;
121  initMemProxies(NULL);
122  }
123  }
124 
126 
131 
135  void setFuncExeInst(Counter new_val) { funcExeInst = new_val; }
136 
138  Status status() const { return _status; }
139 
141  void setStatus(Status new_status) { _status = new_status; }
142 
143  public:
144 
155 
160 
163 
164  protected:
166 
167  // Pointer to the base CPU.
169 
170  // system wide HW context id
172 
173  // Index of hardware thread context on the CPU that this represents.
175 
176  public:
179 
182 
183  public:
188 
189  TheISA::Kernel::Statistics *kernelStats;
190 
191  protected:
193 
197 
202 
203  public:
204  /*
205  * number of executed instructions, for matching with syscall trace
206  * points in EIO files.
207  */
209 
210  //
211  // Count failed store conditionals so we can warn of apparent
212  // application deadlock situations.
214 };
215 
216 #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
Struct for holding general thread state that is needed across CPU models.
Definition: thread_state.hh:59
ProfileNode * profileNode
EndQuiesceEvent * getQuiesceEvent()
Definition: thread_state.hh:96
FunctionProfile * profile
Tick lastActivate
Last time activate was called on this thread.
Tick readLastActivate() const
Definition: thread_state.hh:82
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: thread_state.cc:85
PortProxy & getPhysProxy()
Tick lastSuspend
Last time suspend was called on this thread.
void dumpFuncProfile()
MemObject declaration.
Counter funcExeInst
void profileClear()
ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
Definition: thread_state.cc:46
void setThreadId(ThreadID id)
Definition: thread_state.hh:78
Stats::Scalar numMemRefs
Stat for number of memory references.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Status status() const
Returns the status of this thread.
FSTranslatingPortProxy & getVirtProxy()
Tick readLastSuspend() const
Definition: thread_state.hh:84
Event for timing out quiesce instruction.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
EndQuiesceEvent * quiesceEvent
ThreadID threadId() const
Definition: thread_state.hh:80
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
uint32_t socketId() const
Definition: thread_state.hh:72
void setFuncExeInst(Counter new_val)
Sets the total number of instructions functionally executed and committed.
int cpuId() const
Definition: thread_state.hh:70
void setProcessPtr(Process *p)
virtual ~ThreadState()
Definition: thread_state.cc:56
uint64_t Tick
Tick count type.
Definition: types.hh:63
PortProxy * physProxy
A port proxy outgoing only for functional accesses to physical addresses.
FSTranslatingPortProxy * virtProxy
A translating port proxy, outgoing only, for functional accesse to virtual addresses.
Stats::Scalar numInsts
Stat for number instructions committed.
Counter startNumLoad
The number of simulated loads committed prior to this run.
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: thread_state.cc:67
Stats::Scalar numOps
Stat for number ops (including micro ops) committed.
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
TheISA::Kernel::Statistics * getKernelStats()
Basic support for object serialization.
Definition: serialize.hh:220
SETranslatingPortProxy * proxy
ThreadContext::Status _status
Counter readFuncExeInst()
Reads the number of instructions functionally executed and committed.
void initMemProxies(ThreadContext *tc)
Initialise the physical and virtual port proxies and tie them to the data port of the CPU...
This object is a proxy for a structural port, to be used for debug accesses.
Definition: port_proxy.hh:84
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
TheISA::Kernel::Statistics * kernelStats
Process * getProcessPtr()
std::ostream CheckpointOut
Definition: serialize.hh:67
SETranslatingPortProxy & getMemProxy()
BaseCPU * baseCpu
Counter numLoad
Number of simulated loads, used for tracking events based on the number of loads committed.
unsigned storeCondFailures
ContextID contextId() const
Definition: thread_state.hh:74
Bitfield< 11 > id
Definition: miscregs.hh:124
void profileSample()
Bitfield< 0 > p
ContextID _contextId
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
Counter numOp
Number of ops (including micro ops) committed.
ThreadID _threadId

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6