changeset 46:f154d9d07a42

*** empty log message ***
author gongo
date Fri, 15 Feb 2008 13:09:43 +0900
parents 494a19b053c5
children 8266445bdac2
files TaskManager/kernel/ppe/BufferManager.cc TaskManager/kernel/ppe/HTaskInfo.cc TaskManager/kernel/ppe/TaskInfo.cc TaskManager/kernel/ppe/TaskListInfo.cc TaskManager/kernel/ppe/TaskManager.cc TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskQueueInfo.cc include/TaskManager/BufferManager.h include/TaskManager/DmaManager.h include/TaskManager/FifoTaskInfo.h include/TaskManager/FifoTaskManagerImpl.h include/TaskManager/HTaskInfo.h include/TaskManager/TaskInfo.h include/TaskManager/TaskListInfo.h include/TaskManager/TaskManagerImpl.h include/TaskManager/TaskQueueInfo.h include/TaskManager/ppe_spe.h include/TaskManager/types.h
diffstat 18 files changed, 673 insertions(+), 499 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/BufferManager.cc	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,192 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "TaskInfo.h"
+
+BufferManager::BufferManager(int num)
+    :machineNum(num), activeTaskQueue(NULL), waitTaskQueue(NULL) {}
+
+BufferManager::~BufferManager(void) { finish(); }
+
+void
+BufferManager::init(void)
+{
+    tlistImpl  = new TaskListInfo;
+    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();
+    }
+}
+
+TaskQueuePtr
+BufferManager::create_taskQueue(HTaskPtr task)
+{
+    return tqueueImpl->create(task);
+}
+
+HTaskPtr
+BufferManager::create_task(int cmd, int siz, uint64 in_addr, uint64 out_addr)
+{
+    return htaskImpl->create(cmd, siz, in_addr, out_addr);
+}
+
+void
+BufferManager::free_taskQueue(TaskQueuePtr q)
+{
+    tqueueImpl->free(q);
+}
+
+void
+BufferManager::free_task(HTaskPtr task)
+{
+    htaskImpl->free(task);
+}
+
+void
+BufferManager::append_activeTask(HTaskPtr task)
+{
+    TaskQueuePtr q;
+
+    q = tqueueImpl->create(task);
+    activeTaskQueue = tqueueImpl->append(activeTaskQueue, q);
+}
+
+void
+BufferManager::finish(void)
+{
+    delete tlistImpl;
+    delete tqueueImpl;
+    delete htaskImpl;
+}
+
+void
+BufferManager::append_waitTask(HTaskPtr task)
+{
+    TaskQueuePtr q;
+
+    q = tqueueImpl->create(task);
+    waitTaskQueue = tqueueImpl->append(waitTaskQueue, q);
+}
+
+void
+BufferManager::check_task_finish(HTaskPtr task)
+{
+    notify_wait_taskQueue(task, task->wait_me);
+    task->post_func();
+
+    htaskImpl->free(task);
+}
+
+void
+BufferManager::notify_wait_taskQueue(HTaskPtr depend, TaskQueuePtr list)
+{
+    TaskQueuePtr p, d;
+    HTaskPtr task;
+    
+    p = list; // wait task list
+
+    while (p) {
+	task = p->task;
+	task->wait_i = remove_taskQueue_eq_task(task->wait_i, depend);
+	if (task->wait_i == NULL) {
+	    d = p;
+	    p = p->next;
+	    append_activeTask(task);
+	    waitTaskQueue = remove_taskQueue(waitTaskQueue, d);
+	} else {
+	    p = p->next;
+	}
+    }
+}
+
+TaskQueuePtr
+BufferManager::remove_taskQueue_eq_task(TaskQueuePtr list, HTaskPtr task)
+{
+    TaskQueuePtr p = list;
+    TaskQueuePtr p1;
+
+    if (!p) return p;
+
+    if (p->task == task) {
+	list = list->next;
+	tqueueImpl->free(p);
+    } else {
+	p1 = p->next;
+	while (p1 && p1->task && p1->task != task) {
+	    p1 = p1->next;
+	    p = p->next;
+	}
+	if (p1) {
+	    p->next = p1->next;
+	    tqueueImpl->free(p1);
+	}
+    }
+
+    return list;    
+}
+
+TaskQueuePtr
+BufferManager::remove_taskQueue(TaskQueuePtr list, TaskQueuePtr q)
+{
+    TaskQueuePtr p = list;
+    TaskQueuePtr p1;
+
+    if (!p) return p;
+
+    if (p == q) {
+	list = list->next;
+	tqueueImpl->free(p);
+    } else {
+	p1 = p->next;
+	while (p1 && p1 != q) {
+	    p1 = p1->next;
+	    p = p->next;
+	}
+	if (p1) {
+	    p->next = p1->next;
+	    tqueueImpl->free(p1);
+	}
+    }
+
+    return list;    
+}
+
+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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/HTaskInfo.cc	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "HTaskInfo.h"
+
+HTaskInfo::HTaskInfo(void)
+    :htaskPool(NULL), freeHTask(NULL) {}
+
+HTaskInfo::~HTaskInfo(void) { destroy(); }
+
+int
+HTaskInfo::init(int num)
+{
+    if (htaskPool == NULL) {
+	return extend_pool(num);
+    }
+    return 0;
+}
+
+/**
+ * Fix me
+ *   extend できる限界を設定するべき?
+ */
+int
+HTaskInfo::extend_pool(int num)
+{
+    HTaskPtr q = NULL;
+
+    q = (HTaskPtr)malloc(sizeof(HTask)*(num+1));
+
+    if (q == NULL) {
+	return -1;
+    }
+    q->next = htaskPool;
+    htaskPool = q;
+
+    /* Connect all free queue in the pool */
+    for (q = htaskPool + 1; --num > 0; q++) {
+	q->next = q + 1;
+    }
+    q->next = freeHTask;
+    freeHTask = htaskPool + 1;
+
+    return 0;
+}
+
+HTaskPtr
+HTaskInfo::create(int cmd, int size,
+		  unsigned long long in_addr,
+		  unsigned long long out_addr)
+{
+    HTaskPtr q;
+    
+    if (freeHTask == NULL) {
+	extend_pool(100);
+    }
+
+    q = freeHTask;
+    freeHTask = freeHTask->next;
+
+    q->command  = cmd;
+    q->in_addr  = in_addr;
+    q->out_addr = out_addr;
+    q->in_size  = size;
+    q->wait_me  = NULL;
+    q->wait_i   = NULL;
+    q->post_func = NULL;
+
+    return q;
+}
+
+void
+HTaskInfo::free(HTaskPtr q)
+{
+    q->next = freeHTask;
+    freeHTask = q;
+}
+
+void
+HTaskInfo::destroy(void)
+{
+    HTaskPtr q;
+
+    for (q = htaskPool; q; q = q->next) {
+	free(q);
+    }
+    freeHTask = htaskPool = NULL;
+}
--- a/TaskManager/kernel/ppe/TaskInfo.cc	Fri Feb 15 13:09:43 2008 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,381 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "TaskInfo.h"
-
-TaskInfo::TaskInfo(int num)
-{
-    machineNum = num;
-
-    taskListPool = NULL;
-    freeTaskList = NULL;
-
-    taskQueuePool = NULL;
-    freeTaskQueue = NULL;
-    activeTaskQueue = NULL;
-    waitTaskQueue = NULL;
-
-    taskPool = NULL;
-    freeTask = NULL;
-}
-
-TaskInfo::~TaskInfo(void)
-{
-    finish();
-}
-
-void
-TaskInfo::init(void)
-{
-    init_taskList(machineNum*2);
-    init_taskQueue(TASK_MAX_SIZE*4);
-    init_task(TASK_MAX_SIZE*2);
-
-    machineTaskList = new TaskListPtr[machineNum];
-
-    for (int i = 0; i < machineNum; i++) {
-	machineTaskList[i] = get_free_taskList();
-    }
-}
-
-/**
- * initialize pool of task_pack_list
- * @return if (success) ? 0 : -1
- */
-int
-TaskInfo::init_taskList(int num)
-{
-    if (!taskListPool) {
-	return extend_pool_taskList(num);
-    }
-    return 0;
-}
-
-/**
- * @return free list from pool of task_pack_list
- */
-TaskListPtr
-TaskInfo::get_free_taskList(void)
-{
-    TaskListPtr q;
-
-    if (!freeTaskList) {
-	extend_pool_taskList(10);
-    }
-    q = freeTaskList;
-    freeTaskList = freeTaskList->next;
-
-    q->length = 0;
-    q->next = 0;
-
-    return q;
-}
-
-/**
- * initialize pool of task_queue
- * @return if (success) ? 0 : -1
- */
-int
-TaskInfo::init_taskQueue(int num)
-{
-    if (!taskQueuePool) {
-	return extend_pool_taskQueue(num);
-    }
-    return 0;
-}
-
-int
-TaskInfo::extend_pool_taskQueue(int num)
-{
-    TaskQueuePtr q = NULL;
-
-    q = (TaskQueuePtr)malloc(sizeof(TaskQueue)*(num+1));
-
-    if (q == NULL) {
-	return -1;
-    }
-    q->next = taskQueuePool;
-    taskQueuePool = q;
-
-    /* Connect all free queue in the pool */
-    for (q = taskQueuePool + 1; --num > 0; q++) {
-	q->next = q + 1;
-    }
-    q->next = freeTaskQueue;
-    freeTaskQueue = taskQueuePool + 1;
-
-    return 0;
-}
-
-TaskQueuePtr
-TaskInfo::get_free_taskQueue(HTaskPtr task)
-{
-    TaskQueuePtr q;
- 
-    if (!freeTaskQueue) {
-	extend_pool_taskQueue(100);
-    }
-    q = freeTaskQueue;
-    freeTaskQueue = freeTaskQueue->next;
-
-    q->task = task;
-    q->next = NULL;
-
-    return q;
-}
-
-
-int
-TaskInfo::init_task(int num)
-{
-    if (!taskPool) {
-	return extend_pool_task(num);
-    }
-    return 0;
-}
-
-int
-TaskInfo::extend_pool_task(int num)
-{
-    HTaskPtr q = NULL;
-
-    q = (HTaskPtr)malloc(sizeof(HTask)*(num+1));
-
-    if (q == NULL) {
-	return -1;
-    }
-    q->next = taskPool;
-    taskPool = q;
-
-    /* Connect all free queue in the pool */
-    for (q = taskPool + 1; --num > 0; q++) {
-	q->next = q + 1;
-    }
-    q->next = freeTask;
-    freeTask = taskPool + 1;
-
-    return 0;
-}
-
-HTaskPtr
-TaskInfo::get_free_task(int cmd, int size,
-			unsigned long long in_addr,
-			unsigned long long out_addr)
-{
-    HTaskPtr q;
- 
-    if (!freeTask) {
-	extend_pool_task(100);
-    }
-    q = freeTask;
-    freeTask = freeTask->next;
-
-    q->command  = cmd;
-    q->in_addr  = in_addr;
-    q->out_addr = out_addr;
-    q->in_size  = size;
-    q->wait_me  = NULL;
-    q->wait_i   = NULL;
-    q->post_func = NULL;
-
-    return q;
-}
-
-void
-TaskInfo::free_taskList(TaskListPtr q)
-{
-    q->next = freeTaskList;
-    freeTaskList = q;
-}
-
-void
-TaskInfo::free_taskQueue(TaskQueuePtr q)
-{
-    q->next = freeTaskQueue;
-    freeTaskQueue = q;
-}
-
-void
-TaskInfo::free_task(HTaskPtr q)
-{
-    q->next = freeTask;
-    freeTask = q;
-}
-
-/**
- * [task] is added to active_task
- */
-void
-TaskInfo::append_activeTask(HTaskPtr task)
-{
-    TaskQueuePtr q;
-
-    q = get_free_taskQueue(task);
-    activeTaskQueue = append_taskQueue(activeTaskQueue, q);
-}
-
-/**
- * [task] is added to wait_task
- */
-void
-TaskInfo::append_waitTask(HTaskPtr task)
-{
-    TaskQueuePtr q;
-
-    q = get_free_taskQueue(task);
-    waitTaskQueue = append_taskQueue(waitTaskQueue, q);
-}
-
-void
-TaskInfo::check_task_finish(HTaskPtr task)
-{
-    notify_wait_taskQueue(task, task->wait_me);
-    task->post_func();
-
-    free_task(task);
-}
-
-void
-TaskInfo::notify_wait_taskQueue(HTaskPtr depend, TaskQueuePtr list)
-{
-    TaskQueuePtr p, d;
-    HTaskPtr task;
-    
-    p = list; // wait task list
-
-    while (p) {
-	task = p->task;
-	task->wait_i = remove_taskQueue_eq_task(task->wait_i, depend);
-	if (task->wait_i == NULL) {
-	    d = p;
-	    p = p->next;
-	    append_activeTask(task);
-	    waitTaskQueue = remove_taskQueue(waitTaskQueue, d);
-	} else {
-	    p = p->next;
-	}
-    }
-}
-
-TaskQueuePtr
-TaskInfo::remove_taskQueue_eq_task(TaskQueuePtr list, HTaskPtr task)
-{
-    TaskQueuePtr p = list;
-    TaskQueuePtr p1;
-
-    if (!p) return p;
-
-    if (p->task == task) {
-	list = list->next;
-	free_taskQueue(p);
-    } else {
-	p1 = p->next;
-	while (p1 && p1->task && p1->task != task) {
-	    p1 = p1->next;
-	    p = p->next;
-	}
-	if (p1) {
-	    p->next = p1->next;
-	    free_taskQueue(p1);
-	}
-    }
-
-    return list;    
-}
-
-TaskQueuePtr
-TaskInfo::remove_taskQueue(TaskQueuePtr list, TaskQueuePtr q)
-{
-    TaskQueuePtr p = list;
-    TaskQueuePtr p1;
-
-    if (!p) return p;
-
-    if (p == q) {
-	list = list->next;
-	free_taskQueue(p);
-    } else {
-	p1 = p->next;
-	while (p1 && p1 != q) {
-	    p1 = p1->next;
-	    p = p->next;
-	}
-	if (p1) {
-	    p->next = p1->next;
-	    free_taskQueue(p1);
-	}
-    }
-
-    return list;    
-}
-
-
-void
-TaskInfo::finish(void)
-{
-    //destroy_taskList();
-    //destroy_taskQueue();
-    //destroy_task();
-
-    //delete [] machineTaskList;
-}
-
-void
-TaskInfo::destroy_taskList(void)
-{
-    TaskListPtr q;
-
-    for (q = taskListPool; q; q = q->next) {
-	free(q);
-    }
-    freeTaskList = taskListPool = NULL;
-}
-
-void
-TaskInfo::destroy_taskQueue(void)
-{
-    TaskQueuePtr q;
-
-    for (q = taskQueuePool; q; q = q->next) {
-	free(q);
-    }
-    freeTaskQueue = taskQueuePool = NULL;
-}
-
-void
-TaskInfo::destroy_task(void)
-{
-    HTaskPtr q;
-
-    for (q = taskPool; q; q = q->next) {
-	free(q);
-    }
-    freeTask = taskPool = NULL;
-}
-
-TaskListPtr
-append_taskList(TaskListPtr list, TaskListPtr q)
-{
-    TaskListPtr p = list;
-
-    if (!p) {
-	return q;
-    } else {
-	while (p->next) p = p->next;
-	p->next = q;
-	return list;
-    }
-}
-
-TaskQueuePtr
-append_taskQueue(TaskQueuePtr list, TaskQueuePtr q)
-{
-    TaskQueuePtr p = list;
-
-    if (!p) {
-	return q;
-    } else {
-	while(p->next) p = p->next;
-	p->next = q;
-	return list;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/TaskListInfo.cc	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,90 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "TaskListInfo.h"
+
+TaskListInfo::TaskListInfo(void)
+    :taskListPool(NULL), freeTaskList(NULL) {}
+
+TaskListInfo::~TaskListInfo(void) { destroy(); }
+
+int
+TaskListInfo::init(int num)
+{
+    if (taskListPool == NULL) {
+	return extend_pool(num);
+    }
+    return 0;
+}
+
+int
+TaskListInfo::extend_pool(int num)
+{
+    TaskListPtr q = NULL;
+
+    q = (TaskListPtr)malloc(sizeof(TaskList)*(num+1));
+
+    if (q == NULL) {
+	return -1;
+    }
+
+    q->next = taskListPool;
+    taskListPool = q;
+
+    /* Connect all free pack_list in the pool */
+    for (q = taskListPool + 1; --num > 0; q++) {
+	q->next = q + 1;
+    }
+    q->next = freeTaskList;
+    freeTaskList = taskListPool + 1;
+
+    return 0;
+}
+
+TaskListPtr
+TaskListInfo::create(void)
+{
+    TaskListPtr q;
+
+    if (freeTaskList == NULL) {
+	extend_pool(10);
+    }
+    q = freeTaskList;
+    freeTaskList = freeTaskList->next;
+
+    q->length = 0;
+    q->next = 0;
+
+    return q;
+}
+
+void
+TaskListInfo::free(TaskListPtr q)
+{
+    q->next = freeTaskList;
+    freeTaskList = q;
+}
+
+void
+TaskListInfo::destroy(void)
+{
+    TaskListPtr q;
+
+    for (q = taskListPool; q; q = q->next) {
+	free(q);
+    }
+    freeTaskList = taskListPool = NULL;
+}
+
+TaskListPtr
+TaskListInfo::append(TaskListPtr list, TaskListPtr q)
+{
+    TaskListPtr p = list;
+
+    if (!p) {
+	return q;
+    } else {
+	while (p->next) p = p->next;
+	p->next = q;
+	return list;
+    }
+}
--- a/TaskManager/kernel/ppe/TaskManager.cc	Fri Feb 15 13:09:43 2008 +0900
+++ b/TaskManager/kernel/ppe/TaskManager.cc	Fri Feb 15 13:09:43 2008 +0900
@@ -1,6 +1,5 @@
 #include "TaskManager.h"
 #include "SymTable.h"
-#include "BufferManager.h"
 
 TaskManager::TaskManager(int num)
 {
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc	Fri Feb 15 13:09:43 2008 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc	Fri Feb 15 13:09:43 2008 +0900
@@ -1,17 +1,14 @@
 #include <stdio.h>
 #include "TaskManagerImpl.h"
-
-#include "ppe_spe.h"
+#include "types.h"
+#include "error.h"
 
 void
 noaction(void)
 {
 }
 
-TaskManagerImpl::TaskManagerImpl(int num)
-{
-    machineNum = num;
-}
+TaskManagerImpl::TaskManagerImpl(int num) : machineNum(num) {}
 
 void
 TaskManagerImpl::init(void)
@@ -32,7 +29,7 @@
 {
     HTaskPtr new_task;
 
-    new_task = taskInfo->get_free_task(cmd, size, in_addr, out_addr);
+    new_task = taskInfo->create_task(cmd, size, in_addr, out_addr);
 
     if (func == NULL) {
 	new_task->post_func = noaction;
@@ -52,11 +49,11 @@
 {
     TaskQueuePtr m, s;
 
-    m = taskInfo->get_free_taskQueue(master);
-    s = taskInfo->get_free_taskQueue(slave);
+    m = taskInfo->create_taskQueue(master);
+    s = taskInfo->create_taskQueue(slave);
 
-    master->wait_me = append_taskQueue(master->wait_me, s);
-    slave->wait_i = append_taskQueue(slave->wait_i, m);
+    master->wait_me = TaskQueueInfo::append(master->wait_me, s);
+    slave->wait_i = TaskQueueInfo::append(slave->wait_i, m);
 }
 
 void
@@ -100,17 +97,13 @@
 	task->self = htask;
 
 	taskInfo->free_taskQueue(d);
-    }	
+    }
 
     taskInfo->activeTaskQueue = NULL;
 
     return list;
 }
 
-
-// ../spe/main.cpp
-extern MailQueuePtr spe_main(MailManager*, MailQueuePtr);
-
 void
 TaskManagerImpl::run(void)
 {
@@ -130,10 +123,11 @@
 	sentinel  = mailManager->create_mail(MY_SPE_COMMAND_EXIT);
 	in_mail_list = append_mailQueue(in_mail_list, sentinel);
 
-	// 返って来た mail_list には、spe からの mail がある
 	scheduler->send_mailList(in_mail_list);
 	scheduler->run();
 	out_mail_list = scheduler->recv_mailList();
+
+	// out_mail_list には、ppe scheduler からの mail がある
 	in_mail_list = mail_check(out_mail_list);
     } while (in_mail_list);
 }
@@ -154,18 +148,14 @@
 	data = q->data;
 
 	if (data == MY_SPE_STATUS_READY) {
-#ifdef _PPE_DEBUG
-	    printf("[FIFO] finish\n");
-#endif
+	    __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);
 	    }
 	} else {
-#ifdef _PPE_DEBUG
-	    printf("[PPE] recv from : 0x%x\n", data);
-#endif
+	    __debug_ppe("[PPE] recv from : 0x%x\n", data);
 	    taskInfo->check_task_finish((HTaskPtr)data);
 	}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/TaskQueueInfo.cc	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,92 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "TaskQueueInfo.h"
+
+TaskQueueInfo::TaskQueueInfo(void)
+    :taskQueuePool(NULL), freeTaskQueue(NULL) {}
+
+TaskQueueInfo::~TaskQueueInfo(void) { destroy(); }
+
+int
+TaskQueueInfo::init(int num)
+{
+    if (taskQueuePool == NULL) {
+	return extend_pool(num);
+    }
+    return 0;
+}
+
+int
+TaskQueueInfo::extend_pool(int num)
+{
+    TaskQueuePtr q = NULL;
+
+    q = (TaskQueuePtr)malloc(sizeof(TaskQueue)*(num+1));
+
+    if (q == NULL) {
+	return -1;
+    }
+    q->next = taskQueuePool;
+    taskQueuePool = q;
+
+    /* Connect all free queue in the pool */
+    for (q = taskQueuePool + 1; --num > 0; q++) {
+	q->next = q + 1;
+    }
+    q->next = freeTaskQueue;
+    freeTaskQueue = taskQueuePool + 1;
+
+    return 0;
+}
+
+TaskQueuePtr
+TaskQueueInfo::create(HTaskPtr task)
+{
+    TaskQueuePtr q;
+ 
+    if (freeTaskQueue == NULL) {
+	extend_pool(100);
+    }
+    q = freeTaskQueue;
+    freeTaskQueue = freeTaskQueue->next;
+
+    q->task = task;
+    q->next = NULL;
+
+    return q;
+}
+
+
+void
+TaskQueueInfo::free(TaskQueuePtr q)
+{
+    q->next = freeTaskQueue;
+    freeTaskQueue = q;
+}
+
+
+void
+TaskQueueInfo::destroy(void)
+{
+    TaskQueuePtr q;
+
+    for (q = taskQueuePool; q; q = q->next) {
+	free(q);
+    }
+    freeTaskQueue = taskQueuePool = NULL;
+}
+
+
+TaskQueuePtr
+TaskQueueInfo::append(TaskQueuePtr list, TaskQueuePtr q)
+{
+    TaskQueuePtr p = list;
+
+    if (!p) {
+	return q;
+    } else {
+	while(p->next) p = p->next;
+	p->next = q;
+	return list;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/TaskManager/BufferManager.h	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,66 @@
+#ifndef INCLUDED_BUFFER_MANAGER
+#define INCLUDED_BUFFER_MANAGER
+
+#ifndef INCLUDED_TASK
+#  include "task.h"
+#endif
+
+#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 */
+    BufferManager(int num = 1);
+    virtual ~BufferManager(void);
+    
+    /* variables */
+    TaskListInfo *tlistImpl;
+    TaskQueueInfo *tqueueImpl;
+    HTaskInfo *htaskImpl;
+
+    int machineNum;
+    TaskQueuePtr activeTaskQueue;
+    TaskQueuePtr waitTaskQueue;
+    TaskListPtr *machineTaskList;
+
+    /* function */
+    void init(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 list
+    virtual TaskListPtr get_available_taskList(void);
+
+    void finish(void);
+
+    virtual void clear_taskList(void);
+
+    virtual void append_activeTask(HTaskPtr);
+    virtual void append_waitTask(HTaskPtr);
+
+    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:
+};
+
+#endif
--- a/include/TaskManager/DmaManager.h	Fri Feb 15 13:09:43 2008 +0900
+++ b/include/TaskManager/DmaManager.h	Fri Feb 15 13:09:43 2008 +0900
@@ -7,7 +7,7 @@
 };
 
 #ifndef INCLUDED_TYPES
-#  include "ppe_spe.h"
+#  include "types.h"
 #endif
 
 class DmaManager {
--- a/include/TaskManager/FifoTaskInfo.h	Fri Feb 15 13:09:43 2008 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#ifndef INCLUDED_FIFO_TASK_INFO
-#define INCLUDED_FIFO_TASK_INFO
-
-#ifndef INCLUDED_TASK_INFO
-#  include "TaskInfo.h"
-#endif
-
-class FifoTaskInfo : public TaskInfo {
-public:
-
-    /* function */
-    int extend_pool_taskList(int num);
-    TaskListPtr get_available_taskList(void);
-    void clear_taskList(void);
-
-    /* variables */
-};
-
-#endif
--- a/include/TaskManager/FifoTaskManagerImpl.h	Fri Feb 15 13:09:43 2008 +0900
+++ b/include/TaskManager/FifoTaskManagerImpl.h	Fri Feb 15 13:09:43 2008 +0900
@@ -1,10 +1,6 @@
 #ifndef INCLUDED_FIFO_TASK_MANAGER_IMPL
 #define INCLUDED_FIFO_TASK_MANAGER_IMPL
 
-#ifndef INCLUDED_FIFO_TASK_INFO
-#  include "FifoTaskInfo.h"
-#endif
-
 #ifndef INCLUDED_TASK_MANAGER_IMPL
 #  include "TaskManagerImpl.h"
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/TaskManager/HTaskInfo.h	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,33 @@
+#ifndef INCLUDED_HTASK_INFO
+#define INCLUDED_HTASK_INFO
+
+#ifndef INCLUDED_TASK
+#  include "task.h"
+#endif
+
+#ifndef INCLUDED_TYPES
+#  include "types.h"
+#endif
+
+class HTaskInfo {
+public:
+    /* constructor */
+    HTaskInfo(void);
+    ~HTaskInfo(void);
+
+    /* functions */
+    int init(int num);
+    HTaskPtr create(int cmd, int size, uint64 in_addr, uint64 out_addr);
+    void free(HTaskPtr q);
+
+private:
+    /* variables */
+    HTaskPtr htaskPool;
+    HTaskPtr freeHTask;
+
+    /* functions */
+    int extend_pool(int num);
+    void destroy(void);
+};
+
+#endif
--- a/include/TaskManager/TaskInfo.h	Fri Feb 15 13:09:43 2008 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#ifndef INCLUDED_BUFFER_MANAGER
-#define INCLUDED_BUFFER_MANAGER
-
-#ifndef INCLUDED_TASK
-#  include "task.h"
-#endif
-
-#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 */
-    BufferManager(int num = 1);
-    virtual ~BufferManager(void);
-    
-    /* variables */
-    TaskListInfo *tlistImpl;
-    TaskQueueInfo *tqueueImpl;
-    HTaskInfo *htaskImpl;
-
-    int machineNum;
-    TaskQueuePtr activeTaskQueue;
-    TaskQueuePtr waitTaskQueue;
-    TaskListPtr *machineTaskList;
-
-    /* function */
-    void init(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 list
-    virtual TaskListPtr get_available_taskList(void);
-
-    void finish(void);
-
-    virtual void clear_taskList(void);
-
-    virtual void append_activeTask(HTaskPtr);
-    virtual void append_waitTask(HTaskPtr);
-
-    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:
-};
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/TaskManager/TaskListInfo.h	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,37 @@
+#ifndef INCLUDED_TASK_LIST_INFO
+#define INCLUDED_TASK_LIST_INFO
+
+#ifndef INCLUDED_TASK
+#  include "task.h"
+#endif
+
+#ifndef INCLUDED_TYPES
+#  include "types.h"
+#endif
+
+class TaskListInfo {
+public:
+    /* constructor */
+    TaskListInfo(void);
+    virtual ~TaskListInfo(void);
+    
+    /* functions */
+    int init(int num);
+    TaskListPtr create(void);
+    void free(TaskListPtr list);
+    static TaskListPtr append(TaskListPtr list, TaskListPtr q);
+
+protected:
+    /* functions */
+    virtual int extend_pool(int num);
+
+private:
+    /* variables */
+    TaskListPtr taskListPool;
+    TaskListPtr freeTaskList;
+
+    /* functions */
+    void destroy(void);
+};
+
+#endif
--- a/include/TaskManager/TaskManagerImpl.h	Fri Feb 15 13:09:43 2008 +0900
+++ b/include/TaskManager/TaskManagerImpl.h	Fri Feb 15 13:09:43 2008 +0900
@@ -1,8 +1,8 @@
 #ifndef INCLUDED_TASK_MANAGER_IMPL
 #define INCLUDED_TASK_MANAGER_IMPL
 
-#ifndef INCLUDED_TASK_INFO
-#  include "TaskInfo.h"
+#ifndef INCLUDED_BUFFER_MANAGER
+#  include "BufferManager.h"
 #endif
 
 #ifndef INCLUDED_MAIL_MANAGER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/TaskManager/TaskQueueInfo.h	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,34 @@
+#ifndef INCLUDED_TASK_QUEUE_INFO
+#define INCLUDED_TASK_QUEUE_INFO
+
+#ifndef INCLUDED_TASK
+#  include "task.h"
+#endif
+
+#ifndef INCLUDED_HTASK_INFO
+#  include "HTaskInfo.h"
+#endif
+
+class TaskQueueInfo {
+public:
+    /* constructor */
+    TaskQueueInfo(void);
+    ~TaskQueueInfo(void);
+
+    /* functions */
+    int init(int num);
+    TaskQueuePtr create(HTaskPtr task);
+    void free(TaskQueuePtr queue);
+    static TaskQueuePtr append(TaskQueuePtr list, TaskQueuePtr q);
+
+private:
+    /* variables */
+    TaskQueuePtr taskQueuePool;
+    TaskQueuePtr freeTaskQueue;
+
+    /* functions */
+    int extend_pool(int num);
+    void destroy(void);  
+};
+
+#endif
--- a/include/TaskManager/ppe_spe.h	Fri Feb 15 13:09:43 2008 +0900
+++ b/include/TaskManager/ppe_spe.h	Fri Feb 15 13:09:43 2008 +0900
@@ -1,8 +1,8 @@
 /**
  * Alignment value and macro for DMA transfer in SPE
  */
-#ifndef INCLUDED_TYPES
-#define INCLUDED_TYPES
+#ifndef INCLUDED_T
+#define INCLUDED_T
 
 #define SPE_ALIGNMENT 16
 #define SPE_ALIGNMENT_FULL 128
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/TaskManager/types.h	Fri Feb 15 13:09:43 2008 +0900
@@ -0,0 +1,24 @@
+#ifndef INCLUDED_TYPES
+#define INCLUDED_TYPES
+
+typedef unsigned int uint32;
+typedef unsigned long long uint64;
+
+
+#define SPE_ALIGNMENT 16
+#define SPE_ALIGNMENT_FULL 128
+#define SPE_ALIGN __attribute__((aligned(SPE_ALIGNMENT)))
+#define SPE_ALIGN_FULL __attribute__((aligned(SPE_ALIGNMENT_FULL))
+#define ROUND_UP_ALIGN(value, alignment) \
+    (((value) + ((alignment) - 1))&(~((alignment)-1)))
+#define DEFAULT_ALIGNMENT SPE_ALIGNMENT
+
+enum {
+    MY_SPE_COMMAND_EXIT,
+    MY_SPE_COMMAND_GO,
+
+    MY_SPE_STATUS_BUSY,
+    MY_SPE_STATUS_READY
+};
+
+#endif