summaryrefslogtreecommitdiff
path: root/src/sim/system.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/sim/system.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/sim/system.cc')
-rw-r--r--src/sim/system.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 9704c83f0..29b1d1f61 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -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);