simple_thread.cc (8777:dd43f1c9fa0a) | simple_thread.cc (8793:5f25086326ac) |
---|---|
1/* 2 * Copyright (c) 2001-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; --- 36 unchanged lines hidden (view full) --- 45#include "cpu/base.hh" 46#include "cpu/profile.hh" 47#include "cpu/quiesce_event.hh" 48#include "cpu/simple_thread.hh" 49#include "cpu/thread_context.hh" 50#include "mem/translating_port.hh" 51#include "mem/vport.hh" 52#include "params/BaseCPU.hh" | 1/* 2 * Copyright (c) 2001-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; --- 36 unchanged lines hidden (view full) --- 45#include "cpu/base.hh" 46#include "cpu/profile.hh" 47#include "cpu/quiesce_event.hh" 48#include "cpu/simple_thread.hh" 49#include "cpu/thread_context.hh" 50#include "mem/translating_port.hh" 51#include "mem/vport.hh" 52#include "params/BaseCPU.hh" |
53#include "sim/full_system.hh" |
|
53#include "sim/process.hh" 54#include "sim/serialize.hh" 55#include "sim/sim_exit.hh" 56#include "sim/system.hh" 57 58using namespace std; 59 60// constructor | 54#include "sim/process.hh" 55#include "sim/serialize.hh" 56#include "sim/sim_exit.hh" 57#include "sim/system.hh" 58 59using namespace std; 60 61// constructor |
61#if !FULL_SYSTEM | |
62SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, 63 TheISA::TLB *_itb, TheISA::TLB *_dtb) 64 : ThreadState(_cpu, _thread_num, _process), 65 cpu(_cpu), itb(_itb), dtb(_dtb) 66{ 67 clearArchRegs(); 68 tc = new ProxyThreadContext<SimpleThread>(this); 69} | 62SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, 63 TheISA::TLB *_itb, TheISA::TLB *_dtb) 64 : ThreadState(_cpu, _thread_num, _process), 65 cpu(_cpu), itb(_itb), dtb(_dtb) 66{ 67 clearArchRegs(); 68 tc = new ProxyThreadContext<SimpleThread>(this); 69} |
70#else | |
71SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys, 72 TheISA::TLB *_itb, TheISA::TLB *_dtb, 73 bool use_kernel_stats) 74 : ThreadState(_cpu, _thread_num, NULL), 75 cpu(_cpu), system(_sys), itb(_itb), dtb(_dtb) 76 77{ 78 tc = new ProxyThreadContext<SimpleThread>(this); --- 14 unchanged lines hidden (view full) --- 93 // on the first cycle when there's no node available. 94 static ProfileNode dummyNode; 95 profileNode = &dummyNode; 96 profilePC = 3; 97 98 if (use_kernel_stats) 99 kernelStats = new TheISA::Kernel::Statistics(system); 100} | 70SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys, 71 TheISA::TLB *_itb, TheISA::TLB *_dtb, 72 bool use_kernel_stats) 73 : ThreadState(_cpu, _thread_num, NULL), 74 cpu(_cpu), system(_sys), itb(_itb), dtb(_dtb) 75 76{ 77 tc = new ProxyThreadContext<SimpleThread>(this); --- 14 unchanged lines hidden (view full) --- 92 // on the first cycle when there's no node available. 93 static ProfileNode dummyNode; 94 profileNode = &dummyNode; 95 profilePC = 3; 96 97 if (use_kernel_stats) 98 kernelStats = new TheISA::Kernel::Statistics(system); 99} |
101#endif | |
102 103SimpleThread::SimpleThread() 104 : ThreadState(NULL, -1, NULL) 105{ 106 tc = new ProxyThreadContext<SimpleThread>(this); 107} 108 109SimpleThread::~SimpleThread() 110{ 111 delete physPort; 112 delete virtPort; 113 delete tc; 114} 115 116void 117SimpleThread::takeOverFrom(ThreadContext *oldContext) 118{ 119 // some things should already be set up | 100 101SimpleThread::SimpleThread() 102 : ThreadState(NULL, -1, NULL) 103{ 104 tc = new ProxyThreadContext<SimpleThread>(this); 105} 106 107SimpleThread::~SimpleThread() 108{ 109 delete physPort; 110 delete virtPort; 111 delete tc; 112} 113 114void 115SimpleThread::takeOverFrom(ThreadContext *oldContext) 116{ 117 // some things should already be set up |
120#if FULL_SYSTEM 121 assert(system == oldContext->getSystemPtr()); 122#endif | 118 if (FullSystem) 119 assert(system == oldContext->getSystemPtr()); |
123 assert(process == oldContext->getProcessPtr()); 124 125 copyState(oldContext); | 120 assert(process == oldContext->getProcessPtr()); 121 122 copyState(oldContext); |
126#if FULL_SYSTEM 127 EndQuiesceEvent *quiesce = oldContext->getQuiesceEvent(); 128 if (quiesce) { 129 // Point the quiesce event's TC at this TC so that it wakes up 130 // the proper CPU. 131 quiesce->tc = tc; 132 } 133 if (quiesceEvent) { 134 quiesceEvent->tc = tc; 135 } | 123 if (FullSystem) { 124 EndQuiesceEvent *quiesce = oldContext->getQuiesceEvent(); 125 if (quiesce) { 126 // Point the quiesce event's TC at this TC so that it wakes up 127 // the proper CPU. 128 quiesce->tc = tc; 129 } 130 if (quiesceEvent) { 131 quiesceEvent->tc = tc; 132 } |
136 | 133 |
137 TheISA::Kernel::Statistics *stats = oldContext->getKernelStats(); 138 if (stats) { 139 kernelStats = stats; | 134 TheISA::Kernel::Statistics *stats = oldContext->getKernelStats(); 135 if (stats) { 136 kernelStats = stats; 137 } |
140 } | 138 } |
141#endif | |
142 143 storeCondFailures = 0; 144 145 oldContext->setStatus(ThreadContext::Halted); 146} 147 148void 149SimpleThread::copyTC(ThreadContext *context) 150{ 151 copyState(context); 152 | 139 140 storeCondFailures = 0; 141 142 oldContext->setStatus(ThreadContext::Halted); 143} 144 145void 146SimpleThread::copyTC(ThreadContext *context) 147{ 148 copyState(context); 149 |
153#if FULL_SYSTEM 154 EndQuiesceEvent *quiesce = context->getQuiesceEvent(); 155 if (quiesce) { 156 quiesceEvent = quiesce; | 150 if (FullSystem) { 151 EndQuiesceEvent *quiesce = context->getQuiesceEvent(); 152 if (quiesce) { 153 quiesceEvent = quiesce; 154 } 155 TheISA::Kernel::Statistics *stats = context->getKernelStats(); 156 if (stats) { 157 kernelStats = stats; 158 } |
157 } | 159 } |
158 TheISA::Kernel::Statistics *stats = context->getKernelStats(); 159 if (stats) { 160 kernelStats = stats; 161 } 162#endif | |
163} 164 165void 166SimpleThread::copyState(ThreadContext *oldContext) 167{ 168 // copy over functional state 169 _status = oldContext->status(); 170 copyArchRegs(oldContext); | 160} 161 162void 163SimpleThread::copyState(ThreadContext *oldContext) 164{ 165 // copy over functional state 166 _status = oldContext->status(); 167 copyArchRegs(oldContext); |
171#if !FULL_SYSTEM 172 funcExeInst = oldContext->readFuncExeInst(); 173#endif | 168 if (FullSystem) 169 funcExeInst = oldContext->readFuncExeInst(); |
174 175 _threadId = oldContext->threadId(); 176 _contextId = oldContext->contextId(); 177} 178 179void 180SimpleThread::serialize(ostream &os) 181{ --- 54 unchanged lines hidden (view full) --- 236void 237SimpleThread::suspend() 238{ 239 if (status() == ThreadContext::Suspended) 240 return; 241 242 lastActivate = curTick(); 243 lastSuspend = curTick(); | 170 171 _threadId = oldContext->threadId(); 172 _contextId = oldContext->contextId(); 173} 174 175void 176SimpleThread::serialize(ostream &os) 177{ --- 54 unchanged lines hidden (view full) --- 232void 233SimpleThread::suspend() 234{ 235 if (status() == ThreadContext::Suspended) 236 return; 237 238 lastActivate = curTick(); 239 lastSuspend = curTick(); |
244/* 245#if FULL_SYSTEM 246 // Don't change the status from active if there are pending interrupts 247 if (cpu->checkInterrupts()) { 248 assert(status() == ThreadContext::Active); 249 return; 250 } 251#endif 252*/ | |
253 _status = ThreadContext::Suspended; 254 cpu->suspendContext(_threadId); 255} 256 257 258void 259SimpleThread::halt() 260{ 261 if (status() == ThreadContext::Halted) 262 return; 263 264 _status = ThreadContext::Halted; 265 cpu->haltContext(_threadId); 266} 267 268 269void 270SimpleThread::regStats(const string &name) 271{ | 240 _status = ThreadContext::Suspended; 241 cpu->suspendContext(_threadId); 242} 243 244 245void 246SimpleThread::halt() 247{ 248 if (status() == ThreadContext::Halted) 249 return; 250 251 _status = ThreadContext::Halted; 252 cpu->haltContext(_threadId); 253} 254 255 256void 257SimpleThread::regStats(const string &name) 258{ |
272#if FULL_SYSTEM 273 if (kernelStats) | 259 if (FullSystem && kernelStats) |
274 kernelStats->regStats(name + ".kern"); | 260 kernelStats->regStats(name + ".kern"); |
275#endif | |
276} 277 278void 279SimpleThread::copyArchRegs(ThreadContext *src_tc) 280{ 281 TheISA::copyRegs(src_tc, tc); 282} 283 | 261} 262 263void 264SimpleThread::copyArchRegs(ThreadContext *src_tc) 265{ 266 TheISA::copyRegs(src_tc, tc); 267} 268 |