* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Steve Reinhardt
+ * Nathan Binkert
*/
#include <iostream>
#include "base/output.hh"
#include "cpu/base.hh"
#include "cpu/cpuevent.hh"
-#include "cpu/exec_context.hh"
+#include "cpu/thread_context.hh"
#include "cpu/profile.hh"
-#include "cpu/sampler/sampler.hh"
#include "sim/param.hh"
#include "sim/process.hh"
#include "sim/sim_events.hh"
#if FULL_SYSTEM
BaseCPU::BaseCPU(Params *p)
- : SimObject(p->name), clock(p->clock), checkInterrupts(true),
+ : MemObject(p->name), clock(p->clock), checkInterrupts(true),
params(p), number_of_threads(p->numberOfThreads), system(p->system)
#else
BaseCPU::BaseCPU(Params *p)
- : SimObject(p->name), clock(p->clock), params(p),
+ : MemObject(p->name), clock(p->clock), params(p),
number_of_threads(p->numberOfThreads), system(p->system)
#endif
{
//
if (p->max_insts_any_thread != 0)
for (int i = 0; i < number_of_threads; ++i)
- new SimExitEvent(comInstEventQueue[i], p->max_insts_any_thread,
- "a thread reached the max instruction count");
+ new SimLoopExitEvent(comInstEventQueue[i], p->max_insts_any_thread,
+ "a thread reached the max instruction count");
if (p->max_insts_all_threads != 0) {
// allocate & initialize shared downcounter: each event will
//
if (p->max_loads_any_thread != 0)
for (int i = 0; i < number_of_threads; ++i)
- new SimExitEvent(comLoadEventQueue[i], p->max_loads_any_thread,
- "a thread reached the max load count");
+ new SimLoopExitEvent(comLoadEventQueue[i], p->max_loads_any_thread,
+ "a thread reached the max load count");
if (p->max_loads_all_threads != 0) {
// allocate & initialize shared downcounter: each event will
BaseCPU::init()
{
if (!params->deferRegistration)
- registerExecContexts();
+ registerThreadContexts();
}
void
.desc("number of cpu cycles simulated")
;
- int size = execContexts.size();
+ int size = threadContexts.size();
if (size > 1) {
for (int i = 0; i < size; ++i) {
stringstream namestr;
ccprintf(namestr, "%s.ctx%d", name(), i);
- execContexts[i]->regStats(namestr.str());
+ threadContexts[i]->regStats(namestr.str());
}
} else if (size == 1)
- execContexts[0]->regStats(name());
+ threadContexts[0]->regStats(name());
#if FULL_SYSTEM
#endif
void
-BaseCPU::registerExecContexts()
+BaseCPU::registerThreadContexts()
{
- for (int i = 0; i < execContexts.size(); ++i) {
- ExecContext *xc = execContexts[i];
+ for (int i = 0; i < threadContexts.size(); ++i) {
+ ThreadContext *tc = threadContexts[i];
#if FULL_SYSTEM
int id = params->cpu_id;
if (id != -1)
id += i;
- xc->setCpuId(system->registerExecContext(xc, id));
+ tc->setCpuId(system->registerThreadContext(tc, id));
#else
- xc->setCpuId(xc->getProcessPtr()->registerExecContext(xc));
+ tc->setCpuId(tc->getProcessPtr()->registerThreadContext(tc));
#endif
- }
}
}
void
-BaseCPU::switchOut(Sampler *sampler)
+BaseCPU::switchOut()
{
panic("This CPU doesn't support sampling!");
}
void
BaseCPU::takeOverFrom(BaseCPU *oldCPU)
{
- assert(execContexts.size() == oldCPU->execContexts.size());
+ assert(threadContexts.size() == oldCPU->threadContexts.size());
- for (int i = 0; i < execContexts.size(); ++i) {
- ExecContext *newXC = execContexts[i];
- ExecContext *oldXC = oldCPU->execContexts[i];
+ for (int i = 0; i < threadContexts.size(); ++i) {
+ ThreadContext *newTC = threadContexts[i];
+ ThreadContext *oldTC = oldCPU->threadContexts[i];
- newXC->takeOverFrom(oldXC);
+ newTC->takeOverFrom(oldTC);
- CpuEvent::replaceExecContext(oldXC, newXC);
+ CpuEvent::replaceThreadContext(oldTC, newTC);
- assert(newXC->readCpuId() == oldXC->readCpuId());
+ assert(newTC->readCpuId() == oldTC->readCpuId());
#if FULL_SYSTEM
- system->replaceExecContext(newXC, newXC->readCpuId());
+ system->replaceThreadContext(newTC, newTC->readCpuId());
#else
- assert(newXC->getProcessPtr() == oldXC->getProcessPtr());
- newXC->getProcessPtr()->replaceExecContext(newXC, newXC->readCpuId());
+ assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
+ newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->readCpuId());
#endif
}
interrupts[i] = oldCPU->interrupts[i];
intstatus = oldCPU->intstatus;
- for (int i = 0; i < execContexts.size(); ++i)
- execContexts[i]->profileClear();
+ for (int i = 0; i < threadContexts.size(); ++i)
+ threadContexts[i]->profileClear();
if (profileEvent)
profileEvent->schedule(curTick);
void
BaseCPU::ProfileEvent::process()
{
- for (int i = 0, size = cpu->execContexts.size(); i < size; ++i) {
- ExecContext *xc = cpu->execContexts[i];
- xc->profileSample();
+ for (int i = 0, size = cpu->threadContexts.size(); i < size; ++i) {
+ ThreadContext *tc = cpu->threadContexts[i];
+ tc->profileSample();
}
schedule(curTick + interval);