Right now a single thread cpu 1 could get assigned context Id != 1, depending

on the order in which it's registered with the system.  To make them match,
here is a little change.
This commit is contained in:
Lisa Hsu
2008-11-05 15:30:49 -05:00
parent c68032ddcb
commit 07969dbbf1
3 changed files with 25 additions and 9 deletions

View File

@@ -166,16 +166,22 @@ bool System::breakpoint()
}
int
System::registerThreadContext(ThreadContext *tc)
System::registerThreadContext(ThreadContext *tc, int assigned)
{
int id;
for (id = 0; id < threadContexts.size(); id++) {
if (!threadContexts[id])
break;
}
if (assigned == -1) {
for (id = 0; id < threadContexts.size(); id++) {
if (!threadContexts[id])
break;
}
if (threadContexts.size() <= id)
threadContexts.resize(id + 1);
if (threadContexts.size() <= id)
threadContexts.resize(id + 1);
} else {
if (threadContexts.size() <= assigned)
threadContexts.resize(assigned + 1);
id = assigned;
}
if (threadContexts[id])
panic("Cannot have two CPUs with the same id (%d)\n", id);

View File

@@ -224,7 +224,7 @@ class System : public SimObject
#endif // FULL_SYSTEM
int registerThreadContext(ThreadContext *tc);
int registerThreadContext(ThreadContext *tc, int assigned=-1);
void replaceThreadContext(ThreadContext *tc, int context_id);
void serialize(std::ostream &os);