summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sim/process.cc10
-rw-r--r--src/sim/process.hh3
-rw-r--r--src/sim/syscall_emul.hh2
-rw-r--r--src/sim/system.cc10
-rw-r--r--src/sim/system.hh13
5 files changed, 19 insertions, 19 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index e7f682aad..d3eb069dc 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -280,16 +280,6 @@ Process::regStats()
;
}
-ThreadContext *
-Process::findFreeContext()
-{
- for (auto &it : system->threadContexts) {
- if (ThreadContext::Halted == it->status())
- return it;
- }
- return nullptr;
-}
-
void
Process::revokeThreadContext(int context_id)
{
diff --git a/src/sim/process.hh b/src/sim/process.hh
index 70be3ab8a..6183bcc53 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -129,9 +129,6 @@ class Process : public SimObject
contextIds.push_back(context_id);
}
- // Find a free context to use
- ThreadContext *findFreeContext();
-
/**
* After delegating a thread context to a child process
* no longer should relate to the ThreadContext
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index f7d87d445..62020397f 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1527,7 +1527,7 @@ cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
return -EINVAL;
ThreadContext *ctc;
- if (!(ctc = p->findFreeContext())) {
+ if (!(ctc = tc->getSystemPtr()->findFreeContext())) {
DPRINTF_SYSCALL(Verbose, "clone: no spare thread context in system"
"[cpu %d, thread %d]", tc->cpuId(), tc->threadId());
return -EAGAIN;
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 0cc328c22..739b42278 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -302,6 +302,16 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned)
return id;
}
+ThreadContext *
+System::findFreeContext()
+{
+ for (auto &it : threadContexts) {
+ if (ThreadContext::Halted == it->status())
+ return it;
+ }
+ return nullptr;
+}
+
bool
System::schedule(PCEvent *event)
{
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 6c63b327f..638e35249 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -188,6 +188,14 @@ class System : public SimObject, public PCEventScope
unsigned int cacheLineSize() const { return _cacheLineSize; }
std::vector<ThreadContext *> threadContexts;
+ ThreadContext *findFreeContext();
+
+ ThreadContext *
+ getThreadContext(ContextID tid) const
+ {
+ return threadContexts[tid];
+ }
+
const bool multiThread;
using SimObject::schedule;
@@ -195,11 +203,6 @@ class System : public SimObject, public PCEventScope
bool schedule(PCEvent *event) override;
bool remove(PCEvent *event) override;
- ThreadContext *getThreadContext(ContextID tid) const
- {
- return threadContexts[tid];
- }
-
unsigned numContexts() const { return threadContexts.size(); }
/** Return number of running (non-halted) thread contexts in