[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ltp-list
Subject:    Re: [LTP] PATCH[3/3] Use librttest infrastructure [ tc-2]
From:       Subrata Modak <subrata () linux ! vnet ! ibm ! com>
Date:       2008-02-28 9:23:50
Message-ID: 1204189910.4611.11.camel () subratamodak ! linux ! ibm ! com
[Download RAW message or body]

On Wed, 2008-02-27 at 15:36 +0100, Sebastien Dugue wrote:
> On Wed, 27 Feb 2008 19:35:40 +0530 Chirag Jog <chirag@linux.vnet.ibm.com> wrote:
> 
> > * Sebastien Dugue <sebastien.dugue@bull.net> [2008-02-27 14:37:28]:
> > 
> > > 
> > > Hi Chirag,
> > > 
> > > your patch subtly breaks the test in that when using the create_xx_thread()
> > > functions, the pthr->id member is derived from the global atomic counter
> > > _thread_count and is not the tread function argument passed to \
> > > create_xx_thread(). 
> > > For example, with your patch, we have the following:
> > > 
> > > 
> > > Sleeper thread 0 sleeping
> > > Sleeper thread 1 sleeping
> > > Sleeper thread 2 sleeping
> > > Sleeper thread 3 sleeping
> > > Sleeper thread 4 sleeping
> > > 
> > > Worker thread 5 working
> > > Worker thread 6 working
> > > 
> > > Therefore you cannot use pthr->id as an index into the sleepts[] and
> > > workts[] arrays.
> > > 
> > > One way is to use instead:
> > > 
> > > 	int tid = (int)(long)pthr->arg;
> > > 
> > > in place of
> > > 
> > > 	int tid = pthr->id;
> > 
> > Ack, Suprisingly I missed that.
> > Don't know what I am smoking today ;)
> 
> I know the feeling.
> 
> > 
> > Here is the patch that fixes it.
> > 
> > Signed-Off-By: Chirag <chirag@linux.vnet.ibm.com>
> 
> Acked-By: Sebastien Dugue <sebastien.dugue@bull.net>

And so also does this one. Merged. Thanks.

--Subrata

> 
> 
> > 
> > tc-2.c |   28 +++++++++++-----------------
> > 1 file changed, 11 insertions(+), 17 deletions(-)
> > 
> > 
> > diff --git a/testcases/realtime/func/thread_clock/tc-2.c \
> > b/testcases/realtime/func/thread_clock/tc-2.c index a21de96..56bc7b1 100644
> > --- a/testcases/realtime/func/thread_clock/tc-2.c
> > +++ b/testcases/realtime/func/thread_clock/tc-2.c
> > @@ -54,12 +54,11 @@
> > 
> > #define NS_PER_SEC 1000000000
> > #define THRESHOLD 0.5  /* 500 milliseconds */
> > -
> > #define NUMSLEEP 5
> > #define NUMWORK 2
> > +
> > struct timespec sleepts[NUMSLEEP];
> > struct timespec workts[NUMWORK];
> > -
> > static int run_jvmsim=0;
> > 
> > void usage(void)
> > @@ -99,7 +98,8 @@ void work(void)
> > 
> > void *workerthread(void *arg)
> > {
> > -	int tid = (intptr_t)arg;
> > +	struct thread* pthr = (struct thread* )arg;
> > +	int tid =(int)(long)pthr->arg;
> > 	struct timespec *ts = &workts[tid];
> > 
> > #ifdef DEBUG
> > @@ -121,7 +121,8 @@ void *workerthread(void *arg)
> > 
> > void *sleeperthread(void *arg)
> > {
> > -	int tid = (intptr_t)arg;
> > +	struct thread* pthr = (struct thread* )arg;
> > +	int tid = (int)(long)pthr->arg;
> > 	struct timespec *ts = &sleepts[tid];
> > 
> > #ifdef DEBUG
> > @@ -173,13 +174,14 @@ int checkresult(float proctime)
> > 		printf("FAIL\n");
> > 		retval = 1;
> > 	}
> > -	printf("PASS\n");
> > +	else {
> > +		printf("PASS\n");
> > +	}
> > 	return retval;
> > }
> > 
> > int main(int argc,char* argv[])
> > {
> > -	pthread_t sleepthr[NUMSLEEP], workthr[NUMWORK];
> > 	int i, retval = 0;
> > 	struct timespec myts;
> > 	setup();
> > @@ -195,8 +197,7 @@ int main(int argc,char* argv[])
> > 
> > 	/* Start sleeper threads */
> > 	for (i=0; i<NUMSLEEP; i++) {
> > -		if ((pthread_create (&sleepthr[i], NULL, sleeperthread, (void *)(intptr_t)i)) \
> >                 < 0 ) {
> > -			perror("pthread_create: ");
> > +		if ((create_other_thread (sleeperthread, (void *)(intptr_t)i)) < 0 ) {
> > 			exit(1);
> > 		}
> > 	}
> > @@ -204,8 +205,7 @@ int main(int argc,char* argv[])
> > 
> > 	/* Start worker threads */
> > 	for (i=0; i<NUMWORK; i++) {
> > -		if ((pthread_create (&workthr[i], NULL, workerthread, (void *)(intptr_t)i)) < \
> >                 0 ) {
> > -			perror("pthread_create: ");
> > +		if ((create_other_thread (workerthread, (void *)(intptr_t)i)) < 0 ) {
> > 			exit(1);
> > 		}
> > 	}
> > @@ -213,13 +213,7 @@ int main(int argc,char* argv[])
> > 
> > 	printf("\nPlease wait...\n\n");
> > 
> > -	for (i=0; i<NUMSLEEP; i++) {
> > -		pthread_join(sleepthr[i], NULL);
> > -	}
> > -	for (i=0; i<NUMWORK; i++) {
> > -		pthread_join(workthr[i], NULL);
> > -	}
> > -
> > +	join_threads();
> > 	/* Get the process cpu clock value */
> > 	if ((clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &myts)) < 0) {
> > 		perror("clock_gettime: CLOCK_PROCESS_CPUTIME_ID: ");
> > 
> > -- 
> > Cheers,
> > Chirag Jog
> > 
> > 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic