Move quiesce event to its own class.

SConscript:
    Move quiesce event to its own file/class.

--HG--
extra : convert_revision : 6aa7863adb529fc03142666213c3ec348825bd3b
This commit is contained in:
Kevin Lim 2006-04-22 18:11:54 -04:00
parent bd38b56774
commit de8baeb58a
5 changed files with 62 additions and 39 deletions

View file

@ -85,6 +85,7 @@ base_sources = Split('''
cpu/cpu_exec_context.cc cpu/cpu_exec_context.cc
cpu/exetrace.cc cpu/exetrace.cc
cpu/pc_event.cc cpu/pc_event.cc
cpu/quiesce_event.cc
cpu/static_inst.cc cpu/static_inst.cc
cpu/sampler/sampler.cc cpu/sampler/sampler.cc
cpu/trace/reader/mem_trace_reader.cc cpu/trace/reader/mem_trace_reader.cc

View file

@ -38,6 +38,7 @@
#include "base/output.hh" #include "base/output.hh"
#include "base/trace.hh" #include "base/trace.hh"
#include "cpu/profile.hh" #include "cpu/profile.hh"
#include "cpu/quiesce_event.hh"
#include "kern/kernel_stats.hh" #include "kern/kernel_stats.hh"
#include "sim/serialize.hh" #include "sim/serialize.hh"
#include "sim/sim_exit.hh" #include "sim/sim_exit.hh"
@ -57,10 +58,12 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num, System *_sys,
: _status(ExecContext::Unallocated), cpu(_cpu), thread_num(_thread_num), : _status(ExecContext::Unallocated), cpu(_cpu), thread_num(_thread_num),
cpu_id(-1), lastActivate(0), lastSuspend(0), mem(_mem), itb(_itb), cpu_id(-1), lastActivate(0), lastSuspend(0), mem(_mem), itb(_itb),
dtb(_dtb), system(_sys), memctrl(_sys->memctrl), physmem(_sys->physmem), dtb(_dtb), system(_sys), memctrl(_sys->memctrl), physmem(_sys->physmem),
profile(NULL), quiesceEvent(this), func_exe_inst(0), storeCondFailures(0) profile(NULL), func_exe_inst(0), storeCondFailures(0)
{ {
proxy = new ProxyExecContext<CPUExecContext>(this); proxy = new ProxyExecContext<CPUExecContext>(this);
quiesceEvent = new EndQuiesceEvent(proxy);
memset(&regs, 0, sizeof(RegFile)); memset(&regs, 0, sizeof(RegFile));
if (cpu->params->profile) { if (cpu->params->profile) {
@ -82,7 +85,7 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num,
Process *_process, int _asid) Process *_process, int _asid)
: _status(ExecContext::Unallocated), : _status(ExecContext::Unallocated),
cpu(_cpu), thread_num(_thread_num), cpu_id(-1), lastActivate(0), cpu(_cpu), thread_num(_thread_num), cpu_id(-1), lastActivate(0),
lastSuspend(0), process(_process), mem(process->getMemory()), asid(_asid), lastSuspend(0), process(_process), mem(NULL), asid(_asid),
func_exe_inst(0), storeCondFailures(0) func_exe_inst(0), storeCondFailures(0)
{ {
memset(&regs, 0, sizeof(RegFile)); memset(&regs, 0, sizeof(RegFile));
@ -91,7 +94,7 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num,
CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num, CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num,
FunctionalMemory *_mem, int _asid) FunctionalMemory *_mem, int _asid)
: cpu(_cpu), thread_num(_thread_num), process(0), mem(_mem), asid(_asid), : cpu(_cpu), thread_num(_thread_num), process(0), mem(NULL), asid(_asid),
func_exe_inst(0), storeCondFailures(0) func_exe_inst(0), storeCondFailures(0)
{ {
memset(&regs, 0, sizeof(RegFile)); memset(&regs, 0, sizeof(RegFile));
@ -121,23 +124,6 @@ CPUExecContext::dumpFuncProfile()
profile->dump(proxy, *os); profile->dump(proxy, *os);
} }
CPUExecContext::EndQuiesceEvent::EndQuiesceEvent(CPUExecContext *_cpuXC)
: Event(&mainEventQueue), cpuXC(_cpuXC)
{
}
void
CPUExecContext::EndQuiesceEvent::process()
{
cpuXC->activate();
}
const char*
CPUExecContext::EndQuiesceEvent::description()
{
return "End Quiesce Event.";
}
void void
CPUExecContext::profileClear() CPUExecContext::profileClear()
{ {
@ -189,8 +175,8 @@ CPUExecContext::serialize(ostream &os)
#if FULL_SYSTEM #if FULL_SYSTEM
Tick quiesceEndTick = 0; Tick quiesceEndTick = 0;
if (quiesceEvent.scheduled()) if (quiesceEvent->scheduled())
quiesceEndTick = quiesceEvent.when(); quiesceEndTick = quiesceEvent->when();
SERIALIZE_SCALAR(quiesceEndTick); SERIALIZE_SCALAR(quiesceEndTick);
#endif #endif
@ -210,7 +196,7 @@ CPUExecContext::unserialize(Checkpoint *cp, const std::string &section)
Tick quiesceEndTick; Tick quiesceEndTick;
UNSERIALIZE_SCALAR(quiesceEndTick); UNSERIALIZE_SCALAR(quiesceEndTick);
if (quiesceEndTick) if (quiesceEndTick)
quiesceEvent.schedule(quiesceEndTick); quiesceEvent->schedule(quiesceEndTick);
#endif #endif
} }
@ -223,7 +209,14 @@ CPUExecContext::activate(int delay)
lastActivate = curTick; lastActivate = curTick;
if (status() == ExecContext::Unallocated) {
cpu->activateWhenReady(thread_num);
return;
}
_status = ExecContext::Active; _status = ExecContext::Active;
// status() == Suspended
cpu->activateContext(thread_num, delay); cpu->activateContext(thread_num, delay);
} }

View file

@ -135,23 +135,9 @@ class CPUExecContext
Addr profilePC; Addr profilePC;
void dumpFuncProfile(); void dumpFuncProfile();
/** Event for timing out quiesce instruction */ Event *quiesceEvent;
struct EndQuiesceEvent : public Event
{
/** A pointer to the execution context that is quiesced */
CPUExecContext *cpuXC;
EndQuiesceEvent(CPUExecContext *_cpuXC); Event *getQuiesceEvent() { return quiesceEvent; }
/** Event process to occur at interrupt*/
virtual void process();
/** Event description */
virtual const char *description();
};
EndQuiesceEvent quiesceEvent;
Event *getQuiesceEvent() { return &quiesceEvent; }
Tick readLastActivate() { return lastActivate; } Tick readLastActivate() { return lastActivate; }

20
cpu/quiesce_event.cc Normal file
View file

@ -0,0 +1,20 @@
#include "cpu/exec_context.hh"
#include "cpu/quiesce_event.hh"
EndQuiesceEvent::EndQuiesceEvent(ExecContext *_xc)
: Event(&mainEventQueue), xc(_xc)
{
}
void
EndQuiesceEvent::process()
{
xc->activate();
}
const char*
EndQuiesceEvent::description()
{
return "End Quiesce Event.";
}

23
cpu/quiesce_event.hh Normal file
View file

@ -0,0 +1,23 @@
#ifndef __CPU_QUIESCE_EVENT_HH__
#define __CPU_QUIESCE_EVENT_HH__
#include "sim/eventq.hh"
class ExecContext;
/** Event for timing out quiesce instruction */
struct EndQuiesceEvent : public Event
{
/** A pointer to the execution context that is quiesced */
ExecContext *xc;
EndQuiesceEvent(ExecContext *_xc);
/** Event process to occur at interrupt*/
virtual void process();
/** Event description */
virtual const char *description();
};
#endif // __CPU_QUIESCE_EVENT_HH__