Mercurial > hg > Game > Cerium
changeset 1865:a009522ed6c6 draft
add FileRead.h
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Dec 2013 23:52:54 +0900 |
parents | 7211816380bd |
children | 7b3aa1a31c3a |
files | example/fileread/FileRead.h example/fileread/main.cc example/fileread/ppe/Print.cc |
diffstat | 3 files changed, 29 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/fileread/FileRead.h Tue Dec 24 23:52:54 2013 +0900 @@ -0,0 +1,13 @@ + +typedef struct fileRead { + struct fileRead *self; + long fd; + long division_size; + long task_number; + long task_num; + long filesize; + long left_size; + int task_blocks; + char *read_text; + CPU_TYPE cpu; +} FileRead, *FileReadPtr;
--- a/example/fileread/main.cc Tue Dec 24 19:16:49 2013 +0900 +++ b/example/fileread/main.cc Tue Dec 24 23:52:54 2013 +0900 @@ -8,6 +8,7 @@ #include "TaskManager.h" #include "SchedTask.h" #include "Func.h" +#include "FileRead.h" extern void task_init(void); @@ -22,17 +23,6 @@ const char *usr_help_str = "Usage: ./fileread [-cpu cpu_num] [-file filename]\n\ -cpu Number of SPE (default 1) \n\ -file Opne file\n"; -typedef struct fileread { - struct fileread *self; - long fd; - long division_size; - long task_number; - long task_num; - long filesize; - long left_size; - int task_blocks; - CPU_TYPE cpu; -} Fileread, *FilereadPtr; typedef struct { caddr_t file_mmap; @@ -44,7 +34,7 @@ static int run16(SchedTask *manager, void *in, void *out) { - FilereadPtr fr = (FilereadPtr)in; + FileReadPtr fr = (FileReadPtr)in; HTaskPtr wait; for (int i = 0; (fr->left_size > 0) && (i < fr->task_blocks); i++) { @@ -122,7 +112,7 @@ my_mmap(SchedTask *s, void *in, void *out) { - FilereadPtr fr = (FilereadPtr)in; + FileReadPtr fr = (FileReadPtr)in; /*マッピングだよ!*/ int map = MAP_PRIVATE; @@ -130,7 +120,7 @@ int fd = fr->fd; st_mmap.size = fr->filesize; - st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0); + out = mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0); if (st_mmap.file_mmap == (caddr_t)-1) { fprintf(stderr,"Can't mmap file\n"); @@ -138,7 +128,7 @@ exit(0); } - //printf("%s\n",st_mmap.file_mmap); + //printf("%s\n",out); printf("in mmap\n"); return 0; @@ -159,7 +149,7 @@ fprintf(stderr,"can't fstat %s\n",filename); } - FilereadPtr fr = (FilereadPtr)manager->allocate(sizeof(Fileread)); + FileReadPtr fr = (FileReadPtr)manager->allocate(sizeof(FileRead)); fr->self = fr; fr->fd = fd; @@ -175,14 +165,19 @@ printf("one_task_size: %ld\n",fr->division_size); printf("task_num : %ld\n",fr->task_num); + HTaskPtr run = NULL; + HTaskPtr t_print = manager->create_task(Print_task, (memaddr)&fr->self, sizeof(memaddr),0,0); + if (divide_read_flag != 0) { - HTaskPtr run = manager->create_task(RUN_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); - run->spawn(); + run = manager->create_task(RUN_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),fr->read_text,fr->filesize); }else { //my_mmap(filename, fd, fr); - HTaskPtr run = manager->create_task(MMAP , (memaddr)&fr->self, sizeof(memaddr),0,0); - run->spawn(); + run = manager->create_task(MMAP , (memaddr)&fr->self, sizeof(memaddr),fr->read_text,fr->filesize); } + t_print->wait_for(run); + run->spawn(); + + t_print->spawn(); }
--- a/example/fileread/ppe/Print.cc Tue Dec 24 19:16:49 2013 +0900 +++ b/example/fileread/ppe/Print.cc Tue Dec 24 23:52:54 2013 +0900 @@ -7,7 +7,7 @@ SchedDefineTask1(Print_task,print_task); static int -print_task(SchedTask *smanager, void *rbuf, void *wbuf) +print_task(SchedTask *s, void *rbuf, void *wbuf) { //int task_id = (long)smanager->get_param(0);