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.
This commit is contained in:
Korey Sewell 2010-01-31 18:26:47 -05:00
parent d9eaa2fe21
commit 96b493d315
2 changed files with 41 additions and 16 deletions

View file

@ -628,7 +628,7 @@ InOrderCPU::scheduleCpuEvent(CPUEventType c_event, Fault fault,
resPool->scheduleEvent(c_event, inst, 0, 0, tid); resPool->scheduleEvent(c_event, inst, 0, 0, tid);
} }
inline bool bool
InOrderCPU::isThreadActive(ThreadID tid) InOrderCPU::isThreadActive(ThreadID tid)
{ {
list<ThreadID>::iterator isActive = list<ThreadID>::iterator isActive =
@ -637,6 +637,23 @@ InOrderCPU::isThreadActive(ThreadID tid)
return (isActive != activeThreads.end()); 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 void
InOrderCPU::activateNextReadyThread() InOrderCPU::activateNextReadyThread()
@ -655,24 +672,38 @@ InOrderCPU::activateNextReadyThread()
readyThreads.erase(ready_it); readyThreads.erase(ready_it);
} else { } else {
DPRINTF(InOrderCPU, DPRINTF(InOrderCPU,
"No Ready Threads to Activate.\n"); "Attempting to activate new thread, but No Ready Threads to"
"activate.\n");
} }
} }
void void
InOrderCPU::activateThread(ThreadID tid) 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 && if (threadModel == SwitchOnCacheMiss &&
numActiveThreads() == 1) { numActiveThreads() == 1) {
DPRINTF(InOrderCPU, DPRINTF(InOrderCPU,
"Ignoring Activation of [tid:%i]. Placing on " "Ignoring activation of [tid:%i], since [tid:%i] is "
"ready list\n", tid); "already running.\n", tid, activeThreadId());
DPRINTF(InOrderCPU,"Placing [tid:%i] ready threads list\n",
tid);
readyThreads.push_back(tid); readyThreads.push_back(tid);
} else if (!isThreadActive(tid)) { } else if (!isThreadActive(tid)) {
DPRINTF(InOrderCPU, 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); activeThreads.push_back(tid);
wakeCPU(); wakeCPU();
@ -710,6 +741,8 @@ InOrderCPU::deactivateThread(ThreadID tid)
activeThreads.erase(thread_it); activeThreads.erase(thread_it);
} }
assert(!isThreadActive(tid));
} }
void void
@ -758,15 +791,6 @@ InOrderCPU::removePipelineStalls(ThreadID tid)
} }
bool
InOrderCPU::isThreadSuspended(ThreadID tid)
{
list<ThreadID>::iterator isSuspended =
std::find(suspendedThreads.begin(), suspendedThreads.end(), tid);
return (isSuspended!= suspendedThreads.end());
}
void void
InOrderCPU::updateThreadPriority() InOrderCPU::updateThreadPriority()
{ {

View file

@ -588,6 +588,7 @@ class InOrderCPU : public BaseCPU
/** Thread Status Functions */ /** Thread Status Functions */
bool isThreadActive(ThreadID tid); bool isThreadActive(ThreadID tid);
bool isThreadReady(ThreadID tid);
bool isThreadSuspended(ThreadID tid); bool isThreadSuspended(ThreadID tid);
private: private: