X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt-usertrace%2Fsample-thread-slow.c;h=343332f7d44c0ca82908ebe953e8548524e0704f;hb=6b0817c24e1c10e5e957e2bca73844a4bf88146c;hp=d98c86f5487fdc91c55b5a87ca5f923de2955ac7;hpb=45895deef51904d66a49b1aa6203e3930cea5461;p=lttv.git diff --git a/ltt-usertrace/sample-thread-slow.c b/ltt-usertrace/sample-thread-slow.c index d98c86f5..343332f7 100644 --- a/ltt-usertrace/sample-thread-slow.c +++ b/ltt-usertrace/sample-thread-slow.c @@ -11,26 +11,26 @@ void *thr1(void *arg) { - printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); - while(1) { + while(1) { trace_user_generic_string("Hello world! Have a nice day."); sleep(2); } - - return ((void*)1); - + pthread_exit((void*)1); } + +/* Example of a _bad_ thread, which still works with the tracing */ void *thr2(void *arg) { - printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); sleep(1); - while(1) { + while(1) { trace_user_generic_string("Hello world! Have a nice day."); - sleep(2); - } - return ((void*)2); + sleep(2); + } + return ((void*)2); } @@ -42,21 +42,21 @@ int main() printf("Will trace the following string : Hello world! Have a nice day.\n"); printf("Press CTRL-C to stop.\n"); - printf("No file is created with this example : it logs through a kernel\n"); - printf("system call. See the LTTng lttctl command to start tracing.\n\n"); + printf("No file is created with this example : it logs through a kernel\n"); + printf("system call. See the LTTng lttctl command to start tracing.\n\n"); - printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid()); - err = pthread_create(&tid1, NULL, thr1, NULL); - if(err!=0) exit(1); + printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + err = pthread_create(&tid1, NULL, thr1, NULL); + if(err!=0) exit(1); - err = pthread_create(&tid2, NULL, thr2, NULL); - if(err!=0) exit(1); + err = pthread_create(&tid2, NULL, thr2, NULL); + if(err!=0) exit(1); - err = pthread_join(tid1, &tret); - if(err!= 0) exit(1); + err = pthread_join(tid1, &tret); + if(err!= 0) exit(1); - err = pthread_join(tid2, &tret); - if(err!= 0) exit(1); - - return 0; + err = pthread_join(tid2, &tret); + if(err!= 0) exit(1); + + return 0; }