Mercurial > hg > Members > kono > Cerium
changeset 45:494a19b053c5
*** empty log message ***
author | gongo |
---|---|
date | Fri, 15 Feb 2008 13:09:43 +0900 |
parents | b51daa049bc3 |
children | f154d9d07a42 |
files | TaskManager/kernel/ppe/BufferManager.cc include/TaskManager/BufferManager.h include/TaskManager/TaskInfo.h include/TaskManager/TaskManagerImpl.h |
diffstat | 4 files changed, 36 insertions(+), 169 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/BufferManager.cc Thu Feb 14 19:49:43 2008 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "BufferManager.h" -#include "error.h" - -BufferManager::BufferManager(int siz) -{ - buffer_db_size = siz*4; -} - -void -BufferManager::init(void) -{ - buffer_db = new void*[buffer_db_size]; - buffer_db_index = 0; -} - -/** - * Fix me - * アライメントできる create も必要 (spe 用に) - * あと、オブジェクトだったら new しないとだめか。 - * コンストラクタ呼ぶ必要があるのかー。 - * 汎用の allocate ってことは templete ?いやだー - */ -void* -BufferManager::create_buffer(int size) -{ - void *buf1, *buf2; - - buf1 = malloc(size); - buf2 = malloc(size); - - register_double_buffer(buf1, buf2); - - return buf1; -} - -void* -BufferManager::switch_buffer(void* cur) -{ - int next_index; - int max = buffer_db_size; - - for (int i = 0; i < buffer_db_size; i = i + 2) { - if (cur == buffer_db[i]) { - next_index = (int)(buffer_db[i+1]); - return buffer_db[i + next_index]; - } - } - - __debug_ppe("buffer 0x%x is not registered\n", (unsigned int)cur); - - return NULL; -} - -int -BufferManager::register_double_buffer(void *buf1, void *buf2) -{ - /** - * Fix me - * buffer_db_size 超えた時の処理 - * 今は単純に -1 < 0 を返す - */ - if (buffer_db_index == buffer_db_size) { - return -1; - } - - buffer_db[buffer_db_index++] = buf1; - buffer_db[buffer_db_index++] = (void*)2; - buffer_db[buffer_db_index++] = buf2; - buffer_db[buffer_db_index++] = (void*)-2; - - return 0; -}
--- a/include/TaskManager/BufferManager.h Thu Feb 14 19:49:43 2008 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -#ifndef INCLUDED_BUFFER_MANAGER -#define INCLUDED_BUFFER_MANAGER - -#if 0 -buffer database の中身 - -+-----------+ -| buffer 1 | -+-----------+ -| 2 | -+-----------+ -| buffer 2 | -+-----------+ -| -2 | -+-----------+ -| buffer 3 | -+-----------+ -| 2 | -+-----------+ -| buffer 4 | -+-----------+ -| -2 | -+-----------+ -| ... | - -各 buffer の次の buffer を取得する時は -buffer 1 が db[i] とすると - -next_index = db[i+1]; -next_buffer = db[i + next_index]; - -でとれると思ったり思わなかったり。 -各bufferでフラグを持つ必要なくなる(とおもってる) - -#endif - -class BufferManager { -public: - BufferManager(int siz = 10); - - void **buffer_db; - int buffer_db_size; - int buffer_db_index; - - void init(void); - void *create_buffer(int size); - void *switch_buffer(void* buffer); - int register_double_buffer(void *buf1, void *buf2); -}; - -#endif
--- a/include/TaskManager/TaskInfo.h Thu Feb 14 19:49:43 2008 +0900 +++ b/include/TaskManager/TaskInfo.h Fri Feb 15 13:09:43 2008 +0900 @@ -1,75 +1,66 @@ -#ifndef INCLUDED_TASK_INFO -#define INCLUDED_TASK_INFO +#ifndef INCLUDED_BUFFER_MANAGER +#define INCLUDED_BUFFER_MANAGER #ifndef INCLUDED_TASK # include "task.h" #endif -class TaskInfo { +#ifndef INCLUDED_TYPES +# include "types.h" +#endif + +#ifndef INCLUDED_TASK_LIST_INFO +# include "TaskListInfo.h" +#endif + +#ifndef INCLUDED_TASK_QUEUE_INFO +# include "TaskQueueInfo.h" +#endif + +#ifndef INCLUDED_HTask_INFO +# include "HTaskInfo.h" +#endif + +class BufferManager { public: /* constructor */ - TaskInfo(int num = 1); - virtual ~TaskInfo(void); + BufferManager(int num = 1); + virtual ~BufferManager(void); /* variables */ - TaskListPtr taskListPool; - TaskListPtr freeTaskList; - - TaskQueuePtr taskQueuePool; - TaskQueuePtr freeTaskQueue; + TaskListInfo *tlistImpl; + TaskQueueInfo *tqueueImpl; + HTaskInfo *htaskImpl; + + int machineNum; + TaskQueuePtr activeTaskQueue; TaskQueuePtr waitTaskQueue; - TaskQueuePtr activeTaskQueue; - - HTaskPtr taskPool; - HTaskPtr freeTask; - TaskListPtr *machineTaskList; /* function */ void init(void); - // task list - int init_taskList(int num); - virtual int extend_pool_taskList(int num) = 0; - virtual TaskListPtr get_available_taskList(void) = 0; - TaskListPtr get_free_taskList(void); + TaskQueuePtr create_taskQueue(HTaskPtr); + HTaskPtr create_task(int cmd, int siz, uint64 in, uint64 out); + void free_taskQueue(TaskQueuePtr); + void free_task(HTaskPtr); - // task queue - int init_taskQueue(int num); - TaskQueuePtr get_free_taskQueue(HTaskPtr); - int extend_pool_taskQueue(int num); - - // task - int init_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); + // task list + virtual TaskListPtr get_available_taskList(void); void finish(void); - void destroy_taskList(void); - void destroy_taskQueue(void); - void destroy_task(void); - virtual void clear_taskList(void) = 0; + virtual void clear_taskList(void); virtual void append_activeTask(HTaskPtr); virtual void append_waitTask(HTaskPtr); - void free_taskList(TaskListPtr q); - void free_taskQueue(TaskQueuePtr q); - void free_task(HTaskPtr q); - void check_task_finish(HTaskPtr task); void notify_wait_taskQueue(HTaskPtr depend, TaskQueuePtr list); TaskQueuePtr remove_taskQueue(TaskQueuePtr list, TaskQueuePtr task); TaskQueuePtr remove_taskQueue_eq_task(TaskQueuePtr list, HTaskPtr task); private: - int machineNum; }; -extern TaskQueuePtr append_taskQueue(TaskQueuePtr, TaskQueuePtr); -extern TaskListPtr append_taskList(TaskListPtr list, TaskListPtr q); - #endif
--- a/include/TaskManager/TaskManagerImpl.h Thu Feb 14 19:49:43 2008 +0900 +++ b/include/TaskManager/TaskManagerImpl.h Fri Feb 15 13:09:43 2008 +0900 @@ -21,9 +21,10 @@ /* variables */ int machineNum; - TaskInfo* taskInfo; + MailManager *mailManager; MainScheduler *scheduler; + BufferManager *taskInfo; /* functions */ virtual void init(void);