Mercurial > hg > Game > Cerium
changeset 481:f9ffcffb6d09 draft
Double linked list modification done (tested on Mac OS X)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 05 Oct 2009 16:46:46 +0900 |
parents | 75e4afa40da2 |
children | 314031ecd723 |
files | TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/ChangeLog TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/kernel/ppe/SymTable.cc TaskManager/kernel/ppe/SymTable.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskQueueInfo.cc example/dependency_task/main.cc |
diffstat | 8 files changed, 34 insertions(+), 120 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Mon Oct 05 12:24:07 2009 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Mon Oct 05 16:46:46 2009 +0900 @@ -33,6 +33,8 @@ taskListImpl = new CellTaskListInfo; taskListImpl->init(machineNum*2); + activeTaskQueue = new TaskQueueInfo(); + htaskImpl = new CellHTaskInfo; htaskImpl->init(TASK_MAX_SIZE*2); @@ -60,13 +62,11 @@ void CellTaskManagerImpl::append_activeTask(HTaskPtr task) { - TaskQueuePtr q; - - q = taskQueueImpl->create(task); if (task->cpu_type == CPU_PPE) { ppeManager->append_activeTask(task); } else { - activeTaskQueue = TaskQueue::append(activeTaskQueue, q); + TaskQueuePtr q = taskQueueImpl->create(task); + activeTaskQueue->addLast(q); } } @@ -87,21 +87,18 @@ { // ここ...直すかな TaskListPtr list; - TaskQueuePtr queue; + TaskQueuePtr d; HTaskPtr htask; TaskPtr task; int speid; - queue = activeTaskQueue; - if (queue == NULL) { + if (activeTaskQueue->empty()) { return ; } - while (queue) { + while (TaskQueuePtr queue = activeTaskQueue->poll()) { htask = (HTaskPtr)queue->task; - d = queue; - queue = queue->next; if (htask->cpu_type == SPE_ANY) { speid = cur_anySpeid++; @@ -139,10 +136,10 @@ task->outData = htask->outData; task->self = (unsigned int)htask; #else - memcpy(task, htask, sizeof(Task)); + memcpy(task, (Task*)htask, sizeof(Task)); #endif - taskQueueImpl->free(d); + activeTaskQueue->free(queue); } activeTaskQueue = NULL; @@ -259,7 +256,7 @@ // であり、この場合もし SPE にタスクが残っていても // メインループから抜けてプログラム終了となってしまうので // ここでストップかけてます。 - } while (!ppeManager->activeTaskQueue && waitTaskQueue); + } while (ppeManager->activeTaskQueue->empty() && !waitTaskQueue->empty()); return ppeManager->get_runTaskList(); }
--- a/TaskManager/ChangeLog Mon Oct 05 12:24:07 2009 +0900 +++ b/TaskManager/ChangeLog Mon Oct 05 16:46:46 2009 +0900 @@ -1,3 +1,7 @@ +2009-10-05 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + TaskQueue のfree list の管理はシステムで一つであるべき。 + 2009-10-02 Shinji KONO <kono@ie.u-ryukyu.ac.jp> DrawSpan で、~DrawSpan() で、allocate したデータを DMA_WAIT
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Mon Oct 05 12:24:07 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Mon Oct 05 16:46:46 2009 +0900 @@ -86,7 +86,6 @@ FifoTaskManagerImpl::get_runTaskList() { TaskListPtr list, list_top; - TaskQueuePtr d; HTaskPtr htask; // HTask (PPE にある) TaskPtr task; // Task (SPE に送る Task) @@ -106,7 +105,7 @@ task = &list->tasks[list->length++]; - memcpy(task, htask, sizeof(Task)); + memcpy(task, (Task*)htask, sizeof(Task)); if (list->length >= TASK_MAX_SIZE) { TaskListPtr newList = taskListImpl->create(); @@ -114,7 +113,7 @@ list = newList; } - activeTaskQueue->free(d); + activeTaskQueue->free(queue); } mainTaskList = list_top;
--- a/TaskManager/kernel/ppe/SymTable.cc Mon Oct 05 12:24:07 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -#include <string.h> -#include "SymTable.h" - -SymTable::~SymTable(void) -{ - SymTbPtr tb; - - for (int i = 0; i < symtb_index; i++) { - tb = &symtb[i]; - delete [] tb->sym; - } - - delete [] symtb; -} - -void -SymTable::init(void) -{ - symtb = new SymTb[SYM_MAX_SIZE]; - symtb_index = 0; -} - -void -SymTable::set_symbol(const char *sym, FuncObject addr) -{ - SymTbPtr tb = &symtb[symtb_index++]; - - tb->sym = new char[strlen(sym)+1]; - memcpy(tb->sym, sym, strlen(sym)+1); - tb->address = addr; -} - -void -SymTable::set_func(int id, FuncObject addr) -{ - SymTbPtr tb = &symtb[id]; - - tb->address = addr; -} - -SymTable::FuncObject -SymTable::get_address(int fd) -{ - if (fd >= symtb_index) { - // Fix me - // error process - } - - return symtb[fd].address; -} - - -int -SymTable::get_fd(const char *sym) -{ - SymTbPtr tb; - - for (int i = 0; i < SYM_MAX_SIZE; i++) { - tb = &symtb[i]; - if (strcmp(tb->sym, sym) == 0) { - return i; - } - } - - return -1; -}
--- a/TaskManager/kernel/ppe/SymTable.h Mon Oct 05 12:24:07 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -#ifndef INCLUDED_SYMTABLE -#define INCLUDED_SYMTABLE - -#define SYM_MAX_SIZE 64 - -class SymTable { -public: - ~SymTable(void); - - typedef int (*FuncObject)(void *, void*); - - typedef struct sym_table { - char *sym; - FuncObject address; - } SymTb, *SymTbPtr; - - SymTbPtr symtb; - int symtb_index; - - void init(void); - void set_symbol(const char *sym, FuncObject addr); - void set_func(int id, FuncObject addr); - int get_fd(const char *sym); - FuncObject get_address(int fd); -}; - -#endif
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Mon Oct 05 12:24:07 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Mon Oct 05 16:46:46 2009 +0900 @@ -68,7 +68,7 @@ master->wait_me->addLast(s); slave->wait_i->addLast(m); - m->waiter = s; + s->waiter = m; } /**
--- a/TaskManager/kernel/ppe/TaskQueueInfo.cc Mon Oct 05 12:24:07 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskQueueInfo.cc Mon Oct 05 16:46:46 2009 +0900 @@ -18,6 +18,7 @@ // 最初の一つは自分 first = last = this; next = prev = this; + waiter = NULL; return 0; } @@ -57,6 +58,7 @@ q->task = task; q->next = q->prev = NULL; + q->waiter = NULL; return q; } @@ -65,6 +67,7 @@ void TaskQueueInfo::free(TaskQueuePtr q) { + if (!q) return; q->next = freeTaskQueue; q->prev = NULL; freeTaskQueue = q; @@ -137,6 +140,8 @@ int TaskQueueInfo::remove(TaskQueue* e) { + if (!e) return 0; + e->prev->next = e->next; e->next->prev = e->prev;
--- a/example/dependency_task/main.cc Mon Oct 05 12:24:07 2009 +0900 +++ b/example/dependency_task/main.cc Mon Oct 05 16:46:46 2009 +0900 @@ -16,7 +16,7 @@ void run_start(TaskManager *manager) { - HTaskPtr t_exec; + HTaskPtr t_exec[2]; HTaskPtr t_print; idata = (int*)manager->allocate(sizeof(int)*length*2); @@ -31,21 +31,23 @@ // idata を二つに分けて計算する for (int i = 0; i < 2; i++) { - t_exec = manager->create_task(TASK_EXEC); - t_exec->add_inData(&idata[length*i], sizeof(int)*length); - t_exec->add_outData(&idata[length*i], sizeof(int)*length); - t_exec->add_param(length); - t_exec->add_param(13*(i+1)); - t_exec->set_cpu(SPE_ANY); + t_exec[i] = manager->create_task(TASK_EXEC); + t_exec[i]->add_inData(&idata[length*i], sizeof(int)*length); + t_exec[i]->add_outData(&idata[length*i], sizeof(int)*length); + t_exec[i]->add_param(length); + t_exec[i]->add_param(13*(i+1)); + t_exec[i]->set_cpu(SPE_ANY); if (depend_flg) - t_print->wait_for(t_exec); - - t_exec->spawn(); + t_print->wait_for(t_exec[i]); } // add Active Queue t_print->spawn(); + + for (int i = 0; i < 2; i++) { + t_exec[i]->spawn(); + } } int