Mercurial > hg > Members > taiki > cbc_test
comparison cbc_thread/cbc_thread_test.c @ 9:2ce34a5ff69b default tip
add pointer test
author | taiki |
---|---|
date | Tue, 08 Jan 2013 12:34:40 +0900 |
parents | 1d2839ecabda |
children |
comparison
equal
deleted
inserted
replaced
8:1d2839ecabda | 9:2ce34a5ff69b |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <pthread.h> | 3 #include <pthread.h> |
4 | 4 |
5 int main() | 5 typedef struct _DS { |
6 int thread_no; | |
7 int *data; | |
8 } DS; | |
9 | |
10 __code start1() | |
6 { | 11 { |
12 printf("into cs \n"); | |
13 } | |
14 | |
15 void start(void *arg) | |
16 { | |
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); | |
7 return 0; | 39 return 0; |
8 } | 40 } |