diff options
Diffstat (limited to 'cpu/base_cpu.cc')
-rw-r--r-- | cpu/base_cpu.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/cpu/base_cpu.cc b/cpu/base_cpu.cc index 90785946e..2e1d95d88 100644 --- a/cpu/base_cpu.cc +++ b/cpu/base_cpu.cc @@ -49,13 +49,17 @@ int maxThreadsPerCPU = 1; BaseCPU::BaseCPU(const string &_name, int _number_of_threads, Counter max_insts_any_thread, Counter max_insts_all_threads, + Counter max_loads_any_thread, + Counter max_loads_all_threads, System *_system, int num, Tick freq) : SimObject(_name), number(num), frequency(freq), number_of_threads(_number_of_threads), system(_system) #else BaseCPU::BaseCPU(const string &_name, int _number_of_threads, Counter max_insts_any_thread, - Counter max_insts_all_threads) + Counter max_insts_all_threads, + Counter max_loads_any_thread, + Counter max_loads_all_threads) : SimObject(_name), number_of_threads(_number_of_threads) #endif { @@ -90,6 +94,32 @@ BaseCPU::BaseCPU(const string &_name, int _number_of_threads, max_insts_all_threads, *counter); } + // allocate per-thread load-based event queues + comLoadEventQueue = new (EventQueue *)[number_of_threads]; + for (int i = 0; i < number_of_threads; ++i) + comLoadEventQueue[i] = new EventQueue("load-based event queue"); + + // + // set up instruction-count-based termination events, if any + // + if (max_loads_any_thread != 0) + for (int i = 0; i < number_of_threads; ++i) + new SimExitEvent(comLoadEventQueue[i], max_loads_any_thread, + "a thread reached the max load count"); + + if (max_loads_all_threads != 0) { + // allocate & initialize shared downcounter: each event will + // decrement this when triggered; simulation will terminate + // when counter reaches 0 + int *counter = new int; + *counter = number_of_threads; + for (int i = 0; i < number_of_threads; ++i) + new CountedExitEvent(comLoadEventQueue[i], + "all threads reached the max load count", + max_loads_all_threads, *counter); + } + + #ifdef FULL_SYSTEM memset(interrupts, 0, sizeof(interrupts)); intstatus = 0; |