Mercurial > hg > Members > masakoha > testcode
changeset 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 | 645b93cbf36c |
files | parallel_processing/ppb_first_thread/ppb_first_thread.cc |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/parallel_processing/ppb_first_thread/ppb_first_thread.cc Thu Jan 02 16:57:28 2014 +0900 +++ b/parallel_processing/ppb_first_thread/ppb_first_thread.cc Fri Jan 03 01:36:18 2014 +0900 @@ -29,15 +29,19 @@ int data[DATA_NUM]; int i; + /* initialize */ for (i = 0; i < DATA_NUM; i++) data[i] = i; + /* spawn thread a number of THREAD_NUM */ for (i = 0; i < THREAD_NUM; i++) { targ[i].thread_no = i; targ[i].data = data; + /* spawn thread*/ pthread_create(&handle[i], NULL, &thread_func, (void*)&targ[i]); } + /* wait for running all thread */ for (i = 0; i < THREAD_NUM; i++) pthread_join(handle[i], NULL); return 0; }