Mercurial > hg > Members > kono > Cerium
changeset 480:46464727d825
TaskQueueInfo initiaization...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 05 Oct 2009 12:24:07 +0900 |
parents | 5bda98b0b56d |
children | 4896dffad67c |
files | TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/HTaskInfo.cc TaskManager/kernel/ppe/TaskManager.cc TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/ppe/TaskQueue.h TaskManager/kernel/ppe/TaskQueueInfo.cc TaskManager/kernel/ppe/TaskQueueInfo.h TaskManager/kernel/schedule/TaskGroup.h |
diffstat | 10 files changed, 46 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Mon Oct 05 12:24:07 2009 +0900 @@ -86,13 +86,11 @@ FifoTaskManagerImpl::get_runTaskList() { TaskListPtr list, list_top; - TaskQueuePtr queue; TaskQueuePtr d; HTaskPtr htask; // HTask (PPE にある) TaskPtr task; // Task (SPE に送る Task) - queue = activeTaskQueue; - if (queue == NULL) { + if (activeTaskQueue->empty()) { return NULL; } @@ -103,10 +101,8 @@ list_top = taskListImpl->clear_taskList(list_top); list = list_top; - while (queue) { + while (TaskQueuePtr queue = activeTaskQueue->poll()) { htask = (HTaskPtr)queue->task; - d = queue; - queue = queue->next; task = &list->tasks[list->length++]; @@ -118,10 +114,9 @@ list = newList; } - taskQueueImpl->free(d); + activeTaskQueue->free(d); } - activeTaskQueue = NULL; mainTaskList = list_top; return list_top;
--- a/TaskManager/kernel/ppe/HTask.h Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/HTask.h Mon Oct 05 12:24:07 2009 +0900 @@ -29,7 +29,7 @@ void (*post_func)(void *arg); void *post_arg; CPU_TYPE cpu_type; - HTask *next; + HTask *next; // free list 用 TaskManagerImpl *mimpl; void spawn(void);
--- a/TaskManager/kernel/ppe/HTaskInfo.cc Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/HTaskInfo.cc Mon Oct 05 12:24:07 2009 +0900 @@ -37,12 +37,16 @@ /* Connect all free queue in the pool */ for (q = htaskPool + 1; --num > 0; q++) { q->next = q + 1; + q->wait_me = new TaskQueueInfo(); + q->wait_i = new TaskQueueInfo(); q->inData = (ListDataPtr)malloc(sizeof(ListData)); q->outData = (ListDataPtr)malloc(sizeof(ListData)); } q->next = freeHTask; q->inData = (ListDataPtr)malloc(sizeof(ListData)); q->outData = (ListDataPtr)malloc(sizeof(ListData)); + q->wait_me = new TaskQueueInfo(); + q->wait_i = new TaskQueueInfo(); freeHTask = htaskPool + 1; @@ -72,8 +76,6 @@ q->self = (unsigned int)q; q->param_size = 0; - q->wait_me = NULL; - q->wait_i = NULL; q->post_func = NULL; q->mimpl = NULL; q->cpu_type = CPU_PPE;
--- a/TaskManager/kernel/ppe/TaskManager.cc Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.cc Mon Oct 05 12:24:07 2009 +0900 @@ -90,3 +90,5 @@ TaskManager::get_scheduler() { return m_impl->get_scheduler(); } + +/* end */
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Mon Oct 05 12:24:07 2009 +0900 @@ -13,7 +13,11 @@ } TaskManagerImpl::TaskManagerImpl(int num) - : machineNum(num), activeTaskQueue(NULL), waitTaskQueue(NULL) {} + : machineNum(num) { + activeTaskQueue = new TaskQueueInfo(); + waitTaskQueue = new TaskQueueInfo(); + taskQueueImpl = new TaskQueueInfo(); +} /** * 一番最初に PPE で実行される systask_start @@ -77,7 +81,7 @@ { // waiter // master // waitee // slave - if (task->wait_i == NULL) { + if (task->wait_i->empty()) { append_activeTask(task); } else { append_waitTask(task); @@ -117,9 +121,7 @@ void TaskManagerImpl::check_task_finish(HTaskPtr task) { - TaskQueue *p = task->wait_me->getFirst(); - while(p) { - TaskQueue *next = p->next; + while(TaskQueue *p = task->wait_me->poll()) { HTaskPtr htask = (HTaskPtr)p->task; TaskQueueInfo *wait_i = htask->wait_i; // 相手の wait queue から自分(を指しているTaskQueue)を削除 @@ -128,7 +130,6 @@ // queue を free する wait_i->free(p->waiter); wait_i->free(p); - p = next; } task->post_func(task->post_arg); @@ -150,15 +151,11 @@ void TaskManagerImpl::wakeup_waitTask(void) { - TaskQueuePtr p = waitTaskQueue->getFirst(); - while (p) { + while (TaskQueuePtr p = waitTaskQueue->poll()) { HTaskPtr task = (HTaskPtr)p->task; - TaskQueue *next = p->next; - if (task->wait_i == NULL) { - waitTaskQueue->remove(p); + if (task->wait_i->empty()) { activeTaskQueue->addLast(p); } - p = next; } }
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Mon Oct 05 12:24:07 2009 +0900 @@ -11,9 +11,6 @@ class TaskManagerImpl { public: - /* constructor */ - TaskManagerImpl(int num = 1); - virtual ~TaskManagerImpl(void) {} /* variables */ int machineNum; @@ -25,17 +22,22 @@ TaskQueueInfo *taskQueueImpl; HTaskInfo *htaskImpl; + /* constructor */ + TaskManagerImpl(int num = 1) ; + + virtual ~TaskManagerImpl() { } + /* functions */ // system - virtual void init(void) = 0; - virtual void run(void) = 0; + virtual void init() = 0; + virtual void run() = 0; virtual void append_activeTask(HTaskPtr); virtual void append_waitTask(HTaskPtr); void check_task_finish(HTaskPtr task); - void wakeup_waitTask(void); + void wakeup_waitTask(); - void systask_init(void); + void systask_init(); // user HTaskPtr create_task(int cmd);
--- a/TaskManager/kernel/ppe/TaskQueue.h Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskQueue.h Mon Oct 05 12:24:07 2009 +0900 @@ -12,10 +12,11 @@ BASE_NEW_DELETE(TaskQueue); Task *task; + TaskQueue *waiter; + TaskQueue *next; TaskQueue *prev; - TaskQueue *waiter; }; typedef TaskQueue* TaskQueuePtr;
--- a/TaskManager/kernel/ppe/TaskQueueInfo.cc Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskQueueInfo.cc Mon Oct 05 12:24:07 2009 +0900 @@ -2,8 +2,10 @@ #include <stdlib.h> #include "TaskQueueInfo.h" -TaskQueueInfo::TaskQueueInfo(void) - :taskQueuePool(NULL), freeTaskQueue(NULL) {} +TaskQueueInfo::TaskQueueInfo() + :taskQueuePool(NULL), freeTaskQueue(NULL) { + init(32); +} TaskQueueInfo::~TaskQueueInfo(void) { destroy(); } @@ -11,9 +13,10 @@ TaskQueueInfo::init(int num) { if (taskQueuePool == NULL) { - return extend_pool(num); + extend_pool(num); } // 最初の一つは自分 + first = last = this; next = prev = this; return 0; } @@ -26,7 +29,7 @@ q = (TaskQueuePtr)malloc(sizeof(TaskQueue)*(num+1)); if (q == NULL) { - return -1; + return -1; // throw... } q->next = taskQueuePool; taskQueuePool = q; @@ -47,7 +50,7 @@ TaskQueuePtr q; if (freeTaskQueue == NULL) { - extend_pool(100); + extend_pool(64); } q = freeTaskQueue; freeTaskQueue = freeTaskQueue->next; @@ -120,12 +123,14 @@ TaskQueue* TaskQueueInfo::getFirst() { + if (empty()) return NULL; return first->next; } TaskQueue* TaskQueueInfo::getLast() { + if (empty()) return NULL; return last; }
--- a/TaskManager/kernel/ppe/TaskQueueInfo.h Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskQueueInfo.h Mon Oct 05 12:24:07 2009 +0900 @@ -28,8 +28,8 @@ private: /* variables */ - TaskQueuePtr taskQueuePool; - TaskQueuePtr freeTaskQueue; + TaskQueue* taskQueuePool; + TaskQueue* freeTaskQueue; TaskQueue* first; TaskQueue* last;
--- a/TaskManager/kernel/schedule/TaskGroup.h Mon Oct 05 10:36:37 2009 +0900 +++ b/TaskManager/kernel/schedule/TaskGroup.h Mon Oct 05 12:24:07 2009 +0900 @@ -6,13 +6,16 @@ class TaskGroup { public: - TaskGroup(void): group(NULL) {} BASE_NEW_DELETE(TaskGroup); unsigned int command; TaskQueueInfo *group; + TaskGroup(): group() { + group = new TaskQueueInfo(); + } + /** * 待つ Task を追加 */