X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=usertrace%2Ftest.c;h=a0509a277bfc63561e004d34d8973519ba8dc842;hb=2d6c6b76f73668703e823a0638e7a67262668aee;hp=0154f3ca7c0d3b6155ae44f91373ac5edb88feb6;hpb=b8b006881f98b1193db5c45ef8f2d054f6b02f39;p=lttv.git diff --git a/usertrace/test.c b/usertrace/test.c index 0154f3ca..a0509a27 100644 --- a/usertrace/test.c +++ b/usertrace/test.c @@ -1,13 +1,59 @@ +#include +#include +#include +#include + #include "lttng_usertrace.h" + + +void *thr1(void *arg) +{ + lttng_thread_init(); + printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + + while(1) {} + + return ((void*)1); + +} + +void *thr2(void *arg) +{ + lttng_thread_init(); + + while(1) { + printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); + sleep(2); + } + return ((void*)2); +} + + int main() { + int err; + pthread_t tid1, tid2; + void *tret; + + 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); while(1) { } + + err = pthread_join(tid1, &tret); + if(err!= 0) exit(1); + + err = pthread_join(tid2, &tret); + if(err!= 0) exit(1); return 0; }