Mercurial > hg > Game > Cerium
changeset 5:75f184d16fa5
*** empty log message ***
author | gongo |
---|---|
date | Tue, 05 Feb 2008 23:32:43 +0900 |
parents | 3b57f13a207a |
children | 39ce245235d4 |
files | TaskManager/Fifo/FifoTaskInfo.cc TaskManager/Fifo/MailManager.cc TaskManager/Makefile.def TaskManager/Test/Sum/Makefile TaskManager/Test/Sum/main.cpp TaskManager/kernel/ppe/TaskInfo.cc TaskManager/kernel/ppe/TaskManagerImpl.cc include/TaskManager/TaskInfo.h include/TaskManager/task.h |
diffstat | 9 files changed, 60 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoTaskInfo.cc Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/Fifo/FifoTaskInfo.cc Tue Feb 05 23:32:43 2008 +0900 @@ -6,7 +6,7 @@ FifoTaskInfo::init(void) { init_pool_taskQueue(TASK_MAX_SIZE*4); - init_pool_task(TASK_MAX_SIZE*2); + init_pool_task(TASK_MAX_SIZE); init_pool_taskList(2); machineTaskList = get_free_taskList();
--- a/TaskManager/Fifo/MailManager.cc Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/Fifo/MailManager.cc Tue Feb 05 23:32:43 2008 +0900 @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> #include "MailManager.h" int @@ -15,7 +16,8 @@ { MailQueuePtr q; - q = new MailQueue[num+1]; + //q = new MailQueue[num+1]; + q = (MailQueuePtr)malloc(sizeof(MailQueue)*(num+1)); if (q == NULL) { return -1;
--- a/TaskManager/Makefile.def Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/Makefile.def Tue Feb 05 23:32:43 2008 +0900 @@ -19,8 +19,8 @@ IMPL_CELL_SRCS = $(wildcard $(IMPL_CELL_DIR)/*.cpp) IMPL_CELL_OBJS = $(IMPL_CELL_SRCS:.cpp=.o) -CC = g++ -CFLAGS = -Wall -O2 -g +CC = ccmalloc --no-wrapper g++ +CFLAGS = -Wall -g LIBS = INCLUDE = -I../include/TaskManager \ No newline at end of file
--- a/TaskManager/Test/Sum/Makefile Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/Test/Sum/Makefile Tue Feb 05 23:32:43 2008 +0900 @@ -1,8 +1,9 @@ TARGET = main -CC = g++ +CC = ccmalloc --no-wrapper g++ CFLAGS = -Wall -O2 -g -LIBS = -L../../ -lmanager +LIBS = -L../../ -lmanager ~/src/ccmalloc-0.4.0/obj/ccmalloc-g++.o \ + ~/src/ccmalloc-0.4.0/lib/libccmalloc.a -ldl INCLUDE = -I../../../include/TaskManager
--- a/TaskManager/Test/Sum/main.cpp Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/Test/Sum/main.cpp Tue Feb 05 23:32:43 2008 +0900 @@ -1,4 +1,5 @@ #include <stdio.h> +#include <string.h> #include "TaskManager.h" //#include "ppe_prof.h"
--- a/TaskManager/kernel/ppe/TaskInfo.cc Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/kernel/ppe/TaskInfo.cc Tue Feb 05 23:32:43 2008 +0900 @@ -1,3 +1,5 @@ +#include <stdio.h> +#include <stdlib.h> #include "TaskInfo.h" TaskInfo::TaskInfo(int num) @@ -12,6 +14,8 @@ int TaskInfo::init_pool_taskList(int num) { + printf("pool_taskList: %d\n", num); + if (!taskListPool) { return extend_pool_taskList(num); } @@ -45,6 +49,8 @@ int TaskInfo::init_pool_taskQueue(int num) { + printf("pool_taskQueue: %d\n", num); + if (!taskQueuePool) { return extend_pool_taskQueue(num); } @@ -56,7 +62,8 @@ { TaskQueuePtr q; - q = new TaskQueue[num+1]; + //q = new TaskQueue[num+1]; + q = (TaskQueuePtr)malloc(sizeof(TaskQueue)*(num+1)); if (q == NULL) { return -1; @@ -92,24 +99,40 @@ return q; } -/** - * initialize pool of task_queue - * @return if (success) ? 0 : -1 - */ + int TaskInfo::init_pool_task(int num) { -#if 0 - taskPool = new Task[num]; + printf("pool_task: %d\n", num); if (!taskPool) { - return -1; - } else { - return 0; + return extend_pool_task(num); } -#endif + return 0; +} + +int +TaskInfo::extend_pool_task(int num) +{ + HTaskPtr q; + + //q = new HTask[num+1]; + q = (HTaskPtr)malloc(sizeof(HTask)*(num+1)); - HTask::initMemPool(); + if (q == NULL) { + return -1; + } + q->next = taskPool; + taskPool = q; + + /* Connect all free queue in the pool */ + q = taskPool + 1; + for (q = taskPool + 1; num-- > 0; q++) { + q->next = q + 1; + } + q->next = freeTask; + freeTask = taskPool + 1; + return 0; } @@ -119,8 +142,13 @@ unsigned long long out_addr) { HTaskPtr q; + + if (!freeTask) { + extend_pool_task(100); + } + q = freeTask; + freeTask = freeTask->next; - q = new HTask; // from memorypool q->command = cmd; q->in_addr = in_addr; q->out_addr = out_addr; @@ -149,7 +177,8 @@ void TaskInfo::free_task(HTaskPtr q) { - delete q; + q->next = freeTask; + freeTask = q; } /**
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Tue Feb 05 20:34:53 2008 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Tue Feb 05 23:32:43 2008 +0900 @@ -1,3 +1,4 @@ +#include <stdio.h> #include "TaskManagerImpl.h" void
--- a/include/TaskManager/TaskInfo.h Tue Feb 05 20:34:53 2008 +0900 +++ b/include/TaskManager/TaskInfo.h Tue Feb 05 23:32:43 2008 +0900 @@ -20,6 +20,9 @@ TaskQueuePtr waitTaskQueue; TaskQueuePtr activeTaskQueue; + HTaskPtr taskPool; + HTaskPtr freeTask; + /* function */ virtual void init(void) = 0; @@ -36,6 +39,7 @@ // task int init_pool_task(int num); + int extend_pool_task(int num); HTaskPtr get_free_task(int cmd, int size, unsigned long long in_addr, unsigned long long out_addr);
--- a/include/TaskManager/task.h Tue Feb 05 20:34:53 2008 +0900 +++ b/include/TaskManager/task.h Tue Feb 05 23:32:43 2008 +0900 @@ -1,8 +1,6 @@ #ifndef INCLUDED_TASK #define INCLUDED_TASK -#include "memorypool.h" - #define TASK_MAX_SIZE 100 typedef struct task_queue TaskQueue, *TaskQueuePtr; @@ -16,7 +14,7 @@ HTaskPtr self; } Task, *TaskPtr; -struct htask : public UseMemoryPool<struct htask> { +struct htask { int command; int in_size; unsigned int in_addr; @@ -24,6 +22,7 @@ TaskQueuePtr wait_me; // List of task waiting for me TaskQueuePtr wait_i; // List of task for which I am waiting void (*post_func)(void); + struct htask *next; }; struct task_queue {