b09f3215 |
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 | { |
b09f3215 |
13 | printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
14 | |
15 | while(1) {} |
16 | |
17 | return ((void*)1); |
18 | |
19 | } |
20 | |
21 | void *thr2(void *arg) |
22 | { |
b09f3215 |
23 | while(1) { |
24 | printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
25 | sleep(2); |
26 | } |
27 | return ((void*)2); |
28 | } |
29 | |
30 | |
31 | int main() |
32 | { |
33 | int err; |
34 | pthread_t tid1, tid2; |
35 | void *tret; |
36 | |
37 | printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
38 | err = pthread_create(&tid1, NULL, thr1, NULL); |
39 | if(err!=0) exit(1); |
40 | |
41 | err = pthread_create(&tid2, NULL, thr2, NULL); |
42 | if(err!=0) exit(1); |
43 | |
44 | while(1) |
45 | { |
46 | |
47 | } |
48 | |
49 | err = pthread_join(tid1, &tret); |
50 | if(err!= 0) exit(1); |
51 | |
52 | err = pthread_join(tid2, &tret); |
53 | if(err!= 0) exit(1); |
54 | |
55 | return 0; |
56 | } |