Mercurial > hg > Game > Cerium
changeset 50:7927e00fb8e2
*** empty log message ***
author | gongo |
---|---|
date | Fri, 15 Feb 2008 19:36:08 +0900 |
parents | 64ef030deb22 |
children | c964110017c8 |
files | TaskManager/Fifo/FifoDmaManager.cc TaskManager/Fifo/MailManager.cc TaskManager/Makefile.def TaskManager/Test/simple_render/main.cpp TaskManager/Test/simple_render/viewer.cpp TaskManager/kernel/ppe/MailManager.cc TaskManager/kernel/ppe/TaskManager.cc TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/schedule/MainScheduler.cc TaskManager/kernel/schedule/Scheduler.cc include/TaskManager/MailManager.h include/TaskManager/MainScheduler.h include/TaskManager/Scheduler.h include/TaskManager/TaskManagerImpl.h include/TaskManager/error.h |
diffstat | 15 files changed, 137 insertions(+), 143 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoDmaManager.cc Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/Fifo/FifoDmaManager.cc Fri Feb 15 19:36:08 2008 +0900 @@ -31,8 +31,9 @@ { //spu_writech(SPU_WrOutMbox, data); - mail_sendQueue = append_mailQueue(mail_sendQueue, - mailManager->create_mail(data)); + mail_sendQueue + = MailManager::append_mailQueue(mail_sendQueue, + mailManager->create(data)); } unsigned int @@ -50,7 +51,7 @@ mail_recvQueue = mail_recvQueue->next; ret = q->data; - mailManager->free_mailQueue(q); + mailManager->free(q); return ret; }
--- a/TaskManager/Fifo/MailManager.cc Fri Feb 15 18:51:35 2008 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "MailManager.h" - -MailManager::MailManager(void) -{ - mailQueuePool = NULL; - freeMailQueue = NULL; -} - -MailManager::~MailManager(void) -{ - //destroy_mailQueue(); -} - -int -MailManager::init_pool_mailQueue(int num) -{ - if (!mailQueuePool) { - return extend_pool_mailQueue(num); - } - return 0; -} - -int -MailManager::extend_pool_mailQueue(int num) -{ - MailQueuePtr q; - - q = (MailQueuePtr)malloc(sizeof(MailQueue)*(num+1)); - - if (q == NULL) { - return -1; - } - q->next = mailQueuePool; - mailQueuePool = q; - - /* Connect all free queue in the pool */ - for (q = mailQueuePool + 1; --num > 0; q++) { - q->next = q + 1; - } - q->next = freeMailQueue; - freeMailQueue = mailQueuePool + 1; - - return 0; -} - -MailQueuePtr -MailManager::create_mail(unsigned int data) -{ - return get_free_mailQueue(data); -} - -MailQueuePtr -MailManager::get_free_mailQueue(unsigned int data) -{ - MailQueuePtr q; - - if (!freeMailQueue) { - extend_pool_mailQueue(30); - } - q = freeMailQueue; - freeMailQueue = freeMailQueue->next; - - q->data = data; - q->next = NULL; - - return q; -} - -void -MailManager::free_mailQueue(MailQueuePtr q) -{ - q->next = freeMailQueue; - freeMailQueue = q; -} - - -void -MailManager::destroy_mailQueue(void) -{ - MailQueuePtr q; - - for (q = mailQueuePool; q; q = q->next) { - free(q); - } - freeMailQueue = mailQueuePool = NULL; -} - - -MailQueuePtr -append_mailQueue(MailQueuePtr list, MailQueuePtr q) -{ - MailQueuePtr p = list; - - if (p == NULL) { - return q; - } else { - while(p->next) p = p->next; - p->next = q; - return list; - } -}
--- a/TaskManager/Makefile.def Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/Makefile.def Fri Feb 15 19:36:08 2008 +0900 @@ -24,7 +24,7 @@ IMPL_CELL_OBJS = $(IMPL_CELL_SRCS:.cpp=.o) CC = g++ -CFLAGS = -Wall -g# -D_PPE_DEBUG -DDEBUG +CFLAGS = -O9 -Wall -g# -D_PPE_DEBUG -DDEBUG LIBS = INCLUDE = -I../include/TaskManager \ No newline at end of file
--- a/TaskManager/Test/simple_render/main.cpp Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/Test/simple_render/main.cpp Fri Feb 15 19:36:08 2008 +0900 @@ -107,6 +107,7 @@ { __debug("[%s]\n", __FUNCTION__); delete screen; + delete manager; return 0; } @@ -162,6 +163,7 @@ fd_init = manager->open("init"); task_init = manager->create_task(fd_init, 0, 0, 0, NULL); manager->spawn_task(task_init); + manager->run(); finish(NULL, NULL);
--- a/TaskManager/Test/simple_render/viewer.cpp Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/Test/simple_render/viewer.cpp Fri Feb 15 19:36:08 2008 +0900 @@ -349,7 +349,7 @@ Viewer::run_finish(void) { if (arg->this_time != arg->start_time) { - cout<< ((float)arg->frames/(arg->this_time-arg->start_time))*1000.0 << " FPS\n"; + cout<< (((float)arg->frames)/(arg->this_time-arg->start_time))*1000.0 << " FPS\n"; } SDL_FreeSurface(arg->bitmap);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/ppe/MailManager.cc Fri Feb 15 19:36:08 2008 +0900 @@ -0,0 +1,91 @@ +#include <stdio.h> +#include <stdlib.h> +#include "MailManager.h" + +MailManager::MailManager(void) + :mailQueuePool(NULL), freeMailQueue(NULL) {} + +MailManager::~MailManager(void) { destroy(); } + +int +MailManager::init(int num) +{ + if (!mailQueuePool) { + return extend_pool(num); + } + return 0; +} + +int +MailManager::extend_pool(int num) +{ + MailQueuePtr q; + + q = (MailQueuePtr)malloc(sizeof(MailQueue)*(num+1)); + + if (q == NULL) { + return -1; + } + q->next = mailQueuePool; + mailQueuePool = q; + + /* Connect all free queue in the pool */ + for (q = mailQueuePool + 1; --num > 0; q++) { + q->next = q + 1; + } + q->next = freeMailQueue; + freeMailQueue = mailQueuePool + 1; + + return 0; +} + +MailQueuePtr +MailManager::create(unsigned int data) +{ + MailQueuePtr q; + + if (!freeMailQueue) { + extend_pool(30); + } + q = freeMailQueue; + freeMailQueue = freeMailQueue->next; + + q->data = data; + q->next = NULL; + + return q; +} + +void +MailManager::free(MailQueuePtr q) +{ + q->next = freeMailQueue; + freeMailQueue = q; +} + + +void +MailManager::destroy(void) +{ + MailQueuePtr q; + + for (q = mailQueuePool; q; q = q->next) { + free(q); + } + freeMailQueue = mailQueuePool = NULL; +} + + +MailQueuePtr +MailManager::append_mailQueue(MailQueuePtr list, MailQueuePtr q) +{ + MailQueuePtr p = list; + + if (p == NULL) { + return q; + } else { + while(p->next) p = p->next; + p->next = q; + return list; + } +}
--- a/TaskManager/kernel/ppe/TaskManager.cc Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.cc Fri Feb 15 19:36:08 2008 +0900 @@ -93,7 +93,6 @@ } - // ここは、バイナリから自動的に読めるとうれしいけど // どうやるんだろうね。ユーザに追加させるのはめんどくさい void
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Fri Feb 15 19:36:08 2008 +0900 @@ -10,11 +10,18 @@ TaskManagerImpl::TaskManagerImpl(int num) : machineNum(num) {} +TaskManagerImpl::~TaskManagerImpl(void) +{ + delete mailManager; + delete scheduler; + delete taskInfo; +} + void TaskManagerImpl::init(void) { mailManager = new MailManager(); - mailManager->init_pool_mailQueue(20); + mailManager->init(20); scheduler = new MainScheduler(); scheduler->init(); @@ -116,12 +123,12 @@ // 暫定 list = set_task(); - list_mail = mailManager->create_mail((unsigned int)list); - in_mail_list = append_mailQueue(in_mail_list, list_mail); + list_mail = mailManager->create((unsigned int)list); + in_mail_list = MailManager::append_mailQueue(in_mail_list, list_mail); do { - sentinel = mailManager->create_mail(MY_SPE_COMMAND_EXIT); - in_mail_list = append_mailQueue(in_mail_list, sentinel); + sentinel = mailManager->create(MY_SPE_COMMAND_EXIT); + in_mail_list = MailManager::append_mailQueue(in_mail_list, sentinel); scheduler->send_mailList(in_mail_list); scheduler->run(); @@ -151,8 +158,8 @@ __debug_ppe("[FIFO] finish\n"); next_list = set_task(); if (next_list != NULL) { - d = mailManager->create_mail((unsigned int)next_list); - ret = append_mailQueue(ret, d); + d = mailManager->create((unsigned int)next_list); + ret = MailManager::append_mailQueue(ret, d); } } else { __debug_ppe("[PPE] recv from : 0x%x\n", data); @@ -162,7 +169,7 @@ d = q; q = q->next; - mailManager->free_mailQueue(d); + mailManager->free(d); } return ret;
--- a/TaskManager/kernel/schedule/MainScheduler.cc Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/kernel/schedule/MainScheduler.cc Fri Feb 15 19:36:08 2008 +0900 @@ -34,14 +34,3 @@ { return ((FifoDmaManager*)connector)->mail_sendQueue; } - -void -MainScheduler::finish(void) -{ - free(listBuf[0]); - free(listBuf[1]); - free(readBuf[0]); - free(readBuf[1]); - free(writeBuf[0]); - free(writeBuf[1]); -}
--- a/TaskManager/kernel/schedule/Scheduler.cc Fri Feb 15 18:51:35 2008 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Feb 15 19:36:08 2008 +0900 @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> #include "Scheduler.h" #include "SchedNop.h" #include "error.h" @@ -21,8 +22,6 @@ task2 = new SchedNop(); task3 = new SchedNop(); - fprintf(stderr, " ****** scheduler start ******\n"); - // main loop do { __debug("----------\n"); @@ -38,8 +37,18 @@ delete task3; delete task2; +} - fprintf(stderr, " ****** scheduler finish ******\n"); + +void +Scheduler::finish(void) +{ + free(listBuf[0]); + free(listBuf[1]); + free(readBuf[0]); + free(readBuf[1]); + free(writeBuf[0]); + free(writeBuf[1]); } TaskListPtr
--- a/include/TaskManager/MailManager.h Fri Feb 15 18:51:35 2008 +0900 +++ b/include/TaskManager/MailManager.h Fri Feb 15 19:36:08 2008 +0900 @@ -13,19 +13,19 @@ ~MailManager(void); /* functions */ - int init_pool_mailQueue(int num); - int extend_pool_mailQueue(int num); - MailQueuePtr create_mail(unsigned int data); - MailQueuePtr get_free_mailQueue(unsigned int data); - void free_mailQueue(MailQueuePtr q); - void destroy_mailQueue(void); + int init(int num); + MailQueuePtr create(unsigned int data); + void free(MailQueuePtr q); + static MailQueuePtr append_mailQueue(MailQueuePtr list, MailQueuePtr q); private: /* variables */ MailQueuePtr mailQueuePool; MailQueuePtr freeMailQueue; + + /* functions */ + int extend_pool(int num); + void destroy(void); }; -extern MailQueuePtr append_mailQueue(MailQueuePtr list, MailQueuePtr q); - #endif
--- a/include/TaskManager/MainScheduler.h Fri Feb 15 18:51:35 2008 +0900 +++ b/include/TaskManager/MainScheduler.h Fri Feb 15 19:36:08 2008 +0900 @@ -12,7 +12,6 @@ class MainScheduler : public Scheduler { public: void init_impl(void); - void finish(void); void set_mailManager(MailManager *); void send_mailList(MailQueuePtr mail_list); MailQueuePtr recv_mailList(void);
--- a/include/TaskManager/Scheduler.h Fri Feb 15 18:51:35 2008 +0900 +++ b/include/TaskManager/Scheduler.h Fri Feb 15 19:36:08 2008 +0900 @@ -37,7 +37,7 @@ void init(void); void run(void); virtual void init_impl(void) = 0; - virtual void finish(void) = 0; + void finish(void); TaskListPtr get_curListBuf(void); void* get_curReadBuf(void);
--- a/include/TaskManager/TaskManagerImpl.h Fri Feb 15 18:51:35 2008 +0900 +++ b/include/TaskManager/TaskManagerImpl.h Fri Feb 15 19:36:08 2008 +0900 @@ -17,7 +17,7 @@ public: /* constructor */ TaskManagerImpl(int num = 1); - virtual ~TaskManagerImpl(void) {} + virtual ~TaskManagerImpl(void); /* variables */ int machineNum;
--- a/include/TaskManager/error.h Fri Feb 15 18:51:35 2008 +0900 +++ b/include/TaskManager/error.h Fri Feb 15 19:36:08 2008 +0900 @@ -1,7 +1,7 @@ #ifdef DEBUG # include <stdio.h> # define __debug(...) do { \ - printf(__VA_ARGS__); \ + fprintf(stderr, __VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug(...)