gem5  v22.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 "cpu/base.hh"
33 #include "cpu/thread_context.hh"
34 #include "sim/process.hh"
35 
36 namespace gem5
37 {
38 
39 class Checkpoint;
40 
47 struct ThreadState : public Serializable
48 {
50 
51  ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
52 
53  virtual ~ThreadState() = default;
54 
55  void serialize(CheckpointOut &cp) const override;
56 
57  void unserialize(CheckpointIn &cp) override;
58 
59  int cpuId() const { return baseCpu->cpuId(); }
60 
61  uint32_t socketId() const { return baseCpu->socketId(); }
62 
63  ContextID contextId() const { return _contextId; }
64 
66 
67  void setThreadId(ThreadID id) { _threadId = id; }
68 
69  ThreadID threadId() const { return _threadId; }
70 
71  Tick readLastActivate() const { return lastActivate; }
72 
73  Tick readLastSuspend() const { return lastSuspend; }
74 
75  Process *getProcessPtr() { return process; }
76 
78 
80  Status status() const { return _status; }
81 
83  void setStatus(Status new_status) { _status = new_status; }
84 
85  public:
86 
91  // Defining the stat group
93  {
94  ThreadStateStats(BaseCPU *cpu, const ThreadID& thread);
102 
107 
110 
111  protected:
113 
114  // Pointer to the base CPU.
116 
117  // system wide HW context id
119 
120  // Index of hardware thread context on the CPU that this represents.
122 
123  public:
126 
129 
130  protected:
132 
133  public:
134 
135  //
136  // Count failed store conditionals so we can warn of apparent
137  // application deadlock situations.
139 };
140 
141 } // namespace gem5
142 
143 #endif // __CPU_THREAD_STATE_HH__
uint32_t socketId() const
Reads this CPU's Socket ID.
Definition: base.hh:186
int cpuId() const
Reads this CPU's ID.
Definition: base.hh:183
Basic support for object serialization.
Definition: serialize.hh:170
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
Bitfield< 33 > id
Definition: misc_types.hh:257
Bitfield< 54 > p
Definition: pagetable.hh:70
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Tick
Tick count type.
Definition: types.hh:58
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
statistics::Scalar numOps
Stat for number ops (including micro ops) committed.
Definition: thread_state.hh:98
statistics::Scalar numMemRefs
Stat for number of memory references.
ThreadStateStats(BaseCPU *cpu, const ThreadID &thread)
Definition: thread_state.cc:65
statistics::Scalar numInsts
Stat for number instructions committed.
Definition: thread_state.hh:96
Struct for holding general thread state that is needed across CPU models.
Definition: thread_state.hh:48
ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
Definition: thread_state.cc:44
Counter numInst
Number of instructions committed.
Definition: thread_state.hh:88
ThreadID threadId() const
Definition: thread_state.hh:69
int cpuId() const
Definition: thread_state.hh:59
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: thread_state.cc:54
void setStatus(Status new_status)
Sets the status of this thread.
Definition: thread_state.hh:83
Tick readLastActivate() const
Definition: thread_state.hh:71
ContextID _contextId
ThreadContext::Status Status
Definition: thread_state.hh:49
Process * getProcessPtr()
Definition: thread_state.hh:75
unsigned storeCondFailures
Counter startNumLoad
The number of simulated loads committed prior to this run.
Tick readLastSuspend() const
Definition: thread_state.hh:73
void setProcessPtr(Process *p)
Definition: thread_state.hh:77
Counter numLoad
Number of simulated loads, used for tracking events based on the number of loads committed.
Counter numOp
Number of ops (including micro ops) committed.
Definition: thread_state.hh:90
gem5::ThreadState::ThreadStateStats threadStats
uint32_t socketId() const
Definition: thread_state.hh:61
ContextID contextId() const
Definition: thread_state.hh:63
ThreadContext::Status _status
void setContextId(ContextID id)
Definition: thread_state.hh:65
Tick lastSuspend
Last time suspend was called on this thread.
Tick lastActivate
Last time activate was called on this thread.
virtual ~ThreadState()=default
Status status() const
Returns the status of this thread.
Definition: thread_state.hh:80
void setThreadId(ThreadID id)
Definition: thread_state.hh:67
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: thread_state.cc:60

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1