changeset 955:9989dd7b9ac2

unify all QueueInfo
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 04 Aug 2010 16:46:25 +0900
parents 6d3c954e510a
children 15026ebf7a17
files TaskManager/Cell/CellTaskManagerImpl.h TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/Fifo/FifoTaskManagerImpl.h TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/HTaskInfo.cc TaskManager/kernel/ppe/HTaskInfo.h TaskManager/kernel/ppe/QueueInfo.h TaskManager/kernel/ppe/TaskListInfo.cc TaskManager/kernel/ppe/TaskListInfo.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/ppe/TaskQueue.h TaskManager/kernel/ppe/TaskQueueInfo.cc TaskManager/kernel/ppe/TaskQueueInfo.h
diffstat 14 files changed, 76 insertions(+), 850 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.h	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.h	Wed Aug 04 16:46:25 2010 +0900
@@ -12,8 +12,8 @@
     ~CellTaskManagerImpl();
 
     /* variables */
-    TaskListInfoPtr *taskListInfo;
-    TaskListInfoPtr *speTaskList;  // running task
+    QueueInfo<TaskList> *taskListInfo;
+    QueueInfo<TaskList> *speTaskList;  // running task
 
     SpeThreads *speThreads;
     FifoTaskManagerImpl *ppeManager;
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc	Wed Aug 04 16:46:25 2010 +0900
@@ -2,7 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include "FifoTaskManagerImpl.h"
-#include "TaskListInfo.h"
+#include "QueueInfo.h"
+#include "TaskList.h"
 #include "Scheduler.h"
 #include "SchedTask.h"
 #include "types.h"
@@ -10,6 +11,8 @@
 #include "SchedNop.h"
 #include "SysFunc.h"
 
+extern  QueueInfo<TaskList> *taskListPool;
+
 // static void send_alloc_reply(FifoTaskManagerImpl *tm, int id, MainScheduler *s);
 
 FifoTaskManagerImpl::~FifoTaskManagerImpl()
@@ -36,8 +39,8 @@
     mainScheduler->id = 0;
     set_scheduler(mainScheduler);
 
-    taskListInfo  = new TaskListInfo;
-    ppeTaskList  = new TaskListInfo;
+    taskListInfo  = new QueueInfo<TaskList>(taskListPool);
+    ppeTaskList  = new QueueInfo<TaskList>(taskListPool);
 
     schedTaskManager = new SchedTask();
     others = 0;
@@ -63,8 +66,8 @@
     htaskImpl     = tm-> htaskImpl     ;
     waitTaskQueue     = tm->waitTaskQueue;   
 
-    taskListInfo  = new TaskListInfo;
-    ppeTaskList  = new TaskListInfo;
+    taskListInfo  = new QueueInfo<TaskList>(taskListPool);
+    ppeTaskList  = new QueueInfo<TaskList>(taskListPool);
 
     // schedTaskManager = new SchedTask();
     others = tm;
@@ -127,7 +130,7 @@
     // ppeTaskList は走り終わった ppe の Task の List. 
     // taskListInfo はこれから走る Task の List. 
     // 交換して実行する
-    TaskListInfoPtr tmp = ppeTaskList;
+    QueueInfo<TaskList>* tmp = ppeTaskList;
     ppeTaskList = taskListInfo;
     taskListInfo = tmp;
     // ppeTaskList は本来は循環リストなのだけど、実行中は線形リストである。
--- a/TaskManager/Fifo/FifoTaskManagerImpl.h	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.h	Wed Aug 04 16:46:25 2010 +0900
@@ -13,8 +13,8 @@
 
     /* variables */
     int machineNum;
-    TaskListInfoPtr taskListInfo;  
-    TaskListInfoPtr ppeTaskList;  // running task
+    QueueInfo<TaskList> *taskListInfo;  
+    QueueInfo<TaskList> *ppeTaskList;  // running task
 
     MailManager *mailManager;
     MainScheduler *mainScheduler;
--- a/TaskManager/kernel/ppe/HTask.h	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/kernel/ppe/HTask.h	Wed Aug 04 16:46:25 2010 +0900
@@ -4,7 +4,8 @@
 #include "base.h"
 #include "types.h"
 #include "Task.h"
-#include "TaskQueueInfo.h"
+#include "TaskQueue.h"
+#include "QueueInfo.h"
 #include <stdio.h>
 
 class TaskManagerImpl;
@@ -29,8 +30,8 @@
 public:
     BASE_NEW_DELETE(HTask);
 
-    TaskQueueInfo *wait_me;  // List of task waiting for me
-    TaskQueueInfo *wait_i;   // List of task for which I am waiting
+    QueueInfo<TaskQueue> *wait_me;  // List of task waiting for me
+    QueueInfo<TaskQueue> *wait_i;   // List of task for which I am waiting
     PostFunction post_func;
     void *post_arg1;
     void *post_arg2;
@@ -53,6 +54,12 @@
     Task *next_task_array(int task_id, Task *t);
     void spawn_task_array(Task *t);
 
+    HTask *init(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) {
+	init(cmd);
+	set_input(rbuf, rs);
+	set_output(wbuf, ws);
+	return this;
+    }
 
     private:
 
@@ -114,10 +121,12 @@
 	flag.no_auto_free = 0;
     }
 
-    void init(int cmd) {
+    void init() {
 	next = prev = NULL;
 	waiter = NULL;
+    }
 
+    void init(int cmd) {
 	command  = cmd;
 	param_index = 0;
 	in_index = 0;
--- a/TaskManager/kernel/ppe/HTaskInfo.cc	Tue Aug 03 15:32:49 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "TaskManagerImpl.h"
-#include "HTaskInfo.h"
-#include "TaskQueueInfo.h"
-
-// Singleton HTask Pool
-HTaskInfo HTaskInfo::taskQueuePool;   
-
-HTaskInfo::HTaskInfo() {
-    // 最初の一つは自分
-    first = last = this;
-    next = prev = this;
-    waiter = NULL;
-}
-
-void
-HTaskInfo::freePool() { 
-    for(HTaskPtr p = taskQueuePool.waiter; p; ) {
-	HTaskPtr next = p->waiter;
-	p->waiter = NULL;
-	delete p->wait_me;
-	delete p->wait_i;
-	free(p);
-	p = next;
-    }
-}
-
-int
-HTaskInfo::extend_pool(int num)
-{
-    HTaskPtr q = (HTaskPtr)malloc(sizeof(HTask)*(num+1));
-
-    // First Queue is previous pool
-    q->waiter = waiter; waiter = q;
-    q++;
-
-    /* Connect all free queue in the pool */
-    HTaskPtr p = q;
-    for (; num-- > 0; p++) {
-	p->waiter = NULL;
-	p->wait_me = new TaskQueueInfo();
-	p->wait_i = new TaskQueueInfo();
-	taskQueuePool.addLast(p);
-    }
-
-    return 0;
-}
-
-/**
- * Task をプールから取って来て返す
- *
- * @param [cmd] タスクコマンド
- */
-HTaskPtr
-HTaskInfo::create(int cmd)
-{
-    HTaskPtr q =  taskQueuePool.poll();
-    if (! q)  {
-	taskQueuePool.extend_pool(64);
-	q = taskQueuePool.poll();
-    }
-    q->init(cmd);
-    return q;
-}
-
-HTaskPtr 
-HTaskInfo::create(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws)
-{
-    HTaskPtr task = create(cmd);
-    task->set_input(rbuf, rs);
-    task->set_output(wbuf, ws);
-    return task;
-}
-
-
-void
-HTaskInfo::free_(HTaskPtr q)
-{
-    q->waiter = NULL;
-    taskQueuePool.addLast(q);
-}
-
-
-/*!
-  HTaskInfo は空にならない。最低1個は要素が入っていて
-  1個目は特別扱いする。getFirst すると first->next を返す
- */
-
-/*!
-  最初の1個は特別扱いなので、それの後に追加していく
- */
-void
-HTaskInfo::addFirst(HTask* e)
-{
-    e->prev = first;
-    e->next = first->next;
-    first->next->prev = e;
-    first->next = e;
-}
-
-void
-HTaskInfo::addLast(HTask* e)
-{
-#ifdef CHECK
-    if (find(e)) { 
-	fprintf(stderr,"Add duplicate task %0x\n",(int)e);
-	return; 
-       // ...  
-    }
-#endif
-    e->next = first;
-    e->prev = last;
-    last->next = e;
-    last = e;
-}
-
-HTask*
-HTaskInfo::getFirst()
-{
-    if (empty()) return NULL;
-    return first->next;
-}
-
-HTask*
-HTaskInfo::getLast()
-{
-    if (empty()) return NULL;
-    return last;
-}
-
-int
-HTaskInfo::remove(HTask* e)
-{
-#ifdef CHECK
-    if (!find(e)) { 
-	fprintf(stderr,"Remove non existing task %0x\n",(int)e);
-	return 0; 
-       // ...  
-    }
-#endif
-    e->prev->next = e->next;
-    e->next->prev = e->prev;
-
-    if (first->next == e) {
-	first->next = e->next;
-    }
-    if (last == e) {
-	last = e->prev;
-    }
-
-    e->prev = NULL;
-    e->next = NULL;
-
-    return 1;
-}
-
-/*!
-  リストの先頭を取得および削除する。リストが空の場合は NULL を返す。
- */
-
-HTask*
-HTaskInfo::poll()
-{
-    HTask* e = first->next;
-    if (e == this) {
-	return NULL;
-    }
-    remove(e);
-    return e;
-}
-
-void
-HTaskInfo::moveToFirst(HTask* e)
-{
-    remove(e);
-    addFirst(e);
-}
-
-/*!
-  リスト内の指定された位置にある要素を返す。
-  要素数を超えた位置を指定した場合 NULL を返す。
- */
-
-HTask*
-HTaskInfo::get(int index)
-{
-    HTask* e = first->next;
-    for (int i = 0; i < index; i++) {
-	if (e == this) return NULL;
-	e = e->next;
-    }
-    return e;
-}
-
-HTask*
-HTaskInfo::find(HTask* task)
-{
-    HTask* e = first->next;
-    for(;;) {
-	if (e == this) return NULL;
-	if (e == task) break;
-	e = e->next;
-    }
-    return e;
-}
-
-int
-HTaskInfo::empty()
-{
-    return next == this;
-}
-
-HTask*
-HTaskInfo::getNext(HTask* q) 
-{
-    if (q->next==this) return NULL;
-    return q->next;
-}
-
-int
-HTaskInfo::length() 
-{
-    int i = 1;
-    if (empty()) return 0;
-    HTask* e = first;
-    while((e = e->next) != this ) i++;
-    return i;
-}
-
-
-
-
-/* end */
-
-
--- a/TaskManager/kernel/ppe/HTaskInfo.h	Tue Aug 03 15:32:49 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#ifndef INCLUDED_HTASK_INFO
-#define INCLUDED_HTASK_INFO
-
-#include "Task.h"
-#include "HTask.h"
-
-class HTaskInfo : public HTask {
-
-public:
-    /* constructor */
-    HTaskInfo();
-
-    BASE_NEW_DELETE(HTaskInfo);
-
-    /* functions */
-    HTaskPtr create(int cmd);
-    HTaskPtr create(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws);
-
-    void free_(HTaskPtr queue);
-
-    void addFirst(HTask* e);
-    void addLast(HTask* e);
-    HTask* getFirst();
-    HTask* getLast();
-    int remove(HTask* e);
-    HTask* poll();
-    void moveToFirst(HTask* e); // or use();
-    HTask* get(int index);
-    HTask* find(HTask *task);
-    int empty();
-    void freePool() ;
-
-    // Iterator
-    HTask* getNext(HTask* q) ;
-    int length();
-
-private:
-    /* variables */
-
-    static HTaskInfo taskQueuePool;
-    HTask* first;
-    HTask* last;
-
-    /* functions */
-    int extend_pool(int num);
-    void destroy();  
-}  ;
-
-#endif
--- a/TaskManager/kernel/ppe/QueueInfo.h	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/kernel/ppe/QueueInfo.h	Wed Aug 04 16:46:25 2010 +0900
@@ -49,6 +49,7 @@
     T* find(T *task);
     int empty();
     void freePool() ;
+    void freeAll();
 
     // Iterator
     T* getNext(T* q) ;
@@ -290,6 +291,12 @@
     return i;
 }
 
+template<typename T>void
+QueueInfo<T>::freeAll()
+{
+    T* t;
+    while((t=poll())) free_(t);
+}
 
 
 
--- a/TaskManager/kernel/ppe/TaskListInfo.cc	Tue Aug 03 15:32:49 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "types.h"
-#include "TaskListInfo.h"
-
-
-// Singleton TaskList Pool
-TaskListInfo TaskListInfo::taskListPool;   
-
-TaskListInfo::TaskListInfo() {
-    // 最初の一つは自分
-    first = last = this;
-    next = prev = this;
-    waiter = NULL;
-}
-
-void
-TaskListInfo::freePool() { 
-    for(TaskListPtr p = taskListPool.waiter; p; ) {
-	TaskListPtr next = p->waiter;
-	p->waiter = NULL;
-	free(p);
-	p = next;
-    }
-}
-
-int
-TaskListInfo::extend_pool(int num)
-{
-    TaskListPtr q = (TaskListPtr)malloc(sizeof(TaskList)*(num+1)+DEFAULT_ALIGNMENT);
-
-    // First Queue is previous pool
-    q->waiter = waiter; waiter = q;
-    q = (TaskListPtr)ROUND_UP_ALIGN((long)q, DEFAULT_ALIGNMENT);
-    q++;
-
-    /* Connect all free queue in the pool */
-    TaskListPtr p = q;
-    for (; num-- > 0; p++) {
-	p->waiter = NULL;
-	taskListPool.addLast(p);
-    }
-
-    return 0;
-}
-
-/**
- * Task をプールから取って来て返す
- *
- * @param [cmd] タスクコマンド
- */
-TaskListPtr
-TaskListInfo::create()
-{
-    TaskListPtr q =  taskListPool.poll();
-    if (! q)  {
-	taskListPool.extend_pool(64);
-	q = taskListPool.poll();
-    }
-    q->init();
-    return q;
-}
-
-
-void
-TaskListInfo::free_(TaskListPtr q)
-{
-    q->waiter = NULL;
-    taskListPool.addLast(q);
-}
-
-void
-TaskListInfo::freeAll()
-{
-    TaskListPtr t;
-    //if (getLast()->next==0) getLast()->next = this;
-    while((t=poll())) free_(t);
-}
-
-
-/*!
-  TaskListInfo は空にならない。最低1個は要素が入っていて
-  1個目は特別扱いする。getFirst すると first->next を返す
- */
-
-/*!
-  最初の1個は特別扱いなので、それの後に追加していく
- */
-void
-TaskListInfo::addFirst(TaskList* e)
-{
-    e->prev = first;
-    e->next = first->next;
-    first->next->prev = e;
-    first->next = e;
-}
-
-void
-TaskListInfo::addLast(TaskList* e)
-{
-#ifdef CHECK
-    if (find(e)) { 
-	fprintf(stderr,"Add duplicate task %0x\n",(int)e);
-	return; 
-       // ...  
-    }
-#endif
-    e->next = first;
-    e->prev = last;
-    last->next = e;
-    last = e;
-}
-
-TaskList*
-TaskListInfo::getFirst()
-{
-    if (empty()) return NULL;
-    return first->next;
-}
-
-TaskList*
-TaskListInfo::getLast()
-{
-    if (empty()) return NULL;
-    return last;
-}
-
-int
-TaskListInfo::remove(TaskList* e)
-{
-#ifdef CHECK
-    if (!find(e)) { 
-	fprintf(stderr,"Remove non existing task %0x\n",(int)e);
-	return 0; 
-       // ...  
-    }
-#endif
-    e->prev->next = e->next;
-    e->next->prev = e->prev;
-
-    if (first->next == e) {
-	first->next = e->next;
-    }
-    if (last == e) {
-	last = e->prev;
-    }
-
-    e->prev = NULL;
-    e->next = NULL;
-
-    return 1;
-}
-
-/*!
-  リストの先頭を取得および削除する。リストが空の場合は NULL を返す。
- */
-
-TaskList*
-TaskListInfo::poll()
-{
-    TaskList* e = first->next;
-    if (e == this) {
-	return NULL;
-    }
-    remove(e);
-    return e;
-}
-
-void
-TaskListInfo::moveToFirst(TaskList* e)
-{
-    remove(e);
-    addFirst(e);
-}
-
-/*!
-  リスト内の指定された位置にある要素を返す。
-  要素数を超えた位置を指定した場合 NULL を返す。
- */
-
-TaskList*
-TaskListInfo::get(int index)
-{
-    TaskList* e = first->next;
-    for (int i = 0; i < index; i++) {
-	if (e == this) return NULL;
-	e = e->next;
-    }
-    return e;
-}
-
-TaskList*
-TaskListInfo::find(TaskList* task)
-{
-    TaskList* e = first->next;
-    for(;;) {
-	if (e == this) return NULL;
-	if (e == task) break;
-	e = e->next;
-    }
-    return e;
-}
-
-int
-TaskListInfo::empty()
-{
-    return next == this;
-}
-
-TaskList*
-TaskListInfo::getNext(TaskList* q) 
-{
-    if (q->next==this) return NULL;
-    return q->next;
-}
-
-int
-TaskListInfo::length() 
-{
-    int i = 1;
-    if (empty()) return 0;
-    TaskList* e = first;
-    while((e = e->next) != this ) i++;
-    return i;
-}
-
-
-
-
-/* end */
-
-
--- a/TaskManager/kernel/ppe/TaskListInfo.h	Tue Aug 03 15:32:49 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#ifndef INCLUDED_TASK_LIST_INFO
-#define INCLUDED_TASK_LIST_INFO
-
-#include "types.h"
-#include "TaskList.h"
-
-class TaskListInfo : public TaskList {
-public:
-    /* constructor */
-    TaskListInfo();
-
-    BASE_NEW_DELETE(TaskListInfo);
-
-    /* functions */
-    TaskListPtr create();
-
-    void free_(TaskListPtr queue);
-    void freeAll();
-
-    void addFirst(TaskList* e);
-    void addLast(TaskList* e);
-    TaskList* getFirst();
-    TaskList* getLast();
-    int remove(TaskList* e);
-    TaskList* poll();
-    void moveToFirst(TaskList* e); // or use();
-    TaskList* get(int index);
-    TaskList* find(TaskList *task);
-    int empty();
-    void freePool() ;
-
-    // Iterator
-    TaskList* getNext(TaskList* q) ;
-    int length();
-    static TaskListInfo taskListPool;
-
-private:
-    /* variables */
-
-    TaskList* first;
-    TaskList* last;
-
-    /* functions */
-    int extend_pool(int num);
-    void destroy();  
-};
-
-typedef TaskListInfo *TaskListInfoPtr;
-
-#endif
-
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc	Wed Aug 04 16:46:25 2010 +0900
@@ -8,6 +8,11 @@
 #include "SysFunc.h"
 #include <string.h>
 
+// singleton
+QueueInfo<TaskQueue> *taskQueuePool = new QueueInfo<TaskQueue>() ;
+QueueInfo<HTask> *htaskPool = new QueueInfo<HTask>() ;
+QueueInfo<TaskList> *taskListPool = new QueueInfo<TaskList>() ;
+
 
 static HTaskPtr systask_start;
 static HTaskPtr systask_finish;
@@ -20,13 +25,13 @@
 TaskManagerImpl::TaskManagerImpl(int num)
     : machineNum(num){
     // 実行可能なHTaskのリスト
-    activeTaskQueue = new HTaskInfo();
+    activeTaskQueue = new QueueInfo<HTask>(htaskPool);
     // wait_forで止まっているHTaskのリスト。必要ないが、Dead lock detection に使う
-    waitTaskQueue = new HTaskInfo();
-    // HTask の factory. HTaskInfo ならなんでもいい。
-    htaskImpl = waitTaskQueue ;             // any HTaskInfo
-    // Task の dependency を表現する double linked list. HTaskInfo とは別に必要。
-    taskQueueImpl = new TaskQueueInfo(); 
+    waitTaskQueue = new QueueInfo<HTask>(htaskPool);
+    // HTask の factory. QueueInfo<HTask> ならなんでもいい。
+    htaskImpl = waitTaskQueue ;             // any QueueInfo<HTask>
+    // Task の dependency を表現する double linked list. QueueInfo<HTask> とは別に必要。
+    taskQueueImpl = new QueueInfo<TaskQueue>(taskQueuePool); 
 }
 
 /**
@@ -55,7 +60,8 @@
 TaskManagerImpl::create_task(int cmd,memaddr rbuf, long r_size, memaddr wbuf, long w_size, void *from) {
     HTaskPtr new_task;
 
-    new_task = htaskImpl->create(cmd, rbuf, r_size, wbuf, w_size);
+    new_task = htaskImpl->create();
+    new_task->init(cmd, rbuf, r_size, wbuf, w_size);
     new_task->post_func = noaction;
     new_task->mimpl = this;
     new_task->from = (memaddr)from;
@@ -90,7 +96,7 @@
     HTaskPtr new_task;
 
     // for compatibility
-    new_task = htaskImpl->create(TaskArray1);
+    new_task = htaskImpl->create(); new_task->init(TaskArray1);
     new_task->post_func = noaction;
     new_task->mimpl = this;
     new_task->create_task_array(cmd,1,8,8,8);
@@ -123,8 +129,8 @@
     TaskQueuePtr m, s;
     if (!master->self) return;
 
-    m = taskQueueImpl->create(master);
-    s = taskQueueImpl->create(slave);
+    m = taskQueueImpl->create(); m->init(master);
+    s = taskQueueImpl->create();  s->init(slave);
 
     master->wait_me->addLast(s);
     slave->wait_i->addLast(m);
@@ -175,7 +181,7 @@
 
 #if 0
 static void 
-check_wait(TaskManagerImpl *tm, TaskQueueInfo *wait_i) {
+check_wait(TaskManagerImpl *tm, QueueInfo<TaskQueue> *wait_i) {
     for(TaskQueue *t = wait_i->getFirst(); t; t = wait_i->getNext(t)) {
 	if (!tm->waitTaskQueue->find(t->task)) {
 	    printf("stray waiting task%d %lx\n",t->task->command, (long)t->task);
@@ -194,11 +200,11 @@
  * @param [task] 終了したタスク
  */
 void
-TaskManagerImpl::check_task_finish(HTaskPtr me, HTaskInfo *wait_queue)
+TaskManagerImpl::check_task_finish(HTaskPtr me, QueueInfo<HTask> *wait_queue)
 {
     while(TaskQueue *p = me->wait_me->poll()) {
 	HTaskPtr you = p->task;
-	TaskQueueInfo *wait_i = you->wait_i;
+	QueueInfo<TaskQueue> *wait_i = you->wait_i;
 	// 相手の wait queue から自分(を指しているTaskQueue)を削除
 	wait_i->remove(p->waiter);
 	// queue を free する
@@ -229,7 +235,7 @@
  * @param [task] 終了したタスク
  */
 void
-TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, HTaskInfo *wait_queue)
+TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue)
 {
     for(int i = 0;i<list->length;i++) { 
 	SimpleTaskPtr task = &list->tasks[i];
@@ -264,7 +270,7 @@
       TaskList は自動的に延長される
  */
 void
-TaskManagerImpl::set_taskList(HTaskPtr htask, TaskListInfoPtr taskList) {
+TaskManagerImpl::set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList) {
     TaskListPtr list ; 
     if ( taskList->empty() ) {
 	list = taskList->create();
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.h	Wed Aug 04 16:46:25 2010 +0900
@@ -3,23 +3,28 @@
 
 #include "MailManager.h"
 #include "ListData.h"
-#include "TaskListInfo.h"
-#include "TaskQueueInfo.h"
-#include "HTaskInfo.h"
+#include "QueueInfo.h"
+#include "TaskQueue.h"
+#include "HTask.h"
 #include "Scheduler.h"
 class MemList;
 
+extern QueueInfo<TaskQueue> *taskQueuePool ;
+extern QueueInfo<HTask> *htaskPool ;
+extern  QueueInfo<TaskList> *taskListPool;
+
+
 
 class TaskManagerImpl {
 public:
 
     /* variables */
     int machineNum;
-    HTaskInfo *activeTaskQueue;
-    HTaskInfo *waitTaskQueue;
+    QueueInfo<HTask> *activeTaskQueue;
+    QueueInfo<HTask> *waitTaskQueue;
 
-    TaskQueueInfo *taskQueueImpl;
-    HTaskInfo *htaskImpl;
+    QueueInfo<TaskQueue> *taskQueueImpl;
+    QueueInfo<HTask> *htaskImpl;
 
     SchedTask *schedTaskManager;
     Scheduler *scheduler;
@@ -40,8 +45,8 @@
     virtual void append_waitTask(HTaskPtr);
     virtual void polling() = 0;
 
-    void check_task_finish(HTaskPtr task, HTaskInfo *wait_queue);
-    void check_task_list_finish(SchedTask *s, TaskListPtr list, HTaskInfo *wait_queue);
+    void check_task_finish(HTaskPtr task, QueueInfo<HTask> *wait_queue);
+    void check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue);
 
     void systask_init();
 
@@ -52,7 +57,7 @@
     virtual void set_task_depend(HTaskPtr master, HTaskPtr slave);
     virtual void spawn_task(HTaskPtr);
     virtual void set_task_cpu(HTaskPtr, CPU_TYPE);
-    void set_taskList(HTaskPtr htask, TaskListInfoPtr taskList) ; 
+    void set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList) ; 
 
     void free_htask(HTaskPtr htask) {
 #if !defined(__SPU__)
--- a/TaskManager/kernel/ppe/TaskQueue.h	Tue Aug 03 15:32:49 2010 +0900
+++ b/TaskManager/kernel/ppe/TaskQueue.h	Wed Aug 04 16:46:25 2010 +0900
@@ -22,6 +22,13 @@
     TaskQueue *next;
     TaskQueue *prev;
 
+    void init() { }
+
+    TaskQueue *init(HTask *task) {
+	this->task = task;
+	return this;
+    }
+
 }  ;
 
 typedef TaskQueue* TaskQueuePtr;
--- a/TaskManager/kernel/ppe/TaskQueueInfo.cc	Tue Aug 03 15:32:49 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "TaskQueueInfo.h"
-
-// Singleton TaskQueue Pool
-TaskQueueInfo TaskQueueInfo::taskQueuePool;   
-
-TaskQueueInfo::TaskQueueInfo() {
-    // 最初の一つは自分
-    first = last = this;
-    next = prev = this;
-    waiter = NULL;
-}
-
-void
-TaskQueueInfo::freePool() { 
-    for(TaskQueuePtr p = taskQueuePool.waiter; p; ) {
-	TaskQueuePtr next = p->waiter;
-	p->waiter = NULL;
-	free(p);
-	p = next;
-    }
-}
-
-int
-TaskQueueInfo::extend_pool(int num)
-{
-    TaskQueuePtr q = (TaskQueuePtr)malloc(sizeof(TaskQueue)*(num+1));
-
-    // First Queue is previous pool
-    q->waiter = waiter; waiter = q;
-    q++;
-
-    /* Connect all free queue in the pool */
-    TaskQueuePtr p = q;
-    for (; num-- > 0; p++) {
-	p->task = NULL;
-	p->waiter = NULL;
-	taskQueuePool.addLast(p);
-    }
-
-    return 0;
-}
-
-TaskQueuePtr
-TaskQueueInfo::create(HTask *task)
-{
-    TaskQueuePtr q =  taskQueuePool.poll();
-    if (! q)  {
-	taskQueuePool.extend_pool(64);
-	q = taskQueuePool.poll();
-    }
-    q->next = q->prev = NULL;
-    q->waiter = NULL;
-    q->task = task;
-
-    return q;
-}
-
-
-void
-TaskQueueInfo::free_(TaskQueuePtr q)
-{
-    q->waiter = NULL;
-    q->task = NULL;
-    taskQueuePool.addLast(q);
-}
-
-
-/*!
-  TaskQueueInfo は空にならない。最低1個は要素が入っていて
-  1個目は特別扱いする。getFirst すると first->next を返す
- */
-
-/*!
-  最初の1個は特別扱いなので、それの後に追加していく
- */
-void
-TaskQueueInfo::addFirst(TaskQueue* e)
-{
-    e->prev = first;
-    e->next = first->next;
-    first->next->prev = e;
-    first->next = e;
-}
-
-void
-TaskQueueInfo::addLast(TaskQueue* e)
-{
-    e->next = first;
-    e->prev = last;
-    last->next = e;
-    last = e;
-}
-
-TaskQueue*
-TaskQueueInfo::getFirst()
-{
-    if (empty()) return NULL;
-    return first->next;
-}
-
-TaskQueue*
-TaskQueueInfo::getLast()
-{
-    if (empty()) return NULL;
-    return last;
-}
-
-int
-TaskQueueInfo::remove(TaskQueue* e)
-{
-    e->prev->next = e->next;
-    e->next->prev = e->prev;
-
-    if (first->next == e) {
-	first->next = e->next;
-    }
-    if (last == e) {
-	last = e->prev;
-    }
-
-    e->prev = NULL;
-    e->next = NULL;
-
-    return 1;
-}
-
-/*!
-  リストの先頭を取得および削除する。リストが空の場合は NULL を返す。
- */
-
-TaskQueue*
-TaskQueueInfo::poll()
-{
-    TaskQueue* e = first->next;
-    if (e == this) {
-	return NULL;
-    }
-    remove(e);
-    return e;
-}
-
-void
-TaskQueueInfo::moveToFirst(TaskQueue* e)
-{
-    remove(e);
-    addFirst(e);
-}
-
-/*!
-  リスト内の指定された位置にある要素を返す。
-  要素数を超えた位置を指定した場合 NULL を返す。
- */
-
-TaskQueue*
-TaskQueueInfo::get(int index)
-{
-    TaskQueue* e = first->next;
-    for (int i = 0; i < index; i++) {
-	if (e == this) return NULL;
-	e = e->next;
-    }
-    return e;
-}
-
-TaskQueue*
-TaskQueueInfo::find(HTask* task)
-{
-    TaskQueue* e = first->next;
-    for(;;) {
-	if (e == this) return NULL;
-	if (e->task == task) return e;
-	e = e->next;
-    }
-    return e;
-}
-
-int
-TaskQueueInfo::empty()
-{
-    return next == this;
-}
-
-TaskQueue*
-TaskQueueInfo::getNext(TaskQueue* q) 
-{
-    if (q->next==this) return NULL;
-    return q->next;
-}
-
-
-
-/* end */
--- a/TaskManager/kernel/ppe/TaskQueueInfo.h	Tue Aug 03 15:32:49 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#ifndef INCLUDED_TASK_QUEUE_INFO
-#define INCLUDED_TASK_QUEUE_INFO
-
-#include "TaskQueue.h"
-
-class HTask;
-
-class TaskQueueInfo : public TaskQueue {
-
-
-public:
-    /* constructor */
-    TaskQueueInfo();
-
-    BASE_NEW_DELETE(TaskQueueInfo);
-
-    /* functions */
-    TaskQueuePtr create(HTask *task);
-    void free_(TaskQueuePtr queue);
-
-    void addFirst(TaskQueue* e);
-    void addLast(TaskQueue* e);
-    TaskQueue* getFirst();
-    TaskQueue* getLast();
-    int remove(TaskQueue* e);
-    TaskQueue* poll();
-    void moveToFirst(TaskQueue* e); // or use();
-    TaskQueue* get(int index);
-    TaskQueue* find(HTask *task);
-    int empty();
-    void freePool() ;
-
-    // Iterator
-    TaskQueue* getNext(TaskQueue* q) ;
-    int hasNext(TaskQueue* q);
-
-private:
-    /* variables */
-
-    static TaskQueueInfo taskQueuePool;
-    TaskQueue* first;
-    TaskQueue* last;
-
-    /* functions */
-    int extend_pool(int num);
-    void destroy();  
-}  ;
-
-#endif