summaryrefslogtreecommitdiff
path: root/src/cpu/base.cc
diff options
context:
space:
mode:
authorLisa Hsu <hsul@eecs.umich.edu>2008-11-05 15:30:49 -0500
committerLisa Hsu <hsul@eecs.umich.edu>2008-11-05 15:30:49 -0500
commit07969dbbf1a737e666b5ba6d34cd7cf2b403a9ad (patch)
treec9c5071ab9e25020a4734a266612057a622f219c /src/cpu/base.cc
parentc68032ddcbf0aad10123710e7c7c932bf52061a0 (diff)
downloadgem5-07969dbbf1a737e666b5ba6d34cd7cf2b403a9ad.tar.xz
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.
Diffstat (limited to 'src/cpu/base.cc')
-rw-r--r--src/cpu/base.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 1fa7add65..167606135 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -285,7 +285,17 @@ BaseCPU::registerThreadContexts()
for (int i = 0; i < threadContexts.size(); ++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
tc->getProcessPtr()->assignThreadContext(tc->contextId());
#endif