cpu: stop scheduling suspended threads in all stages of MinorCPU
authorTuan Ta <qtt2@cornell.edu>
Mon, 2 Apr 2018 20:22:01 +0000 (16:22 -0400)
committerTuan Ta <qtt2@cornell.edu>
Fri, 8 Feb 2019 15:25:30 +0000 (15:25 +0000)
This patch makes suspended threads non-schedulable in Fetch1, Fetch2,
Decode and Execute stages in MinorCPU.

Change-Id: Ie79857e13b7b782d9c58c32310993a132b609cf9
Reviewed-on: https://gem5-review.googlesource.com/c/9625
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Giacomo Gabrielli <giacomo.gabrielli@gmail.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/cpu/minor/decode.cc
src/cpu/minor/execute.cc
src/cpu/minor/fetch2.cc

index 390ca5f114a29b305063507f2cdf4f7b59837cc6..94d3dec03299697064e8f501157366bea5bf7582 100644 (file)
@@ -314,7 +314,9 @@ Decode::getScheduledThread()
     }
 
     for (auto tid : priority_list) {
-        if (getInput(tid) && !decodeInfo[tid].blocked) {
+        if (cpu.getContext(tid)->status() == ThreadContext::Active &&
+            getInput(tid) &&
+            !decodeInfo[tid].blocked) {
             threadPriority = tid;
             return tid;
         }
index 93c0895ac94dedd5181dca103a54e2fd40f4615e..d7cb475c687ec2624f11c906f3221b798935d079 100644 (file)
@@ -1676,7 +1676,12 @@ Execute::getCommittingThread()
 
     for (auto tid : priority_list) {
         ExecuteThreadInfo &ex_info = executeInfo[tid];
-        bool can_commit_insts = !ex_info.inFlightInsts->empty();
+
+        bool is_thread_active =
+                cpu.getContext(tid)->status() == ThreadContext::Active;
+        bool can_commit_insts = !ex_info.inFlightInsts->empty() &&
+                                is_thread_active;
+
         if (can_commit_insts) {
             QueuedInst *head_inflight_inst = &(ex_info.inFlightInsts->front());
             MinorDynInstPtr inst = head_inflight_inst->inst;
@@ -1742,7 +1747,8 @@ Execute::getIssuingThread()
     }
 
     for (auto tid : priority_list) {
-        if (getInput(tid)) {
+        if (cpu.getContext(tid)->status() == ThreadContext::Active &&
+            getInput(tid)) {
             issuePriority = tid;
             return tid;
         }
index 09a06fc240ac44c08f1423dc02b2566d9f15ee5a..180890147d2a385737e825ac7fc1561b32d5447c 100644 (file)
@@ -584,7 +584,9 @@ Fetch2::getScheduledThread()
     }
 
     for (auto tid : priority_list) {
-        if (getInput(tid) && !fetchInfo[tid].blocked) {
+        if (cpu.getContext(tid)->status() == ThreadContext::Active &&
+            getInput(tid) &&
+            !fetchInfo[tid].blocked) {
             threadPriority = tid;
             return tid;
         }