Mercurial > hg > Game > Cerium
changeset 464:0d64bdb63005 draft
task run is mere C function now.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Sep 2009 10:12:26 +0900 |
parents | 60f44d3ea452 |
children | 3aaa9da117f4 |
files | TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/Scheduler.cc TaskManager/kernel/schedule/Scheduler.h TaskManager/kernel/sys_task/Finish.cc TaskManager/kernel/sys_task/Finish.h TaskManager/kernel/sys_task/Start.cc TaskManager/kernel/sys_task/Start.h example/get_segment/ppe/Hello.cc example/get_segment/ppe/Hello.h example/get_segment/ppe/Hello1.cc example/get_segment/ppe/Hello1.h example/get_segment/spe/Hello.cc example/get_segment/spe/Hello.h example/get_segment/spe/Hello1.cc example/get_segment/spe/Hello1.h |
diffstat | 16 files changed, 42 insertions(+), 97 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/SchedTask.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Wed Sep 30 10:12:26 2009 +0900 @@ -13,15 +13,13 @@ /** Task Object を作る - code loading ならば、loading の終了を待つ */ SchedTask * createSchedTask(Scheduler *scheduler, TaskPtr task) { - task_list[task->command].wait(scheduler,task->command); - return task_list[task->command].creator(scheduler); + return new SchedTask(); } @@ -58,8 +56,6 @@ ex_write = &SchedTask::ex_write_normal; ex_next = &SchedTask::ex_next_normal; - // run_func = &SchedTask::run; - run_func1 = &SchedTask::run; } /** @@ -194,11 +190,10 @@ #if !defined(NO_PIPELINE) __scheduler->dma_wait(DMA_READ); + task_list[__task->command].wait(__scheduler,__task->command); #endif - //run(__readbuf, __writebuf); - // (this->*run_func)(__readbuf, __writebuf); - (this->*run_func1)(this, __readbuf, __writebuf); + task_list[__task->command].run(this, __readbuf, __writebuf); free(__readbuf);
--- a/TaskManager/kernel/schedule/SchedTask.h Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Wed Sep 30 10:12:26 2009 +0900 @@ -69,13 +69,7 @@ void write(); SchedTaskBase* next(Scheduler *, SchedTaskBase *); - // ここをユーザが継承して - // それぞれのタスクに対応した処理を記述する - virtual int run(SchedTask* smanager, void* r, void *w) =0; - // virtual int run(void* r, void *w) =0; - - // int (SchedTask::*run_func)(void* r, void *w); - int (SchedTask::*run_func1)(SchedTask* smanager, void* r, void *w); + // タスクの処理は、task_list に登録された C の関数によっておこなう //--- System API --- SchedTask* get_nextTask(TaskListPtr list);
--- a/TaskManager/kernel/schedule/Scheduler.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Wed Sep 30 10:12:26 2009 +0900 @@ -367,13 +367,13 @@ // wait for code segment load m->wait_segment(task_list[task_id].segment); // calcurate call address - TaskObjectCreator creator = - (TaskObjectCreator)( + TaskObjectRun run = + (TaskObjectRun)( (char*)task_list[task_id].segment->data + task_list[task_id].entry_offset); - task_list[task_id].creator = creator; + task_list[task_id].run = run; fprintf(stderr,"wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, - (unsigned int)creator, + (unsigned int)run, task_list[task_id].entry_offset); } @@ -383,9 +383,9 @@ } extern void -register_task(int cmd, TaskObjectCreator creator) +register_task(int cmd, TaskObjectRun run) { - task_list[cmd].creator = creator; + task_list[cmd].run = run; task_list[cmd].load = null_loader; task_list[cmd].wait = null_waiter; } @@ -393,9 +393,9 @@ extern void register_dynamic_task(int cmd, memaddr start, int size, - TaskObjectCreator creator, int entry_offset) + TaskObjectRun run, int entry_offset) { - task_list[cmd].creator = creator; + task_list[cmd].run = run; task_list[cmd].location = start; size &= 0xfffffffe; task_list[cmd].end = start+size;
--- a/TaskManager/kernel/schedule/Scheduler.h Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Wed Sep 30 10:12:26 2009 +0900 @@ -21,7 +21,7 @@ class SchedTask; class SchedTaskList; -typedef SchedTask* (*TaskObjectCreator)(Scheduler *); +typedef int (*TaskObjectRun)(SchedTask* smanager, void* r, void *w); class Scheduler { public: @@ -94,11 +94,11 @@ MemList *code_segment_pool; // Task Object Table - // this is named TaskObject but it is not an object. + // this is named TaskObjectRun but it is not an object. // It is a pointer to an object creation function // 大きいので、SPEには置かない方が本当は良い... typedef struct { - TaskObjectCreator creator; + TaskObjectRun run; memaddr location; // location address in a.out memaddr end; uint32 entry_offset; // offset for create(); @@ -171,9 +171,9 @@ void dma_storeList(ListDataPtr list, void *, uint32 mask); }; -extern void register_task(int cmd, TaskObjectCreator creator); +extern void register_task(int cmd, TaskObjectRun run); extern void register_dynamic_task(int cmd, - memaddr start, int size, TaskObjectCreator creator, + memaddr start, int size, TaskObjectRun run, int entry_offset); struct tbl { @@ -191,35 +191,31 @@ BASE_NEW_DELETE(str) \ #define SchedDefineTask(str) \ + static int run(SchedTask *smanager, void *rbuf, void *wbuf); \ extern "C" { \ - SchedTask* createTask_##str(Scheduler *manager) \ + int runTask_##str(SchedTask *smanager, void *rbuf, void *wbuf) \ { \ - return new str(); \ + return run(smanager, rbuf, wbuf); \ } \ } #define SchedExternTask(str) \ extern "C" { \ - extern SchedTask* createTask_##str(Scheduler *manager) ; \ + extern int runTask_##str(SchedTask *manager, void *rbuf, void *wbuf) ; \ } #define SchedRegisterTask(cmd, str) \ - register_task(cmd, createTask_##str); + register_task(cmd, runTask_##str); #define SchedDefineDynamicTask(str,segment) \ - extern "C" { \ - SchedTask* createTask_##str(Scheduler *manager) \ - { \ - return new str(); \ - } \ - } + SchedDefineTask(str) #ifndef NO_OVERLAY #define SchedExternDynamicTask(str,segment) \ extern "C" { \ extern unsigned long long _EAR_; \ extern struct tbl _ovly_table[]; \ - extern SchedTask* createTask_##str(Scheduler *manager) ; \ + extern int runTask_##str(SchedTask *manager, void *rbuf, void *wbuf) ; \ } #else #define SchedExternDynamicTask(str,segment) SchedExternTask(str) @@ -230,8 +226,8 @@ #define SchedRegisterDynamicTask(cmd, str, segment) \ register_dynamic_task(cmd, _EAR_+_ovly_table[segment].file_offset, \ _ovly_table[segment].size, \ - createTask_##str, \ - createTask_##str##_offset); + runTask_##str, \ + runTask_##str##_offset); #else #define SchedRegisterDynamicTask(cmd, str, segment) SchedRegisterTask(cmd, str) #endif
--- a/TaskManager/kernel/sys_task/Finish.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/sys_task/Finish.cc Wed Sep 30 10:12:26 2009 +0900 @@ -3,8 +3,8 @@ SchedDefineTask(Finish); -int -Finish::run(SchedTask *s,void *rbuf, void *wbuf) +static int +run(SchedTask *s,void *rbuf, void *wbuf) { return 0; }
--- a/TaskManager/kernel/sys_task/Finish.h Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/sys_task/Finish.h Wed Sep 30 10:12:26 2009 +0900 @@ -1,15 +1,7 @@ #ifndef INCLUDED_SYSTASK_FINISH #define INCLUDED_SYSTASK_FINISH -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif +#include "SchedTask.h" -class Finish : public SchedTask { -public: - SchedConstructor(Finish); - - int run(SchedTask *,void *r, void *w); -}; #endif
--- a/TaskManager/kernel/sys_task/Start.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/sys_task/Start.cc Wed Sep 30 10:12:26 2009 +0900 @@ -3,8 +3,8 @@ SchedDefineTask(Start); -int -Start::run(SchedTask *s,void *rbuf, void *wbuf) +static int +run(SchedTask *s,void *rbuf, void *wbuf) { return 0; }
--- a/TaskManager/kernel/sys_task/Start.h Tue Sep 29 15:45:11 2009 +0900 +++ b/TaskManager/kernel/sys_task/Start.h Wed Sep 30 10:12:26 2009 +0900 @@ -1,15 +1,7 @@ #ifndef INCLUDED_SYSTASK_START #define INCLUDED_SYSTASK_START -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif +#include "SchedTask.h" -class Start : public SchedTask { -public: - SchedConstructor(Start); - - int run(SchedTask *,void *r, void *w); -}; #endif
--- a/example/get_segment/ppe/Hello.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/ppe/Hello.cc Wed Sep 30 10:12:26 2009 +0900 @@ -8,10 +8,10 @@ #define PP_STORE 3 #define SIZE (4096*sizeof(int)) -int -Hello::run(SchedTask *smanager, void *rbuf, void *wbuf) +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) { - int task_id = get_param(0); + int task_id = smanager->get_param(0); int *ptr = 0; #if 1 ptr = (int*)smanager->allocate(SIZE);
--- a/example/get_segment/ppe/Hello.h Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/ppe/Hello.h Wed Sep 30 10:12:26 2009 +0900 @@ -5,11 +5,5 @@ # include "SchedTask.h" #endif -class Hello : public SchedTask { -public: - SchedConstructor(Hello); - - int run(SchedTask *smanager, void *r, void *w); -}; #endif
--- a/example/get_segment/ppe/Hello1.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/ppe/Hello1.cc Wed Sep 30 10:12:26 2009 +0900 @@ -8,10 +8,10 @@ #define PP_STORE 3 #define SIZE (4096*sizeof(int)) -int -Hello1::run(SchedTask *smanager, void *rbuf, void *wbuf) +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) { - int task_id = get_param(0); + int task_id = smanager->get_param(0); int *ptr = 0; #if 1 ptr = (int*)smanager->allocate(SIZE);
--- a/example/get_segment/ppe/Hello1.h Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/ppe/Hello1.h Wed Sep 30 10:12:26 2009 +0900 @@ -5,11 +5,5 @@ # include "SchedTask.h" #endif -class Hello1 : public SchedTask { -public: - SchedConstructor(Hello1); - - int run(SchedTask *smanager, void *r, void *w); -}; #endif
--- a/example/get_segment/spe/Hello.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/spe/Hello.cc Wed Sep 30 10:12:26 2009 +0900 @@ -5,8 +5,8 @@ /* これは必須 */ SchedDefineDynamicTask(Hello,0); -int -Hello::run(SchedTask *smanager, void *rbuf, void *wbuf) +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) { int task_id = get_param(0);
--- a/example/get_segment/spe/Hello.h Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/spe/Hello.h Wed Sep 30 10:12:26 2009 +0900 @@ -5,11 +5,5 @@ # include "SchedTask.h" #endif -class Hello : public SchedTask { -public: - SchedConstructor(Hello); - - int run(SchedTask *smanager, void *r, void *w); -}; #endif
--- a/example/get_segment/spe/Hello1.cc Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/spe/Hello1.cc Wed Sep 30 10:12:26 2009 +0900 @@ -5,8 +5,8 @@ /* これは必須 */ SchedDefineDynamicTask(Hello1,1); -int -Hello1::run(SchedTask *smanager, void *rbuf, void *wbuf) +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) { int task_id = get_param(0);
--- a/example/get_segment/spe/Hello1.h Tue Sep 29 15:45:11 2009 +0900 +++ b/example/get_segment/spe/Hello1.h Wed Sep 30 10:12:26 2009 +0900 @@ -5,11 +5,5 @@ # include "SchedTask.h" #endif -class Hello1 : public SchedTask { -public: - SchedConstructor(Hello1); - - int run(SchedTask *smanager, void *r, void *w); -}; #endif