Mercurial > hg > Members > masakoha > testcode
comparison parallel_processing/ppb_first_thread/ppb_first_thread.cc @ 7:edf4445da580
add comment
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 03 Jan 2014 01:36:18 +0900 |
parents | 7b0b23f3538d |
children |
comparison
equal
deleted
inserted
replaced
6:7b0b23f3538d | 7:edf4445da580 |
---|---|
27 pthread_t handle[THREAD_NUM]; | 27 pthread_t handle[THREAD_NUM]; |
28 thread_arg_t targ[THREAD_NUM]; | 28 thread_arg_t targ[THREAD_NUM]; |
29 int data[DATA_NUM]; | 29 int data[DATA_NUM]; |
30 int i; | 30 int i; |
31 | 31 |
32 /* initialize */ | |
32 for (i = 0; i < DATA_NUM; i++) data[i] = i; | 33 for (i = 0; i < DATA_NUM; i++) data[i] = i; |
33 | 34 |
35 /* spawn thread a number of THREAD_NUM */ | |
34 for (i = 0; i < THREAD_NUM; i++) { | 36 for (i = 0; i < THREAD_NUM; i++) { |
35 targ[i].thread_no = i; | 37 targ[i].thread_no = i; |
36 targ[i].data = data; | 38 targ[i].data = data; |
37 | 39 |
40 /* spawn thread*/ | |
38 pthread_create(&handle[i], NULL, &thread_func, (void*)&targ[i]); | 41 pthread_create(&handle[i], NULL, &thread_func, (void*)&targ[i]); |
39 } | 42 } |
40 | 43 |
44 /* wait for running all thread */ | |
41 for (i = 0; i < THREAD_NUM; i++) pthread_join(handle[i], NULL); | 45 for (i = 0; i < THREAD_NUM; i++) pthread_join(handle[i], NULL); |
42 return 0; | 46 return 0; |
43 } | 47 } |