Hi Chirag,

  some comments

On Mon, 25 Feb 2008 15:04:19 +0530 Chirag Jog <[EMAIL PROTECTED]> wrote:

> Hi,
>         The thread-clock test doesn't use the librttest
>         infrastructure. This patch ensures that it does.
> 
> tc-2.c |   19 ++++++-------------
> 1 file changed, 6 insertions(+), 13 deletions(-)
> 
> Signed-Off-By: Chirag <[EMAIL PROTECTED]>
> 
> 
> diff --git a/testcases/realtime/func/thread_clock/tc-2.c 
> b/testcases/realtime/func/thread_clock/tc-2.c
> index a21de96..e7ead1f 100644
> --- a/testcases/realtime/func/thread_clock/tc-2.c
> +++ b/testcases/realtime/func/thread_clock/tc-2.c
> @@ -51,7 +51,7 @@
>  #include <unistd.h>
>  #include <librttest.h>
>  #include <libjvmsim.h>
> -
> +#define DEBUG

  Uh, what for? Might be better to convert all the #ifdef DEBUG traces to
using the debug() macro with a DBG_DEBUG loglevel.

>  #define NS_PER_SEC 1000000000
>  #define THRESHOLD 0.5  /* 500 milliseconds */
>  
> @@ -179,7 +179,6 @@ int checkresult(float proctime)
>  
>  int main(int argc,char* argv[])
>  {
> -     pthread_t sleepthr[NUMSLEEP], workthr[NUMWORK];
>       int i, retval = 0;
>       struct timespec myts;
>       setup();
> @@ -195,8 +194,8 @@ 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 ) {
> +                     perror("create_other_thread: ");

  Again, errno might not be what you think it is at this point.

>                       exit(1);
>               }
>       }
> @@ -204,8 +203,8 @@ 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 ) {
> +                     perror("create_other_thread: ");
>                       exit(1);
>               }
>       }
> @@ -213,13 +212,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

Reply via email to