Mercurial > hg > Game > Cerium
changeset 57:1f8a23cdeec3
*** empty log message ***
author | gongo |
---|---|
date | Sat, 16 Feb 2008 19:40:20 +0900 |
parents | 4d554afb22b6 |
children | 7492eb28b577 |
files | TaskManager/Cell/CellBufferManager.cc TaskManager/Cell/CellScheduler.cc TaskManager/Cell/CellTaskInfo.cc TaskManager/Cell/CellTaskListInfo.cc TaskManager/Cell/CellTaskManagerImpl.cc include/TaskManager/CellTaskListInfo.h |
diffstat | 6 files changed, 163 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/CellBufferManager.cc Sat Feb 16 19:40:20 2008 +0900 @@ -0,0 +1,75 @@ +#include <stdio.h> +#include <stdlib.h> +#include "CellBufferManager.h" +#include "CellTaskListInfo.h" + +void +BufferManager::init(void) +{ + tlistImpl = new CellTaskListInfo; + tqueueImpl = new TaskQueueInfo; + htaskImpl = new HTaskInfo; + + tlistImpl->init(machineNum*2); + tqueueImpl->init(TASK_MAX_SIZE*4); + htaskImpl->init(TASK_MAX_SIZE*2); + + machineTaskList = new TaskListPtr[machineNum]; + + for (int i = 0; i < machineNum; i++) { + machineTaskList[i] = tlistImpl->create(); + } +} + +#if 0 // 継承するかもしれないので保存 +void +BufferManager::append_activeTask(HTaskPtr task) +{ + TaskQueuePtr q; + + q = tqueueImpl->create(task); + activeTaskQueue = tqueueImpl->append(activeTaskQueue, q); +} + +void +BufferManager::append_waitTask(HTaskPtr task) +{ + TaskQueuePtr q; + + q = tqueueImpl->create(task); + waitTaskQueue = tqueueImpl->append(waitTaskQueue, q); +} + +TaskListPtr +BufferManager::get_available_taskList(void) +{ + TaskListPtr list, q; + + list = machineTaskList[0]; + + while (list->next) list = list->next; + + if (list->length < TASK_MAX_SIZE) { + return list; + } else { + q = tlistImpl->create(); + machineTaskList[0] = tlistImpl->append(machineTaskList[0], q); + return q; + } +} + +void +BufferManager::clear_taskList(void) +{ + TaskListPtr p, p1; + + machineTaskList[0]->length = 0; + + p = machineTaskList[0]->next; + while (p) { + p1 = p; + p = p->next; + tlistImpl->free(p1); + } +} +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/CellScheduler.cc Sat Feb 16 19:40:20 2008 +0900 @@ -0,0 +1,17 @@ +#include <malloc.h> +#include "CellScheduler.h" +#include "CellDmaManager.h" +#include "error.h" + +void +CellScheduler::init(MailManager *m) +{ + connector = new CellDmaManager; + + for (int i = 0; i < 2; i++) { + listBuf[i] = (TaskListPtr)memalign(DEFAULT_ALIGNMENT, + sizeof(TaskListPtr)); + readBuf[i] = memalign(DEFAULT_ALIGNMENT, DMA_MAX_SIZE); + writeBuf[i] = memalign(DEFAULT_ALIGNMENT, DMA_MAX_SIZE); + } +}
--- a/TaskManager/Cell/CellTaskInfo.cc Sat Feb 16 19:00:53 2008 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "CellTaskInfo.h" - -#define ROUND_UP_ALIGN(value, alignment) \ - (((value) + ((alignment) - 1))&(~((alignment)-1))) - -#define NEXT_ADDR(addr, size) \ - (TaskListPtr)((int)(addr) + (size)) -int -CellTaskInfo::extend_pool_taskList(int num) -{ - TaskListPtr q, p; - int unit_size; - - - unit_size = (ROUND_UP_ALIGN(sizeof(TaskList), 16)); - posix_memalign((void**)&q, 16, unit_size*(num+1)); - - if (q == NULL) { - return -1; - } - - q->next = taskListPool; - taskListPool = q; - - /* Connect all free pack_list in the pool */ - q = NEXT_ADDR(taskListPool,unit_size); // q = taskListPool + 1; - for (; --num > 0; q = NEXT_ADDR(q + unit_size)) { - q->next = NEXT_ADDR(q, unit_size) // q->next = q + 1; - } - q->next = freeTaskList; - freeTaskList = NEXT_ADDR(taskListPool, unit_size); - - return 0; -} - -TaskListPtr -CellTaskInfo::get_available_taskList(void) -{ - TaskListPtr list, q; - - list = machineTaskList[0]; - - while (list->next) list = list->next; - - if (list->length < TASK_MAX_SIZE) { - return list; - } else { - q = get_free_taskList(); - machineTaskList[0] = append_taskList(machineTaskList[0], q); - return q; - } -} - -void -CellTaskInfo::clear_taskList(void) -{ - TaskListPtr p, p1; - - machineTaskList[0]->length = 0; - - p = machineTaskList[0]->next; - while (p) { - p1 = p; - p = p->next; - free_taskList(p1); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/CellTaskListInfo.cc Sat Feb 16 19:40:20 2008 +0900 @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <stdlib.h> +#include "CellTaskListInfo.h" + +int +CellTaskListInfo::extend_pool(int num) +{ + TaskListPtr q = NULL, p; + int unit_size; + + unit_size = (ROUND_UP_ALIGN(sizeof(TaskList), 16)); + posix_memalign((void**)&q, 16, unit_size*(num+1)); + + if (q == NULL) { + return -1; + } + + q->next = taskListPool; + taskListPool = q; + + /* Connect all free pack_list in the pool */ + q = NEXT_ADDR(taskListPool,unit_size); // q = taskListPool + 1; + for (; --num > 0; q = NEXT_ADDR(q + unit_size)) { + q->naext = NEXT_ADDR(q, unit_size); // q->next = q + 1; + } + q->next = freeTaskList; + freeTaskList = NEXT_ADDR(taskListPool, unit_size); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Sat Feb 16 19:40:20 2008 +0900 @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "CellTaskManagerImpl.h" +#include "types.h" + +void +CellTaskManagerImpl::init(void) +{ + TaskManagerImpl::init(); + + bufferManager = new CellBufferManager; + bufferManager->init(); +} + +void +CellTaskManagerImpl::spawn_task(HTaskPtr task) +{ + TaskManagerImpl::spawn_task(task); + //run(); +} + +TaskManagerImpl* +create_impl(int num) +{ + return new CellTaskManagerImpl(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/TaskManager/CellTaskListInfo.h Sat Feb 16 19:40:20 2008 +0900 @@ -0,0 +1,14 @@ +#ifndef INCLUDED_CELL_TASK_LIST_INFO +#define INCLUDED_CELL_TASK_LIST_INFO + +#ifndef INCLUDED_TASK_LIST_INFO +# include "TaskListInfo.h" +#endif + +class CellTaskListInfo : public TaskLisInfo { +public: + /* functions */ + virtual int extend_pool(int num); +}; + +#endif