Draining fixes.
authorKevin Lim <ktlim@umich.edu>
Thu, 9 Nov 2006 16:33:44 +0000 (11:33 -0500)
committerKevin Lim <ktlim@umich.edu>
Thu, 9 Nov 2006 16:33:44 +0000 (11:33 -0500)
src/cpu/o3/cpu.cc:
    Handle draining properly when CPU isn't actually being used.
src/cpu/simple/atomic.cc:
    Be sure to set status properly when draining.
src/mem/bus.cc:
    Fix for draining.

--HG--
extra : convert_revision : d9796e6693e974f022159029fc9743c49a970c8f

src/cpu/o3/cpu.cc
src/cpu/simple/atomic.cc
src/mem/bus.cc

index dfe42d88223b53992ad249f9c6db9f8f625e4ed6..5808163723d9a0eea51f5866bf3088f5d592126e 100644 (file)
@@ -819,6 +819,12 @@ unsigned int
 FullO3CPU<Impl>::drain(Event *drain_event)
 {
     DPRINTF(O3CPU, "Switching out\n");
+
+    // If the CPU isn't doing anything, then return immediately.
+    if (_status == Idle || _status == SwitchedOut) {
+        return 0;
+    }
+
     drainCount = 0;
     fetch.drain();
     decode.drain();
index 4f68cfd6fdfc62ffea9c64db7fb932f962a7960d..f94ea091748720278f70b1c7af052c9ef3b85e6e 100644 (file)
@@ -213,6 +213,9 @@ AtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
             break;
         }
     }
+    if (_status != Running) {
+        _status = Idle;
+    }
 }
 
 
index 7b65d252b952c792a0794dd243a0b8f4f88b5446..ae87d80990826f25f81c81ca4277c9762d35f062 100644 (file)
@@ -242,8 +242,11 @@ Bus::recvRetry(int id)
         }
     }
     //If we weren't able to drain before, we might be able to now.
-    if (drainEvent && retryList.size() == 0 && curTick >= tickNextIdle)
+    if (drainEvent && retryList.size() == 0 && curTick >= tickNextIdle) {
         drainEvent->process();
+        // Clear the drain event once we're done with it.
+        drainEvent = NULL;
+    }
 }
 
 Port *