Mercurial > hg > Game > Cerium
changeset 1843:bf4867621732 draft
merge
author | yuhi |
---|---|
date | Fri, 20 Dec 2013 21:03:38 +0900 |
parents | 17d06be35858 (current diff) 0305732326ca (diff) |
children | 23e84bb83ed2 |
files | example/fileread/ppe/task_init.cc |
diffstat | 4 files changed, 28 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fileread/main.cc Fri Dec 20 20:56:04 2013 +0900 +++ b/example/fileread/main.cc Fri Dec 20 21:03:38 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:56:04 2013 +0900 +++ b/example/fileread/ppe/Read.cc Fri Dec 20 21:03:38 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);
--- a/example/fileread/ppe/task_init.cc Fri Dec 20 20:56:04 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#include "Func.h" -#include "Scheduler.h" - -/* 必ずこの位置に書いて */ -SchedExternTask(Read_task); -SchedExternTask(Print_task); -SchedExternTask(RUN_BLOCKS); - -/** - * この関数は ../spe/spe-main と違って - * 自分で呼び出せばいい関数なので - * 好きな関数名でおk (SchedRegisterTask は必須) - */ - -void -task_init(void) -{ - SchedRegister(Read_task); - SchedRegister(Print_task); - SchedRegister(RUN_BLOCKS); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/fileread/task_init.cc Fri Dec 20 21:03:38 2013 +0900 @@ -0,0 +1,21 @@ +#include "Func.h" +#include "Scheduler.h" + +/* 必ずこの位置に書いて */ +SchedExternTask(Read_task); +SchedExternTask(Print_task); +SchedExternTask(RUN_BLOCKS); + +/** + * この関数は ../spe/spe-main と違って + * 自分で呼び出せばいい関数なので + * 好きな関数名でおk (SchedRegisterTask は必須) + */ + +void +task_init(void) +{ + SchedRegister(Read_task); + SchedRegister(Print_task); + SchedRegister(RUN_BLOCKS); +}