Mercurial > hg > Members > taiki > cbc_test
diff 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 |
line wrap: on
line diff
--- a/cbc_thread/cbc_thread_test.c Sat Dec 29 12:02:56 2012 +0900 +++ b/cbc_thread/cbc_thread_test.c Tue Jan 08 12:34:40 2013 +0900 @@ -2,7 +2,39 @@ #include <stdlib.h> #include <pthread.h> -int main() +typedef struct _DS { + int thread_no; + int *data; +} DS; + +__code start1() +{ + printf("into cs \n"); +} + +void start(void *arg) { + DS *ds = (DS*)arg; + printf("thread%d:\t%d\n", ds->thread_no, ds->data[0]); + goto start1(); +} + + +int main(int argc, char* argv[]) +{ + pthread_t handle; + DS ds; + + int data[2]; + + int i=0; + for (; i < 2; i++) data [i] = i; + + ds.thread_no = 1; + ds.data = data; + + pthread_create(&handle, NULL, (void*)start, (void*)&ds); + + pthread_join(handle, NULL); return 0; }