# HG changeset patch
# User Korey Sewell <[email protected]>
# Date 1254427253 14400
# Node ID 73271f740215297fd95d0022137ed70bace5f906
# Parent d7442a099e4b73c34aefbd74058205b6aafd3f61
inorder: ready/suspend status fns
update/add in the use of isThreadReady & isThreadSuspended
functions.Check in activateThread what list a thread is
on so it can be managed accordingly.
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
@@ -609,7 +609,7 @@
resPool->scheduleEvent(c_event, inst, 0, 0, tid);
}
-inline bool
+bool
InOrderCPU::isThreadActive(ThreadID tid)
{
list<ThreadID>::iterator isActive =
@@ -618,6 +618,23 @@
return (isActive != activeThreads.end());
}
+bool
+InOrderCPU::isThreadReady(ThreadID tid)
+{
+ list<ThreadID>::iterator isReady =
+ std::find(readyThreads.begin(), readyThreads.end(), tid);
+
+ return (isReady != readyThreads.end());
+}
+
+bool
+InOrderCPU::isThreadSuspended(ThreadID tid)
+{
+ list<ThreadID>::iterator isSuspended =
+ std::find(suspendedThreads.begin(), suspendedThreads.end(), tid);
+
+ return (isSuspended != suspendedThreads.end());
+}
void
InOrderCPU::activateNextReadyThread()
@@ -636,26 +653,40 @@
readyThreads.erase(ready_it);
} else {
DPRINTF(InOrderCPU,
- "No Ready Threads to Activate.\n");
+ "Attempting to activate new thread, but No Ready Threads to"
+ "activate.\n");
}
}
void
InOrderCPU::activateThread(ThreadID tid)
{
+ if (isThreadSuspended(tid)) {
+ DPRINTF(InOrderCPU,
+ "Removing [tid:%i] from suspended threads list.\n", tid);
+
+ list<ThreadID>::iterator susp_it =
+ std::find(suspendedThreads.begin(), suspendedThreads.end(),
+ tid);
+ suspendedThreads.erase(susp_it);
+ }
+
if (threadModel == SwitchOnCacheMiss &&
numActiveThreads() == 1) {
DPRINTF(InOrderCPU,
- "Ignoring Activation of [tid:%i]. Placing on "
- "ready list\n", tid);
+ "Ignoring activation of [tid:%i], since [tid:%i] is "
+ "already running.\n", tid, activeThreadId());
+
+ DPRINTF(InOrderCPU,"Placing [tid:%i] ready threads list\n",
+ tid);
readyThreads.push_back(tid);
- } else if (!isThreadActive(tid)) {
+ } else if (!isThreadActive(tid)) {
DPRINTF(InOrderCPU,
- "Adding Thread %i to active threads list in CPU.\n", tid);
+ "Adding [tid:%i] to active threads list.\n", tid);
activeThreads.push_back(tid);
-
+
wakeCPU();
}
}
@@ -691,6 +722,8 @@
activeThreads.erase(thread_it);
}
+
+ assert(!isThreadActive(tid));
}
void
@@ -739,15 +772,6 @@
}
-bool
-InOrderCPU::isThreadSuspended(ThreadID tid)
-{
- list<ThreadID>::iterator isSuspended =
- std::find(suspendedThreads.begin(), suspendedThreads.end(), tid);
-
- return (isSuspended!= suspendedThreads.end());
-}
-
void
InOrderCPU::updateThreadPriority()
{
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
@@ -579,6 +579,7 @@
/** Thread Status Functions */
bool isThreadActive(ThreadID tid);
+ bool isThreadReady(ThreadID tid);
bool isThreadSuspended(ThreadID tid);
private:
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev