# HG changeset patch
# User Korey Sewell <[email protected]>
# Date 1254427253 14400
# Node ID 47663743ca146c41aad078f29c69fc9998f86a27
# Parent  bfed5a5a12278f9dff5feee73ae28052b11f52af
inorder: add/remove halt/deallocate context respectively
Halt is called from the exit() system call while
deallocate is unused. So to clear up things, just
use halt and remove deallocate.

diff --git a/src/cpu/inorder/cpu.cc b/src/cpu/inorder/cpu.cc
--- a/src/cpu/inorder/cpu.cc
+++ b/src/cpu/inorder/cpu.cc
@@ -97,7 +97,7 @@
     "ActivateThread",
     "ActivateNextReadyThread",
     "DeactivateThread",
-    "DeallocateThread",
+    "HaltThread",
     "SuspendThread",
     "Trap",
     "InstGraduated",
@@ -122,8 +122,8 @@
         cpu->deactivateThread(tid);
         break;
 
-      case DeallocateThread:
-        cpu->deallocateThread(tid);
+      case HaltThread:
+        cpu->haltThread(tid);
         break;
 
       case SuspendThread: 
@@ -139,7 +139,7 @@
         break;
 
       default:
-        fatal("Unrecognized Event Type %d", cpuEventType);
+        fatal("Unrecognized Event Type %s", eventNames[cpuEventType]);
     }
 
     cpu->cpuEventRemoveList.push(this);
@@ -741,40 +741,6 @@
 }
 
 void
-InOrderCPU::deallocateContext(ThreadID tid, int delay)
-{
-    DPRINTF(InOrderCPU,"[tid:%i]: Deallocating ...\n", tid);
-
-    scheduleCpuEvent(DeallocateThread, NoFault, tid, dummyInst, delay);
-
-    // Be sure to signal that there's some activity so the CPU doesn't
-    // deschedule itself.
-    activityRec.activity();
-
-    _status = Running;
-}
-
-void
-InOrderCPU::deallocateThread(ThreadID tid)
-{
-    DPRINTF(InOrderCPU, "[tid:%i]: Calling deallocate thread.\n", tid);
-
-    if (isThreadActive(tid)) {
-        DPRINTF(InOrderCPU,"[tid:%i]: Removing from active threads list\n",
-                tid);
-        list<ThreadID>::iterator thread_it =
-            std::find(activeThreads.begin(), activeThreads.end(), tid);
-
-        removePipelineStalls(*thread_it);
-
-        activeThreads.erase(thread_it);
-    }
-
-    // TODO: "Un"Load/Unmap register file state
-  
-}
-
-void
 InOrderCPU::removePipelineStalls(ThreadID tid)
 {
     DPRINTF(InOrderCPU,"[tid:%i]: Removing all pipeline stalls\n",
@@ -855,20 +821,38 @@
 void
 InOrderCPU::haltContext(ThreadID tid, int delay)
 {
-    suspendContext(tid, delay);
+    DPRINTF(InOrderCPU, "[tid:%i]: Calling Halt Context...\n", tid);
+
+    scheduleCpuEvent(HaltThread, NoFault, tid, dummyInst, delay);
+
+    activityRec.activity();
+
+    _status = Running;
+}
+
+void
+InOrderCPU::haltThread(ThreadID tid)
+{
+    DPRINTF(InOrderCPU, "[tid:%i]: Placing on Halted Threads List...\n", tid);
+    deactivateThread(tid);
+    squashThreadInPipeline(tid);   
+    haltedThreads.push_back(tid);    
+
+    if (threadModel == SwitchOnCacheMiss) {        
+        activateNextReadyContext();    
+    }
 }
 
 void
 InOrderCPU::suspendContext(ThreadID tid, int delay)
 {
     scheduleCpuEvent(SuspendThread, NoFault, tid, dummyInst, delay);
-    //_status = Idle;
 }
 
 void
 InOrderCPU::suspendThread(ThreadID tid)
 {
-    DPRINTF(InOrderCPU, "[tid: %i]: Placing on Suspended Threads List...\n", 
tid);
+    DPRINTF(InOrderCPU, "[tid:%i]: Placing on Suspended Threads List...\n", 
tid);
     deactivateThread(tid);
     suspendedThreads.push_back(tid);    
     thread[tid]->lastSuspend = curTick;    
diff --git a/src/cpu/inorder/cpu.hh b/src/cpu/inorder/cpu.hh
--- a/src/cpu/inorder/cpu.hh
+++ b/src/cpu/inorder/cpu.hh
@@ -174,7 +174,7 @@
         ActivateThread,
         ActivateNextReadyThread,
         DeactivateThread,
-        DeallocateThread,
+        HaltThread,
         SuspendThread,
         Trap,
         InstGraduated,
@@ -352,16 +352,18 @@
     void deactivateThread(ThreadID tid);
 
     /** Suspend Thread, Remove from Active Threads List, Add to Suspend List */
-    void haltContext(ThreadID tid, int delay = 0);
     void suspendContext(ThreadID tid, int delay = 0);
     void suspendThread(ThreadID tid);
 
-    /** Remove Thread from Active Threads List, Remove Any Loaded Thread State 
*/
-    void deallocateContext(ThreadID tid, int delay = 0);
-    void deallocateThread(ThreadID tid);
+    /** Halt Thread, Remove from Active Thread List, Place Thread on Halted 
+     *  Threads List 
+     */
+    void haltContext(ThreadID tid, int delay = 0);
+    void haltThread(ThreadID tid);
 
     /** squashFromMemStall() - sets up a squash event
      *  squashDueToMemStall() - squashes pipeline
+     *  @note: maybe squashContext/squashThread would be better?
      */
     void squashFromMemStall(DynInstPtr inst, ThreadID tid, int delay = 0);
     void squashDueToMemStall(int stage_num, InstSeqNum seq_num, ThreadID tid); 
   
@@ -578,6 +580,9 @@
     /** Suspended Threads List */
     std::list<ThreadID> suspendedThreads;
 
+    /** Halted Threads List */
+    std::list<ThreadID> haltedThreads;
+
     /** Thread Status Functions */
     bool isThreadActive(ThreadID tid);
     bool isThreadReady(ThreadID tid);
diff --git a/src/cpu/inorder/resource_pool.cc b/src/cpu/inorder/resource_pool.cc
--- a/src/cpu/inorder/resource_pool.cc
+++ b/src/cpu/inorder/resource_pool.cc
@@ -185,6 +185,9 @@
 //@todo: split this function and call this version schedulePoolEvent
 //       and use this scheduleEvent for scheduling a specific event on 
 //       a resource
+//@todo: For arguments that arent being used in a ResPoolEvent, a dummyParam
+//       or some typedef can be used to signify what's important info
+//       to the event construction
 void
 ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                             int delay,  int res_idx, ThreadID tid)
@@ -207,8 +210,8 @@
         }
         break;
 
+      case InOrderCPU::HaltThread:
       case InOrderCPU::DeactivateThread:
-      case InOrderCPU::DeallocateThread:
         {
 
             DPRINTF(Resource, "Scheduling Deactivate Thread Resource Pool 
Event for tick %i.\n",
@@ -443,7 +446,7 @@
         break;
 
       case InOrderCPU::DeactivateThread:
-      case InOrderCPU::DeallocateThread:
+      case InOrderCPU::HaltThread:
         resPool->deactivateAll(tid);
         break;
 
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to