Mercurial > hg > Game > Cerium
changeset 1912:4a716f35980a draft
remove old my_mmap
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 20 Jan 2014 03:39:03 +0900 |
parents | f842ea419307 |
children | 53c074e60b08 |
files | example/word_count/WordCount.h example/word_count/main.cc |
diffstat | 2 files changed, 8 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/example/word_count/WordCount.h Sun Jan 19 23:36:02 2014 +0900 +++ b/example/word_count/WordCount.h Mon Jan 20 03:39:03 2014 +0900 @@ -28,5 +28,6 @@ char * file_mmap; int file_size; HTaskPtr t_print; + HTaskPtr t_exec; } WordCount, *WordCountPtr;
--- a/example/word_count/main.cc Sun Jan 19 23:36:02 2014 +0900 +++ b/example/word_count/main.cc Mon Jan 20 03:39:03 2014 +0900 @@ -82,7 +82,8 @@ read->set_outData(0,read_text + w->read_task_number*w->read_division_size, w->read_division_size); - w->t_print->wait_for(read); + w->t_print->wait_for(w->t_exec); + w->t_exec->wait_for(read); read->spawn(); w->read_left_size -= w->read_division_size; @@ -94,6 +95,7 @@ HTaskPtr next = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),read_text,w->read_filesize); w->t_print->wait_for(next); + w->t_exec->wait_for(next); next->wait_for(wait); next->spawn(); } @@ -126,42 +128,6 @@ return 0; } -//static st_mmap_t -//my_mmap(char *filename) -//{ -// -// /*マッピングだよ!*/ -// int fd = -1; -// int map = MAP_PRIVATE; -// st_mmap_t st_mmap; -// struct stat sb; -// -// if ((fd=open(filename,O_RDONLY,0666))==0) { -// fprintf(stderr,"can't open %s\n",filename); -// } -// -// if (fstat(fd,&sb)) { -// fprintf(stderr,"can't fstat %s\n",filename); -// } -// -// printf("file size %d\n",(int)sb.st_size); -// -// /*sizeをページングサイズの倍数にあわせる*/ -// st_mmap.size = fix_byte(sb.st_size,4096); -// -// printf("fix 4096byte file size %d\n",(int)st_mmap.size); -// -// st_mmap.file_mmap = (char*)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"); -// perror(NULL); -// exit(0); -// } -// -// return st_mmap; -// -//} - static void run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) { @@ -315,6 +281,7 @@ long fd = (long)manager->allocate(sizeof(long)); struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat)); + HTaskPtr t_exec = NULL; if ((fd=open(filename,O_RDONLY,0666))==0) { fprintf(stderr,"can't open %s\n",filename); @@ -336,6 +303,7 @@ w->read_division_size = READ_DIVISION_SIZE; w->read_task_num = w->read_filesize / READ_DIVISION_SIZE; w->read_task_num += ((w->read_filesize % READ_DIVISION_SIZE) != 0); + w->t_exec = t_exec; printf("filesize : %d\n",w->read_filesize); printf("one_task_size: %d\n",w->read_division_size); @@ -408,10 +376,11 @@ t_print = manager->create_task(TASK_PRINT, (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print = t_print; + for(int i=0;i<1;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ - HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, + t_exec = manager->create_task(RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); t_exec->wait_for(r_run); t_print->wait_for(t_exec);