b8b00688 |
1 | |
92f441a7 |
2 | #include <pthread.h> |
3 | #include <stdio.h> |
4 | #include <unistd.h> |
5 | #include <stdlib.h> |
6 | |
b8b00688 |
7 | #include "lttng_usertrace.h" |
8 | |
92f441a7 |
9 | |
10 | |
11 | void *thr1(void *arg) |
12 | { |
1a1e2a8c |
13 | lttng_thread_init(); |
92f441a7 |
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 | { |
1a1e2a8c |
24 | lttng_thread_init(); |
25 | |
92f441a7 |
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 | |
b8b00688 |
34 | int main() |
35 | { |
92f441a7 |
36 | int err; |
37 | pthread_t tid1, tid2; |
38 | void *tret; |
39 | |
1a1e2a8c |
40 | printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
92f441a7 |
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); |
b8b00688 |
46 | |
47 | while(1) |
48 | { |
49 | |
50 | } |
92f441a7 |
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); |
b8b00688 |
57 | |
58 | return 0; |
59 | } |