simple_thread.cc (8706:b1838faf3bcc) | simple_thread.cc (8735:dd20a8139788) |
---|---|
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; --- 53 unchanged lines hidden (view full) --- 62using namespace std; 63 64// constructor 65#if FULL_SYSTEM 66SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys, 67 TheISA::TLB *_itb, TheISA::TLB *_dtb, 68 bool use_kernel_stats) 69 : ThreadState(_cpu, _thread_num), | 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; --- 53 unchanged lines hidden (view full) --- 62using namespace std; 63 64// constructor 65#if FULL_SYSTEM 66SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys, 67 TheISA::TLB *_itb, TheISA::TLB *_dtb, 68 bool use_kernel_stats) 69 : ThreadState(_cpu, _thread_num), |
70 cpu(_cpu), system(_sys), itb(_itb), dtb(_dtb) | 70 system(_sys), itb(_itb), dtb(_dtb) |
71 72{ 73 tc = new ProxyThreadContext<SimpleThread>(this); 74 75 quiesceEvent = new EndQuiesceEvent(tc); 76 77 clearArchRegs(); 78 | 71 72{ 73 tc = new ProxyThreadContext<SimpleThread>(this); 74 75 quiesceEvent = new EndQuiesceEvent(tc); 76 77 clearArchRegs(); 78 |
79 if (cpu->params()->profile) { | 79 if (baseCpu->params()->profile) { |
80 profile = new FunctionProfile(system->kernelSymtab); 81 Callback *cb = 82 new MakeCallback<SimpleThread, 83 &SimpleThread::dumpFuncProfile>(this); 84 registerExitCallback(cb); 85 } 86 87 // let's fill with a dummy node for now so we don't get a segfault --- 4 unchanged lines hidden (view full) --- 92 93 if (use_kernel_stats) 94 kernelStats = new TheISA::Kernel::Statistics(system); 95} 96#else 97SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, 98 TheISA::TLB *_itb, TheISA::TLB *_dtb) 99 : ThreadState(_cpu, _thread_num, _process), | 80 profile = new FunctionProfile(system->kernelSymtab); 81 Callback *cb = 82 new MakeCallback<SimpleThread, 83 &SimpleThread::dumpFuncProfile>(this); 84 registerExitCallback(cb); 85 } 86 87 // let's fill with a dummy node for now so we don't get a segfault --- 4 unchanged lines hidden (view full) --- 92 93 if (use_kernel_stats) 94 kernelStats = new TheISA::Kernel::Statistics(system); 95} 96#else 97SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, 98 TheISA::TLB *_itb, TheISA::TLB *_dtb) 99 : ThreadState(_cpu, _thread_num, _process), |
100 cpu(_cpu), itb(_itb), dtb(_dtb) | 100 itb(_itb), dtb(_dtb) |
101{ 102 clearArchRegs(); 103 tc = new ProxyThreadContext<SimpleThread>(this); 104} 105 106#endif 107 108SimpleThread::SimpleThread() --- 82 unchanged lines hidden (view full) --- 191 SERIALIZE_ARRAY(floatRegs.i, TheISA::NumFloatRegs); 192 SERIALIZE_ARRAY(intRegs, TheISA::NumIntRegs); 193 _pcState.serialize(os); 194 // thread_num and cpu_id are deterministic from the config 195 196 // 197 // Now must serialize all the ISA dependent state 198 // | 101{ 102 clearArchRegs(); 103 tc = new ProxyThreadContext<SimpleThread>(this); 104} 105 106#endif 107 108SimpleThread::SimpleThread() --- 82 unchanged lines hidden (view full) --- 191 SERIALIZE_ARRAY(floatRegs.i, TheISA::NumFloatRegs); 192 SERIALIZE_ARRAY(intRegs, TheISA::NumIntRegs); 193 _pcState.serialize(os); 194 // thread_num and cpu_id are deterministic from the config 195 196 // 197 // Now must serialize all the ISA dependent state 198 // |
199 isa.serialize(cpu, os); | 199 isa.serialize(baseCpu, os); |
200} 201 202 203void 204SimpleThread::unserialize(Checkpoint *cp, const std::string §ion) 205{ 206 ThreadState::unserialize(cp, section); 207 UNSERIALIZE_ARRAY(floatRegs.i, TheISA::NumFloatRegs); 208 UNSERIALIZE_ARRAY(intRegs, TheISA::NumIntRegs); 209 _pcState.unserialize(cp, section); 210 // thread_num and cpu_id are deterministic from the config 211 212 // 213 // Now must unserialize all the ISA dependent state 214 // | 200} 201 202 203void 204SimpleThread::unserialize(Checkpoint *cp, const std::string §ion) 205{ 206 ThreadState::unserialize(cp, section); 207 UNSERIALIZE_ARRAY(floatRegs.i, TheISA::NumFloatRegs); 208 UNSERIALIZE_ARRAY(intRegs, TheISA::NumIntRegs); 209 _pcState.unserialize(cp, section); 210 // thread_num and cpu_id are deterministic from the config 211 212 // 213 // Now must unserialize all the ISA dependent state 214 // |
215 isa.unserialize(cpu, cp, section); | 215 isa.unserialize(baseCpu, cp, section); |
216} 217 218#if FULL_SYSTEM 219void 220SimpleThread::dumpFuncProfile() 221{ | 216} 217 218#if FULL_SYSTEM 219void 220SimpleThread::dumpFuncProfile() 221{ |
222 std::ostream *os = simout.create(csprintf("profile.%s.dat", cpu->name())); | 222 std::ostream *os = simout.create(csprintf("profile.%s.dat", 223 baseCpu->name())); |
223 profile->dump(tc, *os); 224} 225#endif 226 227void 228SimpleThread::activate(int delay) 229{ 230 if (status() == ThreadContext::Active) --- 4 unchanged lines hidden (view full) --- 235// if (status() == ThreadContext::Unallocated) { 236// cpu->activateWhenReady(_threadId); 237// return; 238// } 239 240 _status = ThreadContext::Active; 241 242 // status() == Suspended | 224 profile->dump(tc, *os); 225} 226#endif 227 228void 229SimpleThread::activate(int delay) 230{ 231 if (status() == ThreadContext::Active) --- 4 unchanged lines hidden (view full) --- 236// if (status() == ThreadContext::Unallocated) { 237// cpu->activateWhenReady(_threadId); 238// return; 239// } 240 241 _status = ThreadContext::Active; 242 243 // status() == Suspended |
243 cpu->activateContext(_threadId, delay); | 244 baseCpu->activateContext(_threadId, delay); |
244} 245 246void 247SimpleThread::suspend() 248{ 249 if (status() == ThreadContext::Suspended) 250 return; 251 --- 4 unchanged lines hidden (view full) --- 256 // Don't change the status from active if there are pending interrupts 257 if (cpu->checkInterrupts()) { 258 assert(status() == ThreadContext::Active); 259 return; 260 } 261#endif 262*/ 263 _status = ThreadContext::Suspended; | 245} 246 247void 248SimpleThread::suspend() 249{ 250 if (status() == ThreadContext::Suspended) 251 return; 252 --- 4 unchanged lines hidden (view full) --- 257 // Don't change the status from active if there are pending interrupts 258 if (cpu->checkInterrupts()) { 259 assert(status() == ThreadContext::Active); 260 return; 261 } 262#endif 263*/ 264 _status = ThreadContext::Suspended; |
264 cpu->suspendContext(_threadId); | 265 baseCpu->suspendContext(_threadId); |
265} 266 267 268void 269SimpleThread::halt() 270{ 271 if (status() == ThreadContext::Halted) 272 return; 273 274 _status = ThreadContext::Halted; | 266} 267 268 269void 270SimpleThread::halt() 271{ 272 if (status() == ThreadContext::Halted) 273 return; 274 275 _status = ThreadContext::Halted; |
275 cpu->haltContext(_threadId); | 276 baseCpu->haltContext(_threadId); |
276} 277 278 279void 280SimpleThread::regStats(const string &name) 281{ 282#if FULL_SYSTEM 283 if (kernelStats) 284 kernelStats->regStats(name + ".kern"); 285#endif 286} 287 288void 289SimpleThread::copyArchRegs(ThreadContext *src_tc) 290{ 291 TheISA::copyRegs(src_tc, tc); 292} 293 | 277} 278 279 280void 281SimpleThread::regStats(const string &name) 282{ 283#if FULL_SYSTEM 284 if (kernelStats) 285 kernelStats->regStats(name + ".kern"); 286#endif 287} 288 289void 290SimpleThread::copyArchRegs(ThreadContext *src_tc) 291{ 292 TheISA::copyRegs(src_tc, tc); 293} 294 |