| 1 | |
| 2 | #include <pthread.h> |
| 3 | #include <stdio.h> |
| 4 | #include <unistd.h> |
| 5 | #include <stdlib.h> |
| 6 | |
| 7 | #include "lttng_usertrace.h" |
| 8 | |
| 9 | |
| 10 | |
| 11 | void *thr1(void *arg) |
| 12 | { |
| 13 | lttng_thread_init(); |
| 14 | printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
| 15 | |
| 16 | while(1) {} |
| 17 | |
| 18 | return ((void*)1); |
| 19 | |
| 20 | } |
| 21 | |
| 22 | void *thr2(void *arg) |
| 23 | { |
| 24 | lttng_thread_init(); |
| 25 | |
| 26 | while(1) { |
| 27 | printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
| 28 | sleep(2); |
| 29 | } |
| 30 | return ((void*)2); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | int err; |
| 37 | pthread_t tid1, tid2; |
| 38 | void *tret; |
| 39 | |
| 40 | printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
| 41 | err = pthread_create(&tid1, NULL, thr1, NULL); |
| 42 | if(err!=0) exit(1); |
| 43 | |
| 44 | err = pthread_create(&tid2, NULL, thr2, NULL); |
| 45 | if(err!=0) exit(1); |
| 46 | |
| 47 | while(1) |
| 48 | { |
| 49 | |
| 50 | } |
| 51 | |
| 52 | err = pthread_join(tid1, &tret); |
| 53 | if(err!= 0) exit(1); |
| 54 | |
| 55 | err = pthread_join(tid2, &tret); |
| 56 | if(err!= 0) exit(1); |
| 57 | |
| 58 | return 0; |
| 59 | } |