Mercurial > hg > Members > kono > Cerium
diff TaskManager/kernel/schedule/SchedTask.cc @ 373:eab18aa0c7f6
MemList not working
author | kazz@kazzone.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Fri, 31 Jul 2009 17:52:27 +0900 |
parents | b89ba1d96fff |
children | 5e2d30bfbf23 |
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/SchedTask.cc Fri Jul 31 01:44:06 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Jul 31 17:52:27 2009 +0900 @@ -1,7 +1,6 @@ #include <stdlib.h> #include <string.h> #include "SchedTask.h" -#include "SchedTask.h" #include "SchedTaskList.h" #include "SchedNop2Ready.h" #include "DmaManager.h" @@ -10,7 +9,7 @@ extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; -//#define NO_PIPELINE +//#define NO_PIPELINE SchedTask * createSchedTask(TaskPtr task) @@ -18,7 +17,7 @@ return task_list[task->command](); } - + SchedTask::SchedTask() { __list = NULL; @@ -32,7 +31,7 @@ __renew_flag = 0; __cur_index = 0; __flag_renewTask = SCHED_TASK_NORMAL; - + ex_init = &SchedTask::ex_init_normal; ex_read = &SchedTask::ex_read_normal; ex_exec = &SchedTask::ex_exec_normal; @@ -40,7 +39,7 @@ ex_next = &SchedTask::ex_next_normal; run_func = &SchedTask::run; - run_func1 = &SchedTask::run; + run_func1 = &SchedTask::run; } /** @@ -53,24 +52,24 @@ SchedTask::~SchedTask(void) { if (__flag_renewTask == SCHED_TASK_RENEW) { - free(__inListData); + free(__inListData); free(__outListData); - - /** - * __list != NULL の場合、 - * この Task が __list の最後の Task になるので (SchedTask::next 参照) - * このタイミングで __list を解放する - * (free に渡されるアドレスが正しいものとなる)。 - * それ以外の Task では当然解放しない。 - * __list == NULL なので、free に渡しても無問題 - */ - free(__list); + + /** + * __list != NULL の場合、 + * この Task が __list の最後の Task になるので (SchedTask::next 参照) + * このタイミングで __list を解放する + * (free に渡されるアドレスが正しいものとなる)。 + * それ以外の Task では当然解放しない。 + * __list == NULL なので、free に渡しても無問題 + */ + free(__list); } } -/** +/** * このタスクを Renew Task とし、それに応じた関数をセットする */ void @@ -81,13 +80,13 @@ ex_init = &SchedTask::ex_init_renew; ex_read = &SchedTask::ex_read_renew; ex_exec = &SchedTask::ex_exec_renew; - ex_write = &SchedTask::ex_write_renew; + ex_write = &SchedTask::ex_write_renew; ex_next = &SchedTask::ex_next_renew; } void SchedTask::__init__(TaskListPtr _list, TaskPtr _task, int index, - ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc) + ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc) { __list = _list; __task = _task; @@ -110,14 +109,14 @@ SchedTask::ex_init_normal(void) { __scheduler->dma_load(__inListData, (uint32)__task->inData, - sizeof(ListData), DMA_READ_IN_LIST); + sizeof(ListData), DMA_READ_IN_LIST); __scheduler->dma_load(__outListData, (uint32)__task->outData, - sizeof(ListData), DMA_READ_OUT_LIST); + sizeof(ListData), DMA_READ_OUT_LIST); #if defined(NO_PIPELINE) __scheduler->dma_wait(DMA_READ_IN_LIST); __scheduler->dma_wait(DMA_READ_OUT_LIST); #endif - + __taskGroup = new TaskGroup; __taskGroup->command = __task->self; } @@ -132,7 +131,7 @@ { __inListData = __task->inData; __outListData = __task->outData; - __taskGroup = (TaskGroupPtr)__task->self; + __taskGroup = (TaskGroupPtr)__task->self; } /** @@ -146,7 +145,7 @@ */ void SchedTask::read(void) -{ +{ __debug("[SchedTask:%s]\n", __FUNCTION__); #if !defined(NO_PIPELINE) @@ -155,7 +154,7 @@ #endif __writebuf = __scheduler->allocate(__outListData->size); - + // 読むデータが一つもなければ無視 if (__inListData->length == 0) return; @@ -186,19 +185,19 @@ free(__readbuf); if (__taskGroup->status() != 0) { - __task->self = __taskGroup->command; - delete __taskGroup; - __taskGroup = NULL; + __task->self = __taskGroup->command; + delete __taskGroup; + __taskGroup = NULL; } // 書き込む領域がなければ無視 if (__outListData->length > 0) { - __scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE); + __scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE); #if defined(NO_PIPELINE) - __scheduler->dma_wait(DMA_WRITE); - free(__writebuf); + __scheduler->dma_wait(DMA_WRITE); + free(__writebuf); #endif } @@ -209,7 +208,7 @@ SchedTask::write(void) { __debug("[SchedTask:%s]\n", __FUNCTION__); - + #if !defined(NO_PIPELINE) __scheduler->dma_wait(DMA_WRITE); free(__writebuf); @@ -256,7 +255,7 @@ /** * PPE 内で生成されたタスクの ex_write() - * + * * このタスク内で新たにタスクが生成され、 * 且つそのタスクの終了を待つ必要がある場合、 * PPE に終了したことは知らせない(command は送信しない) @@ -269,7 +268,7 @@ * or 生成されたが、そのタスクの終了を待つ必要は無い */ if (__renew_flag == 0) { - __scheduler->mail_write(__task->self); + __scheduler->mail_write(__task->self); } } @@ -289,17 +288,17 @@ SchedTask::ex_write_renew(void) { uint32 cmd; - + __taskGroup->remove(__task); - cmd = __taskGroup->status(); + cmd = __taskGroup->status(); // タスク内で作られた全てのタスクが終了した if (cmd != 0) { - delete __taskGroup; - __scheduler->mail_write(cmd); + delete __taskGroup; + __scheduler->mail_write(cmd); } } - + SchedTaskBase* SchedTask::next(Scheduler *m, SchedTaskBase *p) { @@ -314,33 +313,33 @@ SchedTask::ex_next_normal(void) { if (__cur_index < __list->length) { - SchedTaskBase *nextSched; + SchedTaskBase *nextSched; + + nextSched = __scheduler->get_nextRenewTaskList(); - nextSched = __scheduler->get_nextRenewTaskList(); - - // RenewTask がある - if (nextSched) { - __scheduler->set_backupTaskList(__list); - __scheduler->set_backupTaskListIndex(__cur_index); - return nextSched; - } else { - TaskPtr nextTask = &__list->tasks[__cur_index++]; - nextSched = createSchedTask(nextTask); - ((SchedTask*)nextSched)->__init__(__list, nextTask, __cur_index, - __scheduler->get_curReadBuf(), - __scheduler->get_curWriteBuf(), - __scheduler); - return nextSched; - } + // RenewTask がある + if (nextSched) { + __scheduler->set_backupTaskList(__list); + __scheduler->set_backupTaskListIndex(__cur_index); + return nextSched; + } else { + TaskPtr nextTask = &__list->tasks[__cur_index++]; + nextSched = createSchedTask(nextTask); + ((SchedTask*)nextSched)->__init__(__list, nextTask, __cur_index, + __scheduler->get_curReadBuf(), + __scheduler->get_curWriteBuf(), + __scheduler); + return nextSched; + } } else { - uint32 nextList = (uint32)__list->next; - - if (nextList == 0) { - return new SchedNop2Ready(__scheduler); - } else { - return createSchedTaskList(nextList, __scheduler, - SCHED_TASKLIST_NORMAL); - } + uint32 nextList = (uint32)__list->next; + + if (nextList == 0) { + return new SchedNop2Ready(__scheduler); + } else { + return createSchedTaskList(nextList, __scheduler, + SCHED_TASKLIST_NORMAL); + } } } @@ -354,47 +353,47 @@ SchedTask *nextSched; if (__cur_index < __list->length) { - nextTask = &__list->tasks[__cur_index++]; - nextSched = createSchedTask(nextTask); + nextTask = &__list->tasks[__cur_index++]; + nextSched = createSchedTask(nextTask); - // RenewTaskList を実行中なので - nextSched->__setRenew(); - nextSched->__init__(__list, nextTask, __cur_index, - __scheduler->get_curReadBuf(), - __scheduler->get_curWriteBuf(), - __scheduler); + // RenewTaskList を実行中なので + nextSched->__setRenew(); + nextSched->__init__(__list, nextTask, __cur_index, + __scheduler->get_curReadBuf(), + __scheduler->get_curWriteBuf(), + __scheduler); - /** - * この理由は SchedTask:~SchedTask() で - */ - __list = NULL; - return nextSched; + /** + * この理由は SchedTask:~SchedTask() で + */ + __list = NULL; + return nextSched; } else { - SchedTaskBase *nextList; - - nextList = __scheduler->get_nextRenewTaskList(); - - if (nextList) { - return nextList; - } else { - TaskListPtr nextList = __scheduler->get_backupTaskList(); + SchedTaskBase *nextList; + + nextList = __scheduler->get_nextRenewTaskList(); + + if (nextList) { + return nextList; + } else { + TaskListPtr nextList = __scheduler->get_backupTaskList(); + + // 中断した TaskList がある + if (nextList) { + __cur_index = __scheduler->get_backupTaskListIndex(); - // 中断した TaskList がある - if (nextList) { - __cur_index = __scheduler->get_backupTaskListIndex(); - - nextTask = &nextList->tasks[__cur_index++]; - nextSched = createSchedTask(nextTask); - - nextSched->__init__(nextList, nextTask, __cur_index, - __scheduler->get_curReadBuf(), - __scheduler->get_curWriteBuf(), - __scheduler); - return nextSched; - } else { - return new SchedNop2Ready(__scheduler); - } - } + nextTask = &nextList->tasks[__cur_index++]; + nextSched = createSchedTask(nextTask); + + nextSched->__init__(nextList, nextTask, __cur_index, + __scheduler->get_curReadBuf(), + __scheduler->get_curWriteBuf(), + __scheduler); + return nextSched; + } else { + return new SchedNop2Ready(__scheduler); + } + } } } @@ -412,9 +411,9 @@ SchedTask::get_input(void *buff, int index) { if (buff != NULL) { - return (void*)((int)buff + __inListData->bound[index]); + return (void*)((int)buff + __inListData->bound[index]); } else { - return NULL; + return NULL; } } @@ -443,9 +442,9 @@ SchedTask::get_output(void *buff, int index) { if (buff != NULL) { - return (void*)((int)buff + __outListData->bound[index]); + return (void*)((int)buff + __outListData->bound[index]); } else { - return NULL; + return NULL; } } @@ -519,10 +518,20 @@ } void +SchedTask::global_set(int id, void *addr) { + __scheduler->global_set(id, addr); +} + +void SchedTask::global_free(int id) { __scheduler->global_free(id); } +MemList* +SchedTask::createMemList(int size, int count) { + return __scheduler->createMemList(size, count); +} + void SchedTask::mainMem_alloc(int id, int size) { __scheduler->mainMem_alloc(id, size);