From: Subrata Modak <subrata@linux.vnet.ibm.com>
To: Darren Hart <dvhltc@us.ibm.com>
Cc: gowrishankar.m@in.ibm.com,
ltp-list <ltp-list@lists.sourceforge.net>,
Paul McKenney <paulmck@linux.vnet.ibm.com>
Subject: Re: [LTP] [PATCH][realtime] Use librttest arg parsing and init_pi_mutex
Date: Tue, 25 Aug 2009 15:28:20 +0530 [thread overview]
Message-ID: <1251194300.5534.26.camel@subratamodak.linux.ibm.com> (raw)
In-Reply-To: <4A931047.7030000@us.ibm.com>
On Mon, 2009-08-24 at 15:12 -0700, Darren Hart wrote:
> Use librttest arg parsing and init_pi_mutex
>
> This patch converts pthread_cond_many to use the librttest infrastructure
> for argument parsing and mutex initialization. The default behavior of the
> test changes from using a non-pi mutex to a pi mutex. This is because -p
> defaults to 1 in librttest. We could update run.sh with -p0, but I feel
> inside a realtime testsuite this test should be using PI mutexes anyway.
>
> Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
OK. Thanks.
Regards--
Subrata
> Acked-by: Gowrishankar <gowrishankar.m@in.ibm.com>
> CC: Paul McKenney <paulmck@linux.vnet.ibm.com>
>
> Index: realtime/perf/latency/pthread_cond_many.c
> ===================================================================
> --- realtime.orig/perf/latency/pthread_cond_many.c 2009-08-03 14:47:01.000000000 -0700
> +++ realtime/perf/latency/pthread_cond_many.c 2009-08-03 14:51:01.000000000 -0700
> @@ -24,12 +24,12 @@
> *
> * USAGE:
> * Use run_auto.sh script in current directory to build and run test.
> - * Use "-j" to enable jvm simulator.
> *
> * AUTHOR
> * Paul E. McKenney <paulmck@us.ibm.com>
> *
> * HISTORY
> + * librttest parsing, threading, and mutex initialization - Darren Hart
> *
> *
> *****************************************************************************/
> @@ -46,10 +46,12 @@
> #include <librttest.h>
> #include <libstats.h>
> #define PASS_US 100
> -pthread_mutex_t child_mutex = PTHREAD_MUTEX_INITIALIZER;
> +pthread_mutex_t child_mutex;
> volatile int *child_waiting = NULL;
> double endtime;
> pthread_cond_t *condlist = NULL;
> +int iterations = 0;
> +int nthreads = 0;
> int realtime = 0;
> int broadcast_flag = 0;
> unsigned long latency = 0;
> @@ -242,42 +244,68 @@
> printf("Standard Deviation: %f\n", stats_stddev(&dat));
> }
>
> -void
> -usage(char *progname)
> +void usage(void)
> {
> - fprintf(stderr,
> - "Usage: %s [--realtime] [--broadcast] iterations nthreads\n",
> - progname);
> - printf("currently options are not supported\n");
> - exit(-1);
> + rt_help();
> + printf("pthread_cond_many specific options:\n");
> + printf(" -r,--realtime run with realtime priority\n");
> + printf(" -b,--broadcast use cond_broadcast instead of cond_signal\n");
> + printf(" -iITERATIONS iterations (required)\n");
> + printf(" -nNTHREADS number of threads (required)\n");
> + printf("deprecated unnamed arguments:\n");
> + printf(" pthread_cond_many [options] iterations nthreads\n");
> +}
> +
> +int parse_args(int c, char *v)
> +{
> + int handled;
> + switch (c) {
> + case 'h':
> + usage();
> + exit(0);
> + case 'a':
> + broadcast_flag = 1;
> + break;
> + case 'i':
> + iterations = atoi(v);
> + break;
> + case 'n':
> + nthreads = atoi(v);
> + break;
> + case 'r':
> + realtime = 1;
> + break;
> + default:
> + handled = 0;
> + break;
> + }
> + return handled;
> }
>
> int
> main(int argc, char *argv[])
> {
> - int i = 1;
> - long iter;
> - long nthreads;
> + struct option longopts[] = {
> + {"broadcast", 0, NULL, 'a'},
> + {"realtime", 0, NULL, 'r'},
> + {NULL, 0, NULL, 0},
> + };
> setup();
>
> - while (i < argc) {
> - if (strcmp(argv[i], "--realtime") == 0) {
> - realtime = 1;
> - i++;
> - } else if (strcmp(argv[i], "--broadcast") == 0) {
> - broadcast_flag = 1;
> - i++;
> - } else if (argv[i][0] == '-') {
> - usage(argv[0]);
> - } else {
> - break;
> - }
> - }
> - if (argc - i < 2) {
> - usage(argv[0]);
> + init_pi_mutex(&child_mutex);
> + rt_init_long("ahi:n:r", longopts, parse_args, argc, argv);
> +
> + /* Legacy command line arguments support, overrides getopt args. */
> + if (optind < argc)
> + iterations = strtol(argv[optind++], NULL, 0);
> + if (optind < argc)
> + nthreads = strtol(argv[optind++], NULL, 0);
> +
> + /* Ensure we have the required arguments. */
> + if (iterations == 0 || nthreads == 0) {
> + usage();
> + exit(1);
> }
> - iter = strtol(argv[i], NULL, 0);
> - nthreads = strtol(argv[i + 1], NULL, 0);
>
> child_waiting = (int *)malloc(sizeof(*child_waiting) * nthreads);
> condlist = (pthread_cond_t *)malloc(sizeof(*condlist) * nthreads);
> @@ -285,7 +313,7 @@
> fprintf(stderr, "Out of memory\n");
> exit(-1);
> }
> - test_signal(iter, nthreads);
> + test_signal(iterations, nthreads);
> printf("\nCriteria: latencies < %d us\n", PASS_US);
> printf("Result: %s\n", fail ? "FAIL" : "PASS");
> return 0;
> Index: realtime/perf/latency/run.sh
> ===================================================================
> --- realtime.orig/perf/latency/run.sh 2009-08-03 14:47:01.000000000 -0700
> +++ realtime/perf/latency/run.sh 2009-08-03 14:47:33.000000000 -0700
> @@ -35,11 +35,11 @@
> rm -f $nthread.$iter.$nproc.*.out
>
> i=0
> -./pthread_cond_many --realtime --broadcast $iter $nthread > $nthread.$iter.$nproc.$i.out &
> +./pthread_cond_many --realtime --broadcast -i $iter -n $nthread > $nthread.$iter.$nproc.$i.out &
> i=1
> while test $i -lt $nproc
> do
> - ./pthread_cond_many --broadcast $iter $nthread > $nthread.$iter.$nproc.$i.out &
> + ./pthread_cond_many --broadcast -i $iter -n $nthread > $nthread.$iter.$nproc.$i.out &
> i=`expr $i + 1`
> done
> wait
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
prev parent reply other threads:[~2009-08-25 9:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-24 22:12 [LTP] [PATCH][realtime] Use librttest arg parsing and init_pi_mutex Darren Hart
2009-08-25 9:58 ` Subrata Modak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1251194300.5534.26.camel@subratamodak.linux.ibm.com \
--to=subrata@linux.vnet.ibm.com \
--cc=dvhltc@us.ibm.com \
--cc=gowrishankar.m@in.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=paulmck@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox