Mercurial > hg > Game > Cerium
changeset 1840:0305732326ca draft
change *fd to fd & change set_inData to set_param
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Dec 2013 20:08:59 +0900 |
parents | f71b722001dd |
children | bf4867621732 |
files | example/fileread/main.cc example/fileread/ppe/Read.cc |
diffstat | 2 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fileread/main.cc Fri Dec 20 20:00:31 2013 +0900 +++ b/example/fileread/main.cc Fri Dec 20 20:08:59 2013 +0900 @@ -21,7 +21,7 @@ -file Opne file\n"; typedef struct fileread { struct filesize *self; - int *fd; + long fd; long division_size; long task_number; long task_num; @@ -45,8 +45,6 @@ if (i == fr->task_blocks / 2) wait = read; - //ファイルディスクリプタをそのままタスクに渡してあげる - read->set_inData(0,fr->fd,sizeof(int*)); read->set_param(0,(long)fr->task_number); //生成するTaskが何番目か read->set_param(1,(long)fr->division_size); //1つのタスクが読み込む量 @@ -55,6 +53,7 @@ }else{ read->set_param(2,(long)fr->division_size); } + read->set_param(3,(long)fr->fd); //fdの番号の受け渡し read->spawn(); fr->left_size -= fr->division_size; @@ -109,14 +108,14 @@ static void run_start(TaskManager *manager,char *filename) { - int *fd = (int*)manager->allocate(sizeof(int)); + long fd = (long)manager->allocate(sizeof(long)); struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat)); - if ((*fd=open(filename,O_RDONLY,0666))==0) { + if ((fd=open(filename,O_RDONLY,0666))==0) { fprintf(stderr,"can't open %s\n",filename); } - if (fstat(*fd,sb)) { + if (fstat(fd,sb)) { fprintf(stderr,"can't fstat %s\n",filename); }
--- a/example/fileread/ppe/Read.cc Fri Dec 20 20:00:31 2013 +0900 +++ b/example/fileread/ppe/Read.cc Fri Dec 20 20:08:59 2013 +0900 @@ -16,11 +16,10 @@ static int read_task(SchedTask *s, void *rbuf, void *wbuf) { - int *fd = (int *)s->get_input(rbuf,0); ///ファイルディスクリプタの受取 - long task_number = (long)s->get_param(0); //何番目のtaskか long division_size = (long)s->get_param(1); long read_size = (long)s->get_param(2); + long fd = (long)s->get_param(3); char text[(long)read_size]; text[(long)read_size + 1] = '\0'; @@ -28,7 +27,7 @@ //lseek(*fd, division_size* task_number,SEEK_SET); //lseekでどこから読み込むのか指定 //read(*fd,text,(long)read_size); - pread(*fd, text, (long)read_size , division_size*task_number); + pread(fd, text, (long)read_size , division_size*task_number); s->printf("[start task No. %d]\n",task_number); s->printf("%s\n",text);