From 52ff37caa3dc434baa0468f13ac609430f078982 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Mon, 7 Jan 2013 13:05:46 -0500 Subject: cpu: Fix broken thread context handover The thread context handover code used to break when multiple handovers were performed during the same quiesce period. Previously, the thread contexts would assign the TC pointer in the old quiesce event to the new TC. This obviously broke in cases where multiple switches were performed within the same quiesce period, in which case the TC pointer in the quiesce event would point to an old CPU. The new implementation deschedules pending quiesce events in the old TC and schedules a new quiesce event in the new TC. The code has been refactored to remove most of the code duplication. --- src/cpu/o3/thread_context_impl.hh | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'src/cpu/o3') diff --git a/src/cpu/o3/thread_context_impl.hh b/src/cpu/o3/thread_context_impl.hh index 0a8dfeb3e..6de5c5731 100755 --- a/src/cpu/o3/thread_context_impl.hh +++ b/src/cpu/o3/thread_context_impl.hh @@ -66,34 +66,10 @@ template void O3ThreadContext::takeOverFrom(ThreadContext *old_context) { - // some things should already be set up - assert(getSystemPtr() == old_context->getSystemPtr()); - assert(getProcessPtr() == old_context->getProcessPtr()); + ::takeOverFrom(*this, *old_context); - // copy over functional state - setStatus(old_context->status()); - copyArchRegs(old_context); - setContextId(old_context->contextId()); - setThreadId(old_context->threadId()); - - if (FullSystem) { - EndQuiesceEvent *other_quiesce = old_context->getQuiesceEvent(); - if (other_quiesce) { - // Point the quiesce event's TC at this TC so that it wakes up - // the proper CPU. - other_quiesce->tc = this; - } - if (thread->quiesceEvent) { - thread->quiesceEvent->tc = this; - } - - // Transfer kernel stats from one CPU to the other. - thread->kernelStats = old_context->getKernelStats(); - } else { - thread->funcExeInst = old_context->readFuncExeInst(); - } - - old_context->setStatus(ThreadContext::Halted); + thread->kernelStats = old_context->getKernelStats(); + thread->funcExeInst = old_context->readFuncExeInst(); thread->noSquashFromTC = false; thread->trapPending = false; -- cgit v1.2.3