Move quiesce event to its own class.
authorKevin Lim <ktlim@umich.edu>
Sat, 22 Apr 2006 22:11:54 +0000 (18:11 -0400)
committerKevin Lim <ktlim@umich.edu>
Sat, 22 Apr 2006 22:11:54 +0000 (18:11 -0400)
SConscript:
    Move quiesce event to its own file/class.

--HG--
extra : convert_revision : 6aa7863adb529fc03142666213c3ec348825bd3b

SConscript
cpu/cpu_exec_context.cc
cpu/cpu_exec_context.hh
cpu/quiesce_event.cc [new file with mode: 0644]
cpu/quiesce_event.hh [new file with mode: 0644]

index 8f2ae761dca7b144b4a89423201874ea1acade45..062661557a3662c9a117602c70d79261a58a7128 100644 (file)
@@ -85,6 +85,7 @@ base_sources = Split('''
        cpu/cpu_exec_context.cc
        cpu/exetrace.cc
        cpu/pc_event.cc
+        cpu/quiesce_event.cc
        cpu/static_inst.cc
         cpu/sampler/sampler.cc
         cpu/trace/reader/mem_trace_reader.cc
index b7238e73a58120ce69065deacb05e558624d5389..363244e60ed71b92d98df9b071a9dabc0e0f7441 100644 (file)
@@ -38,6 +38,7 @@
 #include "base/output.hh"
 #include "base/trace.hh"
 #include "cpu/profile.hh"
+#include "cpu/quiesce_event.hh"
 #include "kern/kernel_stats.hh"
 #include "sim/serialize.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),
       cpu_id(-1), lastActivate(0), lastSuspend(0), mem(_mem), itb(_itb),
       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);
 
+    quiesceEvent = new EndQuiesceEvent(proxy);
+
     memset(&regs, 0, sizeof(RegFile));
 
     if (cpu->params->profile) {
@@ -82,7 +85,7 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num,
                          Process *_process, int _asid)
     : _status(ExecContext::Unallocated),
       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)
 {
     memset(&regs, 0, sizeof(RegFile));
@@ -91,7 +94,7 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num,
 
 CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num,
                          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)
 {
     memset(&regs, 0, sizeof(RegFile));
@@ -121,23 +124,6 @@ CPUExecContext::dumpFuncProfile()
     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
 CPUExecContext::profileClear()
 {
@@ -189,8 +175,8 @@ CPUExecContext::serialize(ostream &os)
 
 #if FULL_SYSTEM
     Tick quiesceEndTick = 0;
-    if (quiesceEvent.scheduled())
-        quiesceEndTick = quiesceEvent.when();
+    if (quiesceEvent->scheduled())
+        quiesceEndTick = quiesceEvent->when();
     SERIALIZE_SCALAR(quiesceEndTick);
 
 #endif
@@ -210,7 +196,7 @@ CPUExecContext::unserialize(Checkpoint *cp, const std::string &section)
     Tick quiesceEndTick;
     UNSERIALIZE_SCALAR(quiesceEndTick);
     if (quiesceEndTick)
-        quiesceEvent.schedule(quiesceEndTick);
+        quiesceEvent->schedule(quiesceEndTick);
 #endif
 }
 
@@ -223,7 +209,14 @@ CPUExecContext::activate(int delay)
 
     lastActivate = curTick;
 
+    if (status() == ExecContext::Unallocated) {
+        cpu->activateWhenReady(thread_num);
+        return;
+    }
+
     _status = ExecContext::Active;
+
+    // status() == Suspended
     cpu->activateContext(thread_num, delay);
 }
 
index beaf673528587d493eb0713411e3616f5aef77ff..40153ff08558108cf48a4f7a35d6094eb11a77fe 100644 (file)
@@ -135,23 +135,9 @@ class CPUExecContext
     Addr profilePC;
     void dumpFuncProfile();
 
-    /** Event for timing out quiesce instruction */
-    struct EndQuiesceEvent : public Event
-    {
-        /** A pointer to the execution context that is quiesced */
-        CPUExecContext *cpuXC;
-
-        EndQuiesceEvent(CPUExecContext *_cpuXC);
-
-        /** Event process to occur at interrupt*/
-        virtual void process();
-
-        /** Event description */
-        virtual const char *description();
-    };
-    EndQuiesceEvent quiesceEvent;
+    Event *quiesceEvent;
 
-    Event *getQuiesceEvent() { return &quiesceEvent; }
+    Event *getQuiesceEvent() { return quiesceEvent; }
 
     Tick readLastActivate() { return lastActivate; }
 
diff --git a/cpu/quiesce_event.cc b/cpu/quiesce_event.cc
new file mode 100644 (file)
index 0000000..37814ae
--- /dev/null
@@ -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.";
+}
diff --git a/cpu/quiesce_event.hh b/cpu/quiesce_event.hh
new file mode 100644 (file)
index 0000000..18e88ec
--- /dev/null
@@ -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__