[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xenpm: add timeout option to 'xenpm start' command.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1237457399 0 # Node ID cbdc022b003561ba2ed5838aa47a81120f283adf # Parent fe949f9129b00484b0d1a22a5440db0592f9da92 xenpm: add timeout option to 'xenpm start' command. Thus we can sample a fixed time of period without manual interruption. Signed-off-by: Guanqun Lu <guanqun.lu@xxxxxxxxx> --- tools/misc/xenpm.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff -r fe949f9129b0 -r cbdc022b0035 tools/misc/xenpm.c --- a/tools/misc/xenpm.c Thu Mar 19 10:09:24 2009 +0000 +++ b/tools/misc/xenpm.c Thu Mar 19 10:09:59 2009 +0000 @@ -59,8 +59,8 @@ void show_help(void) " set-up-threshold [cpuid] <num> set up threshold on CPU <cpuid> or all\n" " it is used in ondemand governor.\n" " get-cpu-topology get thread/core/socket topology info\n" - " start start collect Cx/Px statistics,\n" - " output after CTRL-C or SIGINT.\n" + " start [seconds] start collect Cx/Px statistics,\n" + " output after CTRL-C or SIGINT or several seconds.\n" ); } /* wrapper function */ @@ -353,6 +353,16 @@ void start_gather_func(int argc, char *a { int i; struct timeval tv; + int timeout = 0; + + if ( argc == 1 ) + { + sscanf(argv[0], "%d", &timeout); + if ( timeout <= 0 ) + fprintf(stderr, "failed to set timeout seconds, falling back...\n"); + else + printf("Timeout set to %d seconds\n", timeout); + } if ( gettimeofday(&tv, NULL) == -1 ) { @@ -408,7 +418,21 @@ void start_gather_func(int argc, char *a free(cxstat); return ; } - printf("Start sampling, waiting for CTRL-C or SIGINT signal ...\n"); + + if ( timeout > 0 ) + { + if ( signal(SIGALRM, signal_int_handler) == SIG_ERR ) + { + fprintf(stderr, "failed to set signal alarm handler\n"); + free(sum); + free(pxstat); + free(cxstat); + return ; + } + alarm(timeout); + } + + printf("Start sampling, waiting for CTRL-C or SIGINT or SIGALARM signal ...\n"); pause(); } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |