Mercurial > hg > Game > Cerium
changeset 1827:d1212026e2a0 draft
some fix
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Dec 2013 13:57:34 +0900 |
parents | d3a9772074d6 |
children | f0dab5fffe7a |
files | example/fileread/Makefile.def example/fileread/Makefile.macosx example/fileread/main.cc |
diffstat | 3 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fileread/Makefile.def Mon Dec 16 20:00:13 2013 +0900 +++ b/example/fileread/Makefile.def Tue Dec 17 13:57:34 2013 +0900 @@ -3,13 +3,16 @@ # include/library path # ex macosx #CERIUM = /Users/gongo/Source/Cerium +ABIBIT=64 # ex linux/ps3 CERIUM = ../../../Cerium -CC = clang++ + OPT = -g -CFLAGS = $(OPT) -Wall -INCLUDE = -I.. -I. -I${CERIUM}/include/TaskManager +CC = clang++ +CFLAGS = -Wall $(OPT) + +INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager
--- a/example/fileread/Makefile.macosx Mon Dec 16 20:00:13 2013 +0900 +++ b/example/fileread/Makefile.macosx Tue Dec 17 13:57:34 2013 +0900 @@ -12,6 +12,7 @@ TASK_OBJS = $(TASK_SRCS:.cc=.o) LIBS += -lFifoManager `sdl-config --libs` +CC += -m$(ABIBIT) .SUFFIXES: .cc .o
--- a/example/fileread/main.cc Mon Dec 16 20:00:13 2013 +0900 +++ b/example/fileread/main.cc Tue Dec 17 13:57:34 2013 +0900 @@ -4,6 +4,7 @@ #include <sys/stat.h> #include <sys/time.h> #include "TaskManager.h" +#include "SchedTask.h" #include "Func.h" extern void task_init(void); @@ -20,7 +21,7 @@ -file Opne file\n"; typedef struct fileread { struct filesize *self; - int fd; + int *fd; long division_size; long task_number; long task_num; @@ -33,18 +34,19 @@ SchedDefineTask1(RUN_BLOCKS,run16); static int -run16(SchedTask *m, void *in, void *out) { +run16(SchedTask *manager, void *in, void *out) { FilereadPtr fr = (FilereadPtr)in; HTaskPtr wait; - for (int task_number = 0; fr->left_size > 0 && task_number < fr->task_blocks; task_number++) { + for (int i = 0; (fr->left_size > 0) && (i < fr->task_blocks); i++) { HTaskPtr read = manager->create_task(Read_task); read->set_cpu(fr->cpu); - if (task_number == fr->task_blocks / 2) wait = read; + if (fr->task_number == 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つのタスクが読み込む量 @@ -53,10 +55,10 @@ }else{ read->set_param(2,(long)fr->division_size); } - read->set_param(3,(long)fr->fd); read->spawn(); fr->left_size -= fr->division_size; + fr->task_number++; } if (fr->left_size > 0) { @@ -107,21 +109,21 @@ static void run_start(TaskManager *manager,char *filename) { - int fd; - + int *fd = (int*)manager->allocate(sizeof(int)); struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat)); - if ((fd=open(filename,O_RDONLY,0666))==0) { - fprintf(stderr,"can't open %s\n",filename); + 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); } FilereadPtr fr = (FilereadPtr)manager->allocate(sizeof(Fileread)); - fr->cpu = spe_cpu; + fr->fd = fd; + fr->cpu = spe_cpu; fr->task_blocks = 16; fr->filesize = sb->st_size; fr->left_size = fr->filesize;