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:
parent
c68032ddcb
commit
07969dbbf1
3 changed files with 25 additions and 9 deletions
|
@ -285,7 +285,17 @@ BaseCPU::registerThreadContexts()
|
||||||
for (int i = 0; i < threadContexts.size(); ++i) {
|
for (int i = 0; i < threadContexts.size(); ++i) {
|
||||||
ThreadContext *tc = threadContexts[i];
|
ThreadContext *tc = threadContexts[i];
|
||||||
|
|
||||||
tc->setContextId(system->registerThreadContext(tc));
|
/** This is so that contextId and cpuId match where there is a
|
||||||
|
* 1cpu:1context relationship. Otherwise, the order of registration
|
||||||
|
* could affect the assignment and cpu 1 could have context id 3, for
|
||||||
|
* example. We may even want to do something like this for SMT so that
|
||||||
|
* cpu 0 has the lowest thread contexts and cpu N has the highest, but
|
||||||
|
* I'll just do this for now
|
||||||
|
*/
|
||||||
|
if (number_of_threads == 1)
|
||||||
|
tc->setContextId(system->registerThreadContext(tc, _cpuId));
|
||||||
|
else
|
||||||
|
tc->setContextId(system->registerThreadContext(tc));
|
||||||
#if !FULL_SYSTEM
|
#if !FULL_SYSTEM
|
||||||
tc->getProcessPtr()->assignThreadContext(tc->contextId());
|
tc->getProcessPtr()->assignThreadContext(tc->contextId());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -166,16 +166,22 @@ bool System::breakpoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
System::registerThreadContext(ThreadContext *tc)
|
System::registerThreadContext(ThreadContext *tc, int assigned)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
for (id = 0; id < threadContexts.size(); id++) {
|
if (assigned == -1) {
|
||||||
if (!threadContexts[id])
|
for (id = 0; id < threadContexts.size(); id++) {
|
||||||
break;
|
if (!threadContexts[id])
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (threadContexts.size() <= id)
|
if (threadContexts.size() <= id)
|
||||||
threadContexts.resize(id + 1);
|
threadContexts.resize(id + 1);
|
||||||
|
} else {
|
||||||
|
if (threadContexts.size() <= assigned)
|
||||||
|
threadContexts.resize(assigned + 1);
|
||||||
|
id = assigned;
|
||||||
|
}
|
||||||
|
|
||||||
if (threadContexts[id])
|
if (threadContexts[id])
|
||||||
panic("Cannot have two CPUs with the same id (%d)\n", id);
|
panic("Cannot have two CPUs with the same id (%d)\n", id);
|
||||||
|
|
|
@ -224,7 +224,7 @@ class System : public SimObject
|
||||||
|
|
||||||
#endif // FULL_SYSTEM
|
#endif // FULL_SYSTEM
|
||||||
|
|
||||||
int registerThreadContext(ThreadContext *tc);
|
int registerThreadContext(ThreadContext *tc, int assigned=-1);
|
||||||
void replaceThreadContext(ThreadContext *tc, int context_id);
|
void replaceThreadContext(ThreadContext *tc, int context_id);
|
||||||
|
|
||||||
void serialize(std::ostream &os);
|
void serialize(std::ostream &os);
|
||||||
|
|
Loading…
Reference in a new issue