Mercurial > hg > Game > Cerium
changeset 1102:8d2a1f5edf10 draft
fix.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 31 Dec 2010 17:21:37 +0900 |
parents | 1da96a535437 |
children | de43f312b51f |
files | TaskManager/kernel/schedule/SchedTaskBase.h example/ResizeWritebuf/Container.h example/ResizeWritebuf/main.cc example/ResizeWritebuf/ppe/Resize.cc |
diffstat | 4 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/SchedTaskBase.h Fri Dec 31 16:29:20 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskBase.h Fri Dec 31 17:21:37 2010 +0900 @@ -29,6 +29,8 @@ virtual void write() {} virtual SchedTaskBase* next(Scheduler *, SchedTaskBase*) {return 0;} + virtual void setup_outputData() {}; + /* functions */ virtual void* get_output(void *buff, int index) { return 0; } virtual void* get_input(void *buff, int index) { return 0;} @@ -40,6 +42,7 @@ virtual memaddr get_outputAddr(int index) {return 0;} virtual int get_inputSize(int index) {return 0;} virtual int get_outputSize(int index) {return 0;} + virtual void set_outputSize(int index, int size) {}; virtual int get_cpuid() {return 0;}
--- a/example/ResizeWritebuf/Container.h Fri Dec 31 16:29:20 2010 +0900 +++ b/example/ResizeWritebuf/Container.h Fri Dec 31 17:21:37 2010 +0900 @@ -2,5 +2,5 @@ typedef struct Container { int length; - int data; + int data[1]; } Container, *ContainerPtr;
--- a/example/ResizeWritebuf/main.cc Fri Dec 31 16:29:20 2010 +0900 +++ b/example/ResizeWritebuf/main.cc Fri Dec 31 17:21:37 2010 +0900 @@ -5,6 +5,8 @@ #include "Container.h" #include "Func.h" +#define CONTAINER_DATA_SIZE 4096 + extern void task_init(void); static int count = 1; @@ -42,8 +44,8 @@ int data_length = obj->length; for(int i =0;i <data_length;i++) { - int data = obj[i].data; - printf("data[%d] = %d\n", i, data); + int idata = obj->data[i]; + printf("data[%d] = %d\n", i, idata); } free(data); @@ -54,10 +56,10 @@ resize_init(TaskManager *manager) { HTaskPtr resize_task = manager->create_task(RESIZE); - ContainerPtr obj = (ContainerPtr)manager->allocate(sizeof(Container)*data_size); - obj->length = data_length; + ContainerPtr obj = (ContainerPtr)manager->allocate(CONTAINER_DATA_SIZE); + obj->length = 0; - resize_task->set_inData(0, obj, sizeof(Container)*data_size); + resize_task->set_param(0, (memaddr)data_length); resize_task->set_outData(0, obj, 0); resize_task->set_post(checkData, (void*)obj, NULL);
--- a/example/ResizeWritebuf/ppe/Resize.cc Fri Dec 31 16:29:20 2010 +0900 +++ b/example/ResizeWritebuf/ppe/Resize.cc Fri Dec 31 17:21:37 2010 +0900 @@ -10,16 +10,17 @@ static int resize(SchedTask *smanager, void *rbuf, void *wbuf) { - ContainerPtr icontainer = (ContainerPtr)smanager->get_input(rbuf, 0); - int length = icontainer->length; - ContainerPtr wcontainer = (ContainerPtr)smanager->get_output(wbuf, 0); + long length = (long)smanager->get_param(0); - smanager->set_outputSize(0, sizeof(Container)*length); + smanager->set_outputSize(0, sizeof(Container)+sizeof(int)*(length-1)); smanager->setup_outputData(); + + ContainerPtr wcontainer = (ContainerPtr)smanager->get_output(wbuf, 0); - for (int i =0; i < length;i++) { - wcontainer[i].data = i; - } - + for (int i =0; i < length;i++){ + wcontainer->data[i] = i; + } + + wcontainer->length = length; return 0; }