From 9471a4d20ffa98ae3f83edbe8cad1d282ab328af Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 5 Nov 2003 17:57:41 -0500 Subject: Fix stats reset make SIGUSR2 dump and reset stats Make resetting time work base/statistics.cc: Fix statistics reset so that it works again, and correctly reset bins as well. (The old code wouldn't reset if you didn't have any bins, and then would actually only reset the first bin) cpu/simple_cpu/simple_cpu.cc: cpu/simple_cpu/simple_cpu.hh: convert idleCycles/idleFraction into a single Average stat to make reset work more simply sim/main.cc: handle SIGUSR2 to dump and reset stats (SIGUSR1 only dumps them) sim/sim_time.cc: sim/sim_time.hh: Add support for resetting the time --HG-- extra : convert_revision : ea43e03c50c0a4bb826dc0842a8c4fa1a9289e0a --- sim/main.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'sim/main.cc') diff --git a/sim/main.cc b/sim/main.cc index addedbc85..4fb075a2a 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -59,6 +59,7 @@ using namespace std; // See async.h. volatile bool async_event = false; volatile bool async_dump = false; +volatile bool async_dumpreset = false; volatile bool async_exit = false; volatile bool async_io = false; volatile bool async_alarm = false; @@ -71,6 +72,13 @@ dumpStatsHandler(int sigtype) async_dump = true; } +void +dumprstStatsHandler(int sigtype) +{ + async_event = true; + async_dumpreset = true; +} + /// Exit signal handler. void exitNowHandler(int sigtype) @@ -219,8 +227,9 @@ main(int argc, char **argv) signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths signal(SIGPIPE, SIG_IGN); signal(SIGTRAP, SIG_IGN); - signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats - signal(SIGINT, exitNowHandler); // dump final stats and exit + signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats + signal(SIGUSR2, dumprstStatsHandler); // dump and reset stats + signal(SIGINT, exitNowHandler); // dump final stats and exit sayHello(cerr); @@ -405,6 +414,13 @@ main(int argc, char **argv) SetupEvent(Dump, curTick); } + if (async_dumpreset) { + async_dumpreset = false; + + using namespace Statistics; + SetupEvent(Dump | Reset, curTick); + } + if (async_exit) { async_exit = false; new SimExitEvent("User requested STOP"); -- cgit v1.2.3