From: compudj Date: Thu, 9 Mar 2006 21:10:23 +0000 (+0000) Subject: new ltt-usertrace X-Git-Tag: v0.12.20~1843 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=45895deef51904d66a49b1aa6203e3930cea5461;p=lttv.git new ltt-usertrace git-svn-id: http://ltt.polymtl.ca/svn@1646 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt-usertrace/sample-thread-slow.c b/ltt-usertrace/sample-thread-slow.c new file mode 100644 index 00000000..d98c86f5 --- /dev/null +++ b/ltt-usertrace/sample-thread-slow.c @@ -0,0 +1,62 @@ + +#include +#include +#include +#include + +#define LTT_TRACE +//this one is a non blocking sample (not #define LTT_BLOCKING 1) +#include + + +void *thr1(void *arg) +{ + printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + + while(1) { + trace_user_generic_string("Hello world! Have a nice day."); + sleep(2); + } + + return ((void*)1); + +} + +void *thr2(void *arg) +{ + printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + sleep(1); + while(1) { + trace_user_generic_string("Hello world! Have a nice day."); + sleep(2); + } + return ((void*)2); +} + + +int main() +{ + int err; + pthread_t tid1, tid2; + void *tret; + + 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("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_join(tid1, &tret); + if(err!= 0) exit(1); + + err = pthread_join(tid2, &tret); + if(err!= 0) exit(1); + + return 0; +} diff --git a/ltt-usertrace/sample-thread.c b/ltt-usertrace/sample-thread.c deleted file mode 100644 index d98c86f5..00000000 --- a/ltt-usertrace/sample-thread.c +++ /dev/null @@ -1,62 +0,0 @@ - -#include -#include -#include -#include - -#define LTT_TRACE -//this one is a non blocking sample (not #define LTT_BLOCKING 1) -#include - - -void *thr1(void *arg) -{ - printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); - - while(1) { - trace_user_generic_string("Hello world! Have a nice day."); - sleep(2); - } - - return ((void*)1); - -} - -void *thr2(void *arg) -{ - printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); - sleep(1); - while(1) { - trace_user_generic_string("Hello world! Have a nice day."); - sleep(2); - } - return ((void*)2); -} - - -int main() -{ - int err; - pthread_t tid1, tid2; - void *tret; - - 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("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_join(tid1, &tret); - if(err!= 0) exit(1); - - err = pthread_join(tid2, &tret); - if(err!= 0) exit(1); - - return 0; -}