8
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <pthread.h>
|
|
4
|
9
|
5 typedef struct _DS {
|
|
6 int thread_no;
|
|
7 int *data;
|
|
8 } DS;
|
|
9
|
|
10 __code start1()
|
|
11 {
|
|
12 printf("into cs \n");
|
|
13 }
|
|
14
|
|
15 void start(void *arg)
|
8
|
16 {
|
9
|
17 DS *ds = (DS*)arg;
|
|
18 printf("thread%d:\t%d\n", ds->thread_no, ds->data[0]);
|
|
19 goto start1();
|
|
20 }
|
|
21
|
|
22
|
|
23 int main(int argc, char* argv[])
|
|
24 {
|
|
25 pthread_t handle;
|
|
26 DS ds;
|
|
27
|
|
28 int data[2];
|
|
29
|
|
30 int i=0;
|
|
31 for (; i < 2; i++) data [i] = i;
|
|
32
|
|
33 ds.thread_no = 1;
|
|
34 ds.data = data;
|
|
35
|
|
36 pthread_create(&handle, NULL, (void*)start, (void*)&ds);
|
|
37
|
|
38 pthread_join(handle, NULL);
|
8
|
39 return 0;
|
|
40 }
|