changeset 301:bcb81858aa62

remove deprecated source. not work.
author tkaito@localhost.localdomain
date Sun, 07 Jun 2009 19:45:41 +0900
parents 0691f38195f6
children b0d37afab06a
files TaskManager/Cell/spe/CellScheduler.cc TaskManager/Makefile.cell TaskManager/Test/test_render/.gdbinit TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTaskImpl.cc TaskManager/kernel/schedule/Scheduler.cc include/TaskManager/ListData.h include/TaskManager/SchedExit.h include/TaskManager/SchedTask.h include/TaskManager/SchedTaskBase.h include/TaskManager/SchedTaskImpl.h include/TaskManager/Scheduler.h include/TaskManager/TaskList.h include/TaskManager/base.h
diffstat 14 files changed, 874 insertions(+), 813 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellScheduler.cc	Sun Jun 07 17:44:08 2009 +0900
+++ b/TaskManager/Cell/spe/CellScheduler.cc	Sun Jun 07 19:45:41 2009 +0900
@@ -6,7 +6,7 @@
 
 // ユーザプログラムで定義
 // なんだけど、それは微妙じゃね?
-// extern void task_init(void);
+extern void task_init(void);
 
 void
 CellScheduler::init_impl(void)
@@ -15,8 +15,9 @@
 
     mainMemNum = 0;
 
-    // task_init(); User 側で既に呼んでいる...
-    // Fifo では呼んでないし...
+    task_init(); // PPE側ではUser 側で既に呼んでいる...
+    // SPE側はここで呼び出す必要がある
+    // Fifo ではSPEは無いので呼び出されない
 }
 
 void*
--- a/TaskManager/Makefile.cell	Sun Jun 07 17:44:08 2009 +0900
+++ b/TaskManager/Makefile.cell	Sun Jun 07 19:45:41 2009 +0900
@@ -7,6 +7,12 @@
 CELL_SPE_SRCS = $(wildcard $(CELL_SPE_DIR)/*.cc)
 CELL_SPE_OBJS = $(CELL_SPE_SRCS:.cc=.o)
 
+CELL_SPE_KERNEL = kernel/schedule
+CELL_SPE_KERNEL_OBJS = $(CELL_SPE_DIR)/SchedExit.o $(CELL_SPE_DIR)/SchedNop2Ready.o \
+ $(CELL_SPE_DIR)/Scheduler.o $(CELL_SPE_DIR)/SchedMail.o $(CELL_SPE_DIR)/SchedTask.o \
+ $(CELL_SPE_DIR)/TaskGroup.o $(CELL_SPE_DIR)/SchedNop.o $(CELL_SPE_DIR)/SchedTaskList.o
+
+
 SPUCC = spu-g++
 
 EXTRA_CFLAGS = -D__CERIUM_CELL__ -fno-strict-aliasing
@@ -24,12 +30,32 @@
 $(PPE_ALL_OBJS): %.o : %.cc
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@
 
-$(SPETARGET): $(CELL_SPE_OBJS)
-	ar crus $@ $(CELL_SPE_OBJS)
+$(SPETARGET): $(CELL_SPE_OBJS) $(CELL_SPE_KERNEL_OBJS)
+	ar crus $@ $(CELL_SPE_OBJS) $(CELL_SPE_KERNEL_OBJS)
 
 $(CELL_SPE_OBJS): %.o : %.cc
 	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
 
+$(CELL_SPE_KERNEL_OBJS):
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+
+$(CELL_SPE_DIR)/SchedExit.o: $(CELL_SPE_KERNEL)/SchedExit.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/SchedNop2Ready.o: $(CELL_SPE_KERNEL)/SchedNop2Ready.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/Scheduler.o: $(CELL_SPE_KERNEL)/Scheduler.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/SchedMail.o: $(CELL_SPE_KERNEL)/SchedMail.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/SchedTask.o: $(CELL_SPE_KERNEL)/SchedTask.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/TaskGroup.o: $(CELL_SPE_KERNEL)/TaskGroup.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/SchedNop.o: $(CELL_SPE_KERNEL)/SchedNop.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+$(CELL_SPE_DIR)/SchedTaskList.o: $(CELL_SPE_KERNEL)/SchedTaskList.cc
+	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
+
 celldistclean: cellclean
 	rm -f $(TARGET)
 	rm -f $(SPETARGET)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Test/test_render/.gdbinit	Sun Jun 07 19:45:41 2009 +0900
@@ -0,0 +1,10 @@
+define si 
+  stepi
+  x/1i $pc
+end
+define ni
+  nexti
+  x/1i $pc
+end
+break main
+run -video fb -width 1920 -height 1080
\ No newline at end of file
--- a/TaskManager/kernel/schedule/SchedTask.cc	Sun Jun 07 17:44:08 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Sun Jun 07 19:45:41 2009 +0900
@@ -1,555 +1,5 @@
-#include <stdlib.h>
-#include <string.h>
 #include "SchedTask.h"
-#include "SchedTaskList.h"
-#include "SchedNop2Ready.h"
-#include "DmaManager.h"
-#include "error.h"
-#include "TaskManager.h"
-
-extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT];
-
-//#define NO_PIPELINE 
-
-SchedTask*
-createSchedTask(TaskPtr task)
-{
-    return task_list[task->command]();
-}
-
-SchedTask::SchedTask(void)
-{
-    __list        = NULL;
-    __task        = NULL;
-    __inListData  = NULL;
-    __outListData = NULL;
-    __readbuf     = NULL;
-    __writebuf    = NULL;
-    __scheduler   = NULL;
-    __taskGroup   = NULL;
-    __renew_flag  = 0;
-    __cur_index   = 0;
-    __flag_renewTask = SCHED_TASK_NORMAL;
-    
-    ex_init  = &SchedTask::ex_init_normal;
-    ex_read  = &SchedTask::ex_read_normal;
-    ex_exec  = &SchedTask::ex_exec_normal;
-    ex_write = &SchedTask::ex_write_normal;
-    ex_next  = &SchedTask::ex_next_normal;
-
-    run_func = &SchedTask::run;
-}
-
-/**
- * dma_store の wait を行う
- * このタスクが RenewTask だった場合、
- * __inListData や __outListData は
- * Scheduler の持つ、使い回しの buffer ではなく
- * 新たに allocate されたものなので、ここで free する
- */
-SchedTask::~SchedTask(void)
-{
-    if (__flag_renewTask == SCHED_TASK_RENEW) {
-	free(__inListData);
-        free(__outListData);
- 
-	/**
-	 * __list != NULL の場合、
-	 * この Task が __list の最後の Task になるので (SchedTask::next 参照)
-	 * このタイミングで __list を解放する
-	 *   (free に渡されるアドレスが正しいものとなる)。
-	 * それ以外の Task では当然解放しない。
-	 *  __list == NULL なので、free に渡しても無問題
-	 */
-	free(__list);
-    }
-
-    delete smanager;
-}
-
-/**                                                                         
- * このタスクを Renew Task とし、それに応じた関数をセットする
- */
-void
-SchedTask::__setRenew(void)
-{
-    __flag_renewTask = SCHED_TASK_RENEW;
-
-    ex_init   = &SchedTask::ex_init_renew;
-    ex_read   = &SchedTask::ex_read_renew;
-    ex_exec   = &SchedTask::ex_exec_renew;
-    ex_write  = &SchedTask::ex_write_renew; 
-    ex_next   = &SchedTask::ex_next_renew;
-}
-
-void
-SchedTask::__init__(TaskListPtr _list, TaskPtr _task, int index,
-		    ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc)
-{
-    __list        = _list;
-    __task        = _task;
-    __inListData  = rbuf;
-    __outListData = wbuf;
-    __scheduler   = sc;
-    __cur_index   = index;
-
-    smanager = new STaskManager(this);
-
-    __scheduler->mainMem_wait();
-
-    (this->*ex_init)();
-}
-
-/**
- * PPE 内で生成されたタスクの ex_init()
- */
-void
-SchedTask::ex_init_normal(void)
-{
-    __scheduler->dma_load(__inListData, (uint32)__task->inData,
-			  sizeof(ListData), DMA_READ_IN_LIST);
-    __scheduler->dma_load(__outListData, (uint32)__task->outData,
-			  sizeof(ListData), DMA_READ_OUT_LIST);
-#if defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ_IN_LIST);
-    __scheduler->dma_wait(DMA_READ_OUT_LIST);
-#endif
-    
-    __taskGroup = new TaskGroup;
-    __taskGroup->command = __task->self;
-}
-
-/**
- * SPE 内で生成されたタスクの ex_init()
- * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので
- * ex_init_normal() と違い、ここでは値を渡すだけ
- */
-void
-SchedTask::ex_init_renew(void)
-{
-    __inListData = __task->inData;
-    __outListData = __task->outData;
-    __taskGroup = (TaskGroupPtr)__task->self;    
-}
-
-/**
- * [Todo]
- *   データの読み込み場所を readbuf ではなく、
- *   ユーザ自身で決めれるようになるといいかもしれない。
- *
- *   # TaskManager が勝手に消すことなく、
- *   # ユーザが SPE 上に持ち続けることができるため。
- *   # もちろん管理はユーザに任せるわけだ。
- */
-void
-SchedTask::read(void)
-{    
-    __debug("[SchedTask:%s]\n", __FUNCTION__);
-
-#if !defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ_IN_LIST);
-    __scheduler->dma_wait(DMA_READ_OUT_LIST);
-#endif
-
-    __writebuf = __scheduler->allocate(__outListData->size);
-    
-    // 読むデータが一つもなければ無視
-    if (__inListData->length == 0) return;
-
-    // load Input Data
-    __readbuf = __scheduler->allocate(__inListData->size);
-    __scheduler->dma_loadList(__inListData, __readbuf, DMA_READ);
-
-#if defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ);
-#endif
-
-    (this->*ex_read)();
-}
-
-void
-SchedTask::exec(void)
-{
-    __debug("[SchedTask:%s]\n", __FUNCTION__);
-
-#if !defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ);
-#endif
-
-    //run(__readbuf, __writebuf);
-    (this->*run_func)(__readbuf, __writebuf);
-
-    free(__readbuf);
-
-    if (__taskGroup->status() != 0) {
-	__task->self = __taskGroup->command;
-	delete __taskGroup;
-	__taskGroup = NULL;
-    }
-
-
-    // 書き込む領域がなければ無視
-    if (__outListData->length > 0) {
-	__scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
-
-#if defined(NO_PIPELINE)
-	__scheduler->dma_wait(DMA_WRITE);
-	free(__writebuf);
-#endif
-    }
-
-    (this->*ex_exec)();
-}
-
-void
-SchedTask::write(void)
-{
-    __debug("[SchedTask:%s]\n", __FUNCTION__);
-    
-#if !defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_WRITE);
-    free(__writebuf);
-#endif
-
-    if (__task->self == MY_SPE_NOP) return;
-
-    (this->*ex_write)();
-}
-
-/**
- * PPE 内で生成されたタスクの ex_read()
- */
-void
-SchedTask::ex_read_normal(void)
-{
-}
-
-/**
- * SPE 内で生成されたタスクの ex_read()
- */
-void
-SchedTask::ex_read_renew(void)
-{
-}
-
-/**
- * PPE 内で生成されたタスクの ex_exec()
- */
-void
-SchedTask::ex_exec_normal(void)
-{
-}
-
-/**
- * SPE 内で生成されたタスクの ex_exec()
- */
-void
-SchedTask::ex_exec_renew(void)
-{
-}
-
-
-
-/**
- * PPE 内で生成されたタスクの ex_write()
- * 
- * このタスク内で新たにタスクが生成され、
- * 且つそのタスクの終了を待つ必要がある場合、
- * PPE に終了したことは知らせない(command は送信しない)
- */
-void
-SchedTask::ex_write_normal(void)
-{
-    /**
-     * このタスク内で新たにタスクが生成されなかった
-     * or 生成されたが、そのタスクの終了を待つ必要は無い
-     */
-    if (__renew_flag == 0) {
-	__scheduler->mail_write(__task->self);
-    }
-}
 
-/**
- * SPE 内で生成されたタスクの ex_write()
- *
- *  A <- 親タスク
- *  | \
- *  B   C <- SPE 内で生成されたタスク
- *
- * A は SPE 内で B, C を生成したとする。
- * B と C が終了したら、A が PPE に送るはずだったコマンドが
- * 子タスクに引き継がれているので、最後に実行された子タスクが
- * PPE に mail 送信する。
- */
-void
-SchedTask::ex_write_renew(void)
-{
-    uint32 cmd;
-	
-    __taskGroup->remove(__task);
-    cmd = __taskGroup->status();    
-
-    // タスク内で作られた全てのタスクが終了した
-    if (cmd != 0) {
-	delete __taskGroup;
-	__scheduler->mail_write(cmd);
-    }
-}
-    
-SchedTaskBase*
-SchedTask::next(Scheduler *m, SchedTaskBase *p)
-{
-    __debug("[SchedTask:%s]\n", __FUNCTION__);
-
-    delete p;
-
-    return (this->*ex_next)();
-}
-
-SchedTaskBase*
-SchedTask::ex_next_normal(void)
-{
-    if (__cur_index < __list->length) {
-	SchedTaskBase *nextSched;
-
-	nextSched = __scheduler->get_nextRenewTaskList();
-	
-	// RenewTask がある
-	if (nextSched) {
-	    __scheduler->set_backupTaskList(__list);
-	    __scheduler->set_backupTaskListIndex(__cur_index);
-	    return nextSched;
-	} else {
-	    TaskPtr nextTask = &__list->tasks[__cur_index++];
-	    nextSched = createSchedTask(nextTask);
-	    ((SchedTask*)nextSched)->__init__(__list, nextTask, __cur_index,
-					      __scheduler->get_curReadBuf(),
-					      __scheduler->get_curWriteBuf(),
-					      __scheduler);
-	    return nextSched;
-	}
-    } else {
-	uint32 nextList = (uint32)__list->next;
-	
-	if (nextList == 0) {
-	    return new SchedNop2Ready(__scheduler);
-	} else {
-	    return createSchedTaskList(nextList, __scheduler,
-				       SCHED_TASKLIST_NORMAL);
-	}
-    }
-}
-
-/**
- *
- */
-SchedTaskBase*
-SchedTask::ex_next_renew(void)
-{
-    TaskPtr nextTask;
-    SchedTask *nextSched;
-
-    if (__cur_index < __list->length) {
-	nextTask = &__list->tasks[__cur_index++];
-	nextSched = createSchedTask(nextTask);
-
-	// RenewTaskList を実行中なので
-	nextSched->__setRenew();
-	nextSched->__init__(__list, nextTask, __cur_index,
-			    __scheduler->get_curReadBuf(),
-			    __scheduler->get_curWriteBuf(),
-			    __scheduler);
-
-	/**
-	 * この理由は SchedTask:~SchedTask() で
-	 */
-	__list = NULL;
-	return nextSched;
-    } else {
-	SchedTaskBase *nextList;
-	
-	nextList = __scheduler->get_nextRenewTaskList();
-	
-	if (nextList) {
-	    return nextList;
-	} else {
-	    TaskListPtr nextList = __scheduler->get_backupTaskList();
-
-	    // 中断した TaskList がある
-	    if (nextList) {
-		__cur_index = __scheduler->get_backupTaskListIndex();
-		
-		nextTask = &nextList->tasks[__cur_index++];
-		nextSched = createSchedTask(nextTask);
-		
-		nextSched->__init__(nextList, nextTask, __cur_index,
-				    __scheduler->get_curReadBuf(),
-				    __scheduler->get_curWriteBuf(),
-				    __scheduler);
-		return nextSched;
-	    } else {
-		return new SchedNop2Ready(__scheduler);
-	    }
-	}
-    }
-}
-
-int
-SchedTask::get_cpuid(void)
-{
-    return __scheduler->id;
-}
-
-/**
- * task->add_inData で与えられた順番に対応する index (0〜n-1) で、
- * buffer から対応するデータを返す。
- */
-void*
-SchedTask::get_input(void *buff, int index)
-{
-    if (buff != NULL) {
-	return (void*)((int)buff + __inListData->bound[index]);
-    } else {
-	return NULL;
-    }
-}
-
-/**
- * get_input(index) のアドレスを返す
- */
-uint32
-SchedTask::get_inputAddr(int index)
-{
-    return __inListData->element[index].addr;
-}
-
-/**
- * get_input(index) のサイズを返す
- */
-int
-SchedTask::get_inputSize(int index)
-{
-    return __inListData->element[index].size;
-}
-
-/**
- * write buffer の領域を返す。
- */
-void*
-SchedTask::get_output(void *buff, int index)
-{
-    if (buff != NULL) {
-	return (void*)((int)buff + __outListData->bound[index]);
-    } else {
-	return NULL;
-    }
-}
-
-/**
- * get_output(index) のアドレスを返す
- */
-uint32
-SchedTask::get_outputAddr(int index)
-{
-    return __outListData->element[index].addr;
-}
-
-/**
- * get_output(index) のサイズを返す
- */
-int
-SchedTask::get_outputSize(int index)
-{
-    return __outListData->element[index].size;
-}
-
-int
-SchedTask::get_param(int index)
-{
-    return __task->param[index];
-}
-
-TaskPtr
-SchedTask::create_task(int cmd)
-{
-    TaskListPtr taskList = __scheduler->get_renewListBuf();
-    TaskPtr p = &taskList->tasks[taskList->length++];
-    p->command = cmd;
-
-    p->inData = (ListData*)__scheduler->allocate(sizeof(ListData));
-    p->outData = (ListData*)__scheduler->allocate(sizeof(ListData));
-
-    p->inData->clear();
-    p->outData->clear();
-
-    p->self = MY_SPE_NOP;
-    p->param_size = 0;
-
-    return p;
-}
-
-/**
- * 生成したタスクが終了してから、メインスケジューラ(PPE) に
- * タスクが終了した旨を知らせる。
- *
- * @param[in] waitTask タスク内で生成したタスク
- */
-void
-SchedTask::wait_task(TaskPtr waitTask)
-{
-    waitTask->self = (uint32)__taskGroup;
-
-    __scheduler->add_groupTask(__taskGroup, waitTask);
-
-    __renew_flag++;
-}
-
-void*
-SchedTask::global_alloc(int id, int size) {
-    return __scheduler->global_alloc(id, size);
-}
-
-void*
-SchedTask::global_get(int id) {
-    return __scheduler->global_get(id);
-}
-
-void
-SchedTask::global_free(int id) {
-    __scheduler->global_free(id);
-}
-
-void
-SchedTask::mainMem_alloc(int id, int size) {
-    __scheduler->mainMem_alloc(id, size);
-}
-
-void
-SchedTask::mainMem_wait(void) {
-    __scheduler->mainMem_wait();
-}
-
-void*
-SchedTask::mainMem_get(int id) {
-    return __scheduler->mainMem_get(id);
-}
-
-void*
-SchedTask::allocate(int size) {
-    return __scheduler->allocate(size);
-}
-
-void
-SchedTask::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {
-    __scheduler->dma_load(buf, addr, size, mask);
-}
-
-void
-SchedTask::dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {
-    __scheduler->dma_store(buf, addr, size, mask);
-}
-
-void
-SchedTask::dma_wait(uint32 mask) {
-    __scheduler->dma_wait(mask);
-}
+    /* constructor */
+    SchedTask();
+    ~SchedTask();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/schedule/SchedTaskImpl.cc	Sun Jun 07 19:45:41 2009 +0900
@@ -0,0 +1,555 @@
+#include <stdlib.h>
+#include <string.h>
+#include "SchedTaskImpl.h"
+#include "SchedTaskList.h"
+#include "SchedNop2Ready.h"
+#include "DmaManager.h"
+#include "error.h"
+#include "TaskManager.h"
+
+extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT];
+
+//#define NO_PIPELINE 
+
+SchedTask*
+createSchedTask(TaskPtr task)
+{
+    return task_list[task->command]();
+}
+
+SchedTaskImpl::SchedTask(void)
+{
+    __list        = NULL;
+    __task        = NULL;
+    __inListData  = NULL;
+    __outListData = NULL;
+    __readbuf     = NULL;
+    __writebuf    = NULL;
+    __scheduler   = NULL;
+    __taskGroup   = NULL;
+    __renew_flag  = 0;
+    __cur_index   = 0;
+    __flag_renewTask = SCHED_TASK_NORMAL;
+    
+    ex_init  = &SchedTaskImpl::ex_init_normal;
+    ex_read  = &SchedTaskImpl::ex_read_normal;
+    ex_exec  = &SchedTaskImpl::ex_exec_normal;
+    ex_write = &SchedTaskImpl::ex_write_normal;
+    ex_next  = &SchedTaskImpl::ex_next_normal;
+
+    run_func = &SchedTaskImpl::run;
+}
+
+/**
+ * dma_store の wait を行う
+ * このタスクが RenewTask だった場合、
+ * __inListData や __outListData は
+ * Scheduler の持つ、使い回しの buffer ではなく
+ * 新たに allocate されたものなので、ここで free する
+ */
+SchedTaskImpl::~SchedTask(void)
+{
+    if (__flag_renewTask == SCHED_TASK_RENEW) {
+	free(__inListData);
+        free(__outListData);
+ 
+	/**
+	 * __list != NULL の場合、
+	 * この Task が __list の最後の Task になるので (SchedTaskImpl::next 参照)
+	 * このタイミングで __list を解放する
+	 *   (free に渡されるアドレスが正しいものとなる)。
+	 * それ以外の Task では当然解放しない。
+	 *  __list == NULL なので、free に渡しても無問題
+	 */
+	free(__list);
+    }
+
+    delete smanager;
+}
+
+/**                                                                         
+ * このタスクを Renew Task とし、それに応じた関数をセットする
+ */
+void
+SchedTaskImpl::__setRenew(void)
+{
+    __flag_renewTask = SCHED_TASK_RENEW;
+
+    ex_init   = &SchedTaskImpl::ex_init_renew;
+    ex_read   = &SchedTaskImpl::ex_read_renew;
+    ex_exec   = &SchedTaskImpl::ex_exec_renew;
+    ex_write  = &SchedTaskImpl::ex_write_renew; 
+    ex_next   = &SchedTaskImpl::ex_next_renew;
+}
+
+void
+SchedTaskImpl::__init__(TaskListPtr _list, TaskPtr _task, int index,
+		    ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc)
+{
+    __list        = _list;
+    __task        = _task;
+    __inListData  = rbuf;
+    __outListData = wbuf;
+    __scheduler   = sc;
+    __cur_index   = index;
+
+    smanager = new STaskManager(this);
+
+    __scheduler->mainMem_wait();
+
+    (this->*ex_init)();
+}
+
+/**
+ * PPE 内で生成されたタスクの ex_init()
+ */
+void
+SchedTaskImpl::ex_init_normal(void)
+{
+    __scheduler->dma_load(__inListData, (uint32)__task->inData,
+			  sizeof(ListData), DMA_READ_IN_LIST);
+    __scheduler->dma_load(__outListData, (uint32)__task->outData,
+			  sizeof(ListData), DMA_READ_OUT_LIST);
+#if defined(NO_PIPELINE)
+    __scheduler->dma_wait(DMA_READ_IN_LIST);
+    __scheduler->dma_wait(DMA_READ_OUT_LIST);
+#endif
+    
+    __taskGroup = new TaskGroup;
+    __taskGroup->command = __task->self;
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_init()
+ * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので
+ * ex_init_normal() と違い、ここでは値を渡すだけ
+ */
+void
+SchedTaskImpl::ex_init_renew(void)
+{
+    __inListData = __task->inData;
+    __outListData = __task->outData;
+    __taskGroup = (TaskGroupPtr)__task->self;    
+}
+
+/**
+ * [Todo]
+ *   データの読み込み場所を readbuf ではなく、
+ *   ユーザ自身で決めれるようになるといいかもしれない。
+ *
+ *   # TaskManager が勝手に消すことなく、
+ *   # ユーザが SPE 上に持ち続けることができるため。
+ *   # もちろん管理はユーザに任せるわけだ。
+ */
+void
+SchedTaskImpl::read(void)
+{    
+    __debug("[SchedTask:%s]\n", __FUNCTION__);
+
+#if !defined(NO_PIPELINE)
+    __scheduler->dma_wait(DMA_READ_IN_LIST);
+    __scheduler->dma_wait(DMA_READ_OUT_LIST);
+#endif
+
+    __writebuf = __scheduler->allocate(__outListData->size);
+    
+    // 読むデータが一つもなければ無視
+    if (__inListData->length == 0) return;
+
+    // load Input Data
+    __readbuf = __scheduler->allocate(__inListData->size);
+    __scheduler->dma_loadList(__inListData, __readbuf, DMA_READ);
+
+#if defined(NO_PIPELINE)
+    __scheduler->dma_wait(DMA_READ);
+#endif
+
+    (this->*ex_read)();
+}
+
+void
+SchedTaskImpl::exec(void)
+{
+    __debug("[SchedTask:%s]\n", __FUNCTION__);
+
+#if !defined(NO_PIPELINE)
+    __scheduler->dma_wait(DMA_READ);
+#endif
+
+    //run(__readbuf, __writebuf);
+    (this->*run_func)(__readbuf, __writebuf);
+
+    free(__readbuf);
+
+    if (__taskGroup->status() != 0) {
+	__task->self = __taskGroup->command;
+	delete __taskGroup;
+	__taskGroup = NULL;
+    }
+
+
+    // 書き込む領域がなければ無視
+    if (__outListData->length > 0) {
+	__scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
+
+#if defined(NO_PIPELINE)
+	__scheduler->dma_wait(DMA_WRITE);
+	free(__writebuf);
+#endif
+    }
+
+    (this->*ex_exec)();
+}
+
+void
+SchedTaskImpl::write(void)
+{
+    __debug("[SchedTask:%s]\n", __FUNCTION__);
+    
+#if !defined(NO_PIPELINE)
+    __scheduler->dma_wait(DMA_WRITE);
+    free(__writebuf);
+#endif
+
+    if (__task->self == MY_SPE_NOP) return;
+
+    (this->*ex_write)();
+}
+
+/**
+ * PPE 内で生成されたタスクの ex_read()
+ */
+void
+SchedTaskImpl::ex_read_normal(void)
+{
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_read()
+ */
+void
+SchedTaskImpl::ex_read_renew(void)
+{
+}
+
+/**
+ * PPE 内で生成されたタスクの ex_exec()
+ */
+void
+SchedTaskImpl::ex_exec_normal(void)
+{
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_exec()
+ */
+void
+SchedTaskImpl::ex_exec_renew(void)
+{
+}
+
+
+
+/**
+ * PPE 内で生成されたタスクの ex_write()
+ * 
+ * このタスク内で新たにタスクが生成され、
+ * 且つそのタスクの終了を待つ必要がある場合、
+ * PPE に終了したことは知らせない(command は送信しない)
+ */
+void
+SchedTaskImpl::ex_write_normal(void)
+{
+    /**
+     * このタスク内で新たにタスクが生成されなかった
+     * or 生成されたが、そのタスクの終了を待つ必要は無い
+     */
+    if (__renew_flag == 0) {
+	__scheduler->mail_write(__task->self);
+    }
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_write()
+ *
+ *  A <- 親タスク
+ *  | \
+ *  B   C <- SPE 内で生成されたタスク
+ *
+ * A は SPE 内で B, C を生成したとする。
+ * B と C が終了したら、A が PPE に送るはずだったコマンドが
+ * 子タスクに引き継がれているので、最後に実行された子タスクが
+ * PPE に mail 送信する。
+ */
+void
+SchedTaskImpl::ex_write_renew(void)
+{
+    uint32 cmd;
+	
+    __taskGroup->remove(__task);
+    cmd = __taskGroup->status();    
+
+    // タスク内で作られた全てのタスクが終了した
+    if (cmd != 0) {
+	delete __taskGroup;
+	__scheduler->mail_write(cmd);
+    }
+}
+    
+SchedTaskBase*
+SchedTaskImpl::next(Scheduler *m, SchedTaskBase *p)
+{
+    __debug("[SchedTask:%s]\n", __FUNCTION__);
+
+    delete p;
+
+    return (this->*ex_next)();
+}
+
+SchedTaskBase*
+SchedTaskImpl::ex_next_normal(void)
+{
+    if (__cur_index < __list->length) {
+	SchedTaskBase *nextSched;
+
+	nextSched = __scheduler->get_nextRenewTaskList();
+	
+	// RenewTask がある
+	if (nextSched) {
+	    __scheduler->set_backupTaskList(__list);
+	    __scheduler->set_backupTaskListIndex(__cur_index);
+	    return nextSched;
+	} else {
+	    TaskPtr nextTask = &__list->tasks[__cur_index++];
+	    nextSched = createSchedTask(nextTask);
+	    ((SchedTask*)nextSched)->__init__(__list, nextTask, __cur_index,
+					      __scheduler->get_curReadBuf(),
+					      __scheduler->get_curWriteBuf(),
+					      __scheduler);
+	    return nextSched;
+	}
+    } else {
+	uint32 nextList = (uint32)__list->next;
+	
+	if (nextList == 0) {
+	    return new SchedNop2Ready(__scheduler);
+	} else {
+	    return createSchedTaskList(nextList, __scheduler,
+				       SCHED_TASKLIST_NORMAL);
+	}
+    }
+}
+
+/**
+ *
+ */
+SchedTaskBase*
+SchedTaskImpl::ex_next_renew(void)
+{
+    TaskPtr nextTask;
+    SchedTask *nextSched;
+
+    if (__cur_index < __list->length) {
+	nextTask = &__list->tasks[__cur_index++];
+	nextSched = createSchedTask(nextTask);
+
+	// RenewTaskList を実行中なので
+	nextSched->__setRenew();
+	nextSched->__init__(__list, nextTask, __cur_index,
+			    __scheduler->get_curReadBuf(),
+			    __scheduler->get_curWriteBuf(),
+			    __scheduler);
+
+	/**
+	 * この理由は SchedTask:~SchedTask() で
+	 */
+	__list = NULL;
+	return nextSched;
+    } else {
+	SchedTaskBase *nextList;
+	
+	nextList = __scheduler->get_nextRenewTaskList();
+	
+	if (nextList) {
+	    return nextList;
+	} else {
+	    TaskListPtr nextList = __scheduler->get_backupTaskList();
+
+	    // 中断した TaskList がある
+	    if (nextList) {
+		__cur_index = __scheduler->get_backupTaskListIndex();
+		
+		nextTask = &nextList->tasks[__cur_index++];
+		nextSched = createSchedTask(nextTask);
+		
+		nextSched->__init__(nextList, nextTask, __cur_index,
+				    __scheduler->get_curReadBuf(),
+				    __scheduler->get_curWriteBuf(),
+				    __scheduler);
+		return nextSched;
+	    } else {
+		return new SchedNop2Ready(__scheduler);
+	    }
+	}
+    }
+}
+
+int
+SchedTaskImpl::get_cpuid(void)
+{
+    return __scheduler->id;
+}
+
+/**
+ * task->add_inData で与えられた順番に対応する index (0〜n-1) で、
+ * buffer から対応するデータを返す。
+ */
+void*
+SchedTaskImpl::get_input(void *buff, int index)
+{
+    if (buff != NULL) {
+	return (void*)((int)buff + __inListData->bound[index]);
+    } else {
+	return NULL;
+    }
+}
+
+/**
+ * get_input(index) のアドレスを返す
+ */
+uint32
+SchedTaskImpl::get_inputAddr(int index)
+{
+    return __inListData->element[index].addr;
+}
+
+/**
+ * get_input(index) のサイズを返す
+ */
+int
+SchedTaskImpl::get_inputSize(int index)
+{
+    return __inListData->element[index].size;
+}
+
+/**
+ * write buffer の領域を返す。
+ */
+void*
+SchedTaskImpl::get_output(void *buff, int index)
+{
+    if (buff != NULL) {
+	return (void*)((int)buff + __outListData->bound[index]);
+    } else {
+	return NULL;
+    }
+}
+
+/**
+ * get_output(index) のアドレスを返す
+ */
+uint32
+SchedTaskImpl::get_outputAddr(int index)
+{
+    return __outListData->element[index].addr;
+}
+
+/**
+ * get_output(index) のサイズを返す
+ */
+int
+SchedTaskImpl::get_outputSize(int index)
+{
+    return __outListData->element[index].size;
+}
+
+int
+SchedTaskImpl::get_param(int index)
+{
+    return __task->param[index];
+}
+
+TaskPtr
+SchedTaskImpl::create_task(int cmd)
+{
+    TaskListPtr taskList = __scheduler->get_renewListBuf();
+    TaskPtr p = &taskList->tasks[taskList->length++];
+    p->command = cmd;
+
+    p->inData = (ListData*)__scheduler->allocate(sizeof(ListData));
+    p->outData = (ListData*)__scheduler->allocate(sizeof(ListData));
+
+    p->inData->clear();
+    p->outData->clear();
+
+    p->self = MY_SPE_NOP;
+    p->param_size = 0;
+
+    return p;
+}
+
+/**
+ * 生成したタスクが終了してから、メインスケジューラ(PPE) に
+ * タスクが終了した旨を知らせる。
+ *
+ * @param[in] waitTask タスク内で生成したタスク
+ */
+void
+SchedTaskImpl::wait_task(TaskPtr waitTask)
+{
+    waitTask->self = (uint32)__taskGroup;
+
+    __scheduler->add_groupTask(__taskGroup, waitTask);
+
+    __renew_flag++;
+}
+
+void*
+SchedTaskImpl::global_alloc(int id, int size) {
+    return __scheduler->global_alloc(id, size);
+}
+
+void*
+SchedTaskImpl::global_get(int id) {
+    return __scheduler->global_get(id);
+}
+
+void
+SchedTaskImpl::global_free(int id) {
+    __scheduler->global_free(id);
+}
+
+void
+SchedTaskImpl::mainMem_alloc(int id, int size) {
+    __scheduler->mainMem_alloc(id, size);
+}
+
+void
+SchedTaskImpl::mainMem_wait(void) {
+    __scheduler->mainMem_wait();
+}
+
+void*
+SchedTaskImpl::mainMem_get(int id) {
+    return __scheduler->mainMem_get(id);
+}
+
+void*
+SchedTaskImpl::allocate(int size) {
+    return __scheduler->allocate(size);
+}
+
+void
+SchedTaskImpl::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {
+    __scheduler->dma_load(buf, addr, size, mask);
+}
+
+void
+SchedTaskImpl::dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {
+    __scheduler->dma_store(buf, addr, size, mask);
+}
+
+void
+SchedTaskImpl::dma_wait(uint32 mask) {
+    __scheduler->dma_wait(mask);
+}
--- a/TaskManager/kernel/schedule/Scheduler.cc	Sun Jun 07 17:44:08 2009 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Sun Jun 07 19:45:41 2009 +0900
@@ -11,6 +11,9 @@
     delete connector;
 }
 
+/*! @brief speTaskの入出力のパイプラインバッファを確保する
+ */
+
 void
 Scheduler::init(void)
 {
--- a/include/TaskManager/ListData.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/ListData.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,9 +1,7 @@
 #ifndef INCLUDED_LIST_DATA
 #define INCLUDED_LIST_DATA
 
-#ifndef INCLUDED_BASE_H_
-#  include "base.h"
-#endif
+#include "base.h"
 
 #define MAX_LIST_DMA_SIZE 8
 
--- a/include/TaskManager/SchedExit.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/SchedExit.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,17 +1,10 @@
 #ifndef INCLUDED_SCHED_EXIT
 #define INCLUDED_SCHED_EXIT
 
-#ifndef INCLUDED_BASE_H_
-#  include "base.h"
-#endif
+#include "base.h"
+#include "Scheduler.h"
+#include "SchedTaskBase.h"
 
-#ifndef INCLUDED_SCHEDULER
-#  include "Scheduler.h"
-#endif
-
-#ifndef INCLUDED_SCHED_TASK_BASE
-#  include "SchedTaskBase.h"
-#endif
 
 class SchedExit : public SchedTaskBase {
 public:
--- a/include/TaskManager/SchedTask.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/SchedTask.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,26 +1,11 @@
 #ifndef INCLUDED_SCHED_TASK
 #define INCLUDED_SCHED_TASK
 
-#ifndef INCLUDED_BASE_H_
-#  include "base.h"
-#endif
-
-#ifndef INCLUDED_SCHEDULER
-#  include "Scheduler.h"
-#endif
-
-#ifndef INCLUDED_SCHED_TASK_BASE
-#  include "SchedTaskBase.h"
-#endif
-
-#ifndef INCLUDED_LIST_DATA
-#  include "ListData.h"
-#endif
-
-#ifndef INCLUDED_TASK_GROUP
-#  include "TaskGroup.h"
-#endif
-
+#include "base.h"
+#include "Scheduler.h"
+#include "SchedTaskBase.h"
+#include "ListData.h"
+#include "TaskGroup.h"
 
 class SchedTask : public SchedTaskBase {
 public:
@@ -31,92 +16,13 @@
     BASE_NEW_DELETE(SchedTask);
 
     /* variables */
-
-    // Task を実行するスケジューラ自身
-    Scheduler *__scheduler;
-
-    // 現在スケジューラが実行している TaskList と、このタスクに対応する Task
-    TaskListPtr __list;
-    TaskPtr __task;
-
-    // read/write 用の ListData
-    ListDataPtr __inListData;
-    ListDataPtr __outListData;
-
-    /**
-     * read データ、write 用のバッファ
-     * readbuf には タスク登録時に設定した入力データが入っている。
-     * writebuf にデータを描き込んでおくと、
-     * タスク登録時に設定した出力先に書き込む
-     */
-    void *__readbuf;
-    void *__writebuf;
-
-    // Task の、Tasklist での位置。(task = &list[cur_index-1])
-    int __cur_index;
-
-    // タスク内で生成されたタスクのグループ
-    TaskGroup *__taskGroup;
-
-    // このタスク内で生成されたタスクの数
-    int __renew_flag;
-
-    // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No
-    int __flag_renewTask;
-
-    // タスクがメインメモリ側で生成されたものか、
-    // SPE で生成されたものかによって、データの扱いが変わってくる。
-    // そのために if (__flag_renewTask) を連発するのはよくないので
-    // 関数ポインタで持っておく
-    void (SchedTask::*ex_init)(void);
-    void (SchedTask::*ex_read)(void);
-    void (SchedTask::*ex_exec)(void);
-    void (SchedTask::*ex_write)(void);
-    SchedTaskBase* (SchedTask::*ex_next)(void);
-    
-    /* functions */
-    void __setRenew(void);
-    void __init__(TaskListPtr _list, TaskPtr _task, int index,
-		  ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc);
-
-    // override
-    void read(void);
-    void exec(void);
-    void write(void);
-    SchedTaskBase* next(Scheduler *, SchedTaskBase *);
-
+    SchedTaskImpl* schedTaskImpl;
     // ここをユーザが継承して
     // それぞれのタスクに対応した処理を記述する
     virtual int run(void* r, void *w) { return 0; }
 
-    int (SchedTask::*run_func)(void* r, void *w);
-
-    //---  System API ---
-    SchedTask* get_nextTask(TaskListPtr list);
-    
-    /**
-     * PPE で生成されたタスクに対する
-     * __init__, read,exec,write,next の付属(?)処理
-     */
-    void ex_init_normal(void);
-    void ex_read_normal(void);
-    void ex_exec_normal(void);
-    void ex_write_normal(void);
-    SchedTaskBase* ex_next_normal(void);
-
-    /**
-     * SPE で生成されたタスクに対する
-     * __inti__, ead,exec,write,next の付属(?)処理
-     */
-    void ex_init_renew(void);
-    void ex_read_renew(void);
-    void ex_exec_renew(void);
-    void ex_write_renew(void);
-    SchedTaskBase* ex_next_renew(void);
-
-
     //---  User API ---
-    int get_cpuid(void);
+    int get_cpuid() {schedTaskImpl->get_cpuid();}
 
     void* get_input(void *buff, int index);
     void* get_output(void *buff, int index);
@@ -142,104 +48,6 @@
     void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
     void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
     void dma_wait(uint32 mask);
-
-    class STaskManager {
-    public:
-	STaskManager(SchedTask *_t) {
-	    outer = _t;
-	}
-
-	BASE_NEW_DELETE(STaskManager);
-
-	SchedTask *outer;
-
-	int get_cpuid(void) {
-	    return outer->get_cpuid();
-	}
-	
-	void* get_input(int index) {
-	    return outer->get_input(outer->__readbuf, index);
-	}
-
-	void* get_output(int index) {
-	    return outer->get_output(outer->__writebuf, index);
-	}
-
-	uint32 get_inputAddr(int index) {
-	    return outer->get_inputAddr(index);
-	}
-
-	uint32 get_outputAddr(int index) {
-	    return outer->get_outputAddr(index);
-	}
-
-	uint32 get_inputSize(int index) {
-	    return outer->get_inputSize(index);
-	}
-
-	uint32 get_outputSize(int index) {
-	    return outer->get_outputSize(index);
-	}
-
-	int get_param(int index) {
-	    return outer->get_param(index);
-	}
-
-	TaskPtr create_task(int cmd) {
-	    return outer->create_task(cmd);
-	}
-
-	void wait_task(TaskPtr waitTask) {
-	    outer->wait_task(waitTask);
-	}
-	
-	void* global_alloc(int id, int size) {
-	    return outer->global_alloc(id, size);
-	}
-
-	void* global_get(int id) {
-	    return outer->global_get(id);
-	}
-
-	void global_free(int id) {
-	    outer->global_free(id);
-	}
-
-	void mainMem_alloc(int id, int size) {
-	    outer->mainMem_alloc(id, size);
-	}
-
-	void mainMem_wait(void) {
-	    outer->mainMem_wait();
-	}
-
-	void* mainMem_get(int id) {
-	    return outer->mainMem_get(id);
-	}
-
-	void *allocate(int size) {
-	    return outer->allocate(size);
-	}
-
-	void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {
-	    outer->dma_load(buf, addr, size, mask);
-	}
-
-	void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {
-	    outer->dma_store(buf, addr, size, mask);
-	}
-
-	void dma_wait(uint32 mask) {
-	    outer->dma_wait(mask);
-	}
-    };
-
-    STaskManager *smanager;
-};
-
-const int SCHED_TASK_NORMAL = 0;
-const int SCHED_TASK_RENEW  = 1;
-
 #endif
 
 extern SchedTask* createSchedTask(TaskPtr);
--- a/include/TaskManager/SchedTaskBase.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/SchedTaskBase.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,13 +1,8 @@
 #ifndef INCLUDED_SCHED_TASK_BASE
 #define INCLUDED_SCHED_TASK_BASE
 
-#ifndef INCLUDED_BASE_H_
-#  include "base.h"
-#endif
-
-#ifndef INCLUDED_SCHEDULER
-#  include "Scheduler.h"
-#endif
+#include "base.h"
+#include "Scheduler.h"
 
 class Scheduler;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/TaskManager/SchedTaskImpl.h	Sun Jun 07 19:45:41 2009 +0900
@@ -0,0 +1,245 @@
+#ifndef INCLUDED_SCHED_TASK
+#define INCLUDED_SCHED_TASK
+
+#ifndef INCLUDED_BASE_H_
+#  include "base.h"
+#endif
+
+#ifndef INCLUDED_SCHEDULER
+#  include "Scheduler.h"
+#endif
+
+#ifndef INCLUDED_SCHED_TASK_BASE
+#  include "SchedTaskBase.h"
+#endif
+
+#ifndef INCLUDED_LIST_DATA
+#  include "ListData.h"
+#endif
+
+#ifndef INCLUDED_TASK_GROUP
+#  include "TaskGroup.h"
+#endif
+
+
+class SchedTask : public SchedTaskBase {
+public:
+    /* constructor */
+    SchedTask(void);
+    ~SchedTask(void);
+
+    BASE_NEW_DELETE(SchedTask);
+
+    /* variables */
+
+    // Task を実行するスケジューラ自身
+    Scheduler *__scheduler;
+
+    // 現在スケジューラが実行している TaskList と、このタスクに対応する Task
+    TaskListPtr __list;
+    TaskPtr __task;
+
+    // read/write 用の ListData
+    ListDataPtr __inListData;
+    ListDataPtr __outListData;
+
+    /**
+     * read データ、write 用のバッファ
+     * readbuf には タスク登録時に設定した入力データが入っている。
+     * writebuf にデータを描き込んでおくと、
+     * タスク登録時に設定した出力先に書き込む
+     */
+    void *__readbuf;
+    void *__writebuf;
+
+    // Task の、Tasklist での位置。(task = &list[cur_index-1])
+    int __cur_index;
+
+    // タスク内で生成されたタスクのグループ
+    TaskGroup *__taskGroup;
+
+    // このタスク内で生成されたタスクの数
+    int __renew_flag;
+
+    // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No
+    int __flag_renewTask;
+
+    // タスクがメインメモリ側で生成されたものか、
+    // SPE で生成されたものかによって、データの扱いが変わってくる。
+    // そのために if (__flag_renewTask) を連発するのはよくないので
+    // 関数ポインタで持っておく
+    void (SchedTask::*ex_init)(void);
+    void (SchedTask::*ex_read)(void);
+    void (SchedTask::*ex_exec)(void);
+    void (SchedTask::*ex_write)(void);
+    SchedTaskBase* (SchedTask::*ex_next)(void);
+    
+    /* functions */
+    void __setRenew(void);
+    void __init__(TaskListPtr _list, TaskPtr _task, int index,
+		  ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc);
+
+    // override
+    void read(void);
+    void exec(void);
+    void write(void);
+    SchedTaskBase* next(Scheduler *, SchedTaskBase *);
+
+    // ここをユーザが継承して
+    // それぞれのタスクに対応した処理を記述する
+    virtual int run(void* r, void *w) { return 0; }
+
+    int (SchedTask::*run_func)(void* r, void *w);
+
+    //---  System API ---
+    SchedTask* get_nextTask(TaskListPtr list);
+    
+    /**
+     * PPE で生成されたタスクに対する
+     * __init__, read,exec,write,next の付属(?)処理
+     */
+    void ex_init_normal(void);
+    void ex_read_normal(void);
+    void ex_exec_normal(void);
+    void ex_write_normal(void);
+    SchedTaskBase* ex_next_normal(void);
+
+    /**
+     * SPE で生成されたタスクに対する
+     * __inti__, ead,exec,write,next の付属(?)処理
+     */
+    void ex_init_renew(void);
+    void ex_read_renew(void);
+    void ex_exec_renew(void);
+    void ex_write_renew(void);
+    SchedTaskBase* ex_next_renew(void);
+
+
+    //---  User API ---
+    int get_cpuid(void);
+
+    void* get_input(void *buff, int index);
+    void* get_output(void *buff, int index);
+    uint32 get_inputAddr(int index);
+    uint32 get_outputAddr(int index);
+    int get_inputSize(int index);
+    int get_outputSize(int index);
+    int get_param(int index);
+
+    TaskPtr create_task(int cmd);
+    void wait_task(TaskPtr waitTask);
+
+    void* global_alloc(int id, int size);
+    void* global_get(int id);
+    void global_free(int id);
+
+    void mainMem_alloc(int id, int size);
+    void mainMem_wait(void);
+    void* mainMem_get(int id);
+
+    void *allocate(int size);
+
+    void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
+    void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
+    void dma_wait(uint32 mask);
+
+    class STaskManager {
+    public:
+	STaskManager(SchedTask *_t) {
+	    outer = _t;
+	}
+
+	BASE_NEW_DELETE(STaskManager);
+
+	SchedTask *outer;
+
+	int get_cpuid(void) {
+	    return outer->get_cpuid();
+	}
+	
+	void* get_input(int index) {
+	    return outer->get_input(outer->__readbuf, index);
+	}
+
+	void* get_output(int index) {
+	    return outer->get_output(outer->__writebuf, index);
+	}
+
+	uint32 get_inputAddr(int index) {
+	    return outer->get_inputAddr(index);
+	}
+
+	uint32 get_outputAddr(int index) {
+	    return outer->get_outputAddr(index);
+	}
+
+	uint32 get_inputSize(int index) {
+	    return outer->get_inputSize(index);
+	}
+
+	uint32 get_outputSize(int index) {
+	    return outer->get_outputSize(index);
+	}
+
+	int get_param(int index) {
+	    return outer->get_param(index);
+	}
+
+	TaskPtr create_task(int cmd) {
+	    return outer->create_task(cmd);
+	}
+
+	void wait_task(TaskPtr waitTask) {
+	    outer->wait_task(waitTask);
+	}
+	
+	void* global_alloc(int id, int size) {
+	    return outer->global_alloc(id, size);
+	}
+
+	void* global_get(int id) {
+	    return outer->global_get(id);
+	}
+
+	void global_free(int id) {
+	    outer->global_free(id);
+	}
+
+	void mainMem_alloc(int id, int size) {
+	    outer->mainMem_alloc(id, size);
+	}
+
+	void mainMem_wait(void) {
+	    outer->mainMem_wait();
+	}
+
+	void* mainMem_get(int id) {
+	    return outer->mainMem_get(id);
+	}
+
+	void *allocate(int size) {
+	    return outer->allocate(size);
+	}
+
+	void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {
+	    outer->dma_load(buf, addr, size, mask);
+	}
+
+	void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {
+	    outer->dma_store(buf, addr, size, mask);
+	}
+
+	void dma_wait(uint32 mask) {
+	    outer->dma_wait(mask);
+	}
+    };
+
+    STaskManager *smanager;
+};
+
+const int SCHED_TASK_NORMAL = 0;
+const int SCHED_TASK_RENEW  = 1;
+
+#endif
+
+extern SchedTask* createSchedTask(TaskPtr);
--- a/include/TaskManager/Scheduler.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/Scheduler.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,37 +1,15 @@
 #ifndef INCLUDED_SCHEDULER
 #define INCLUDED_SCHEDULER
 
-#ifndef INCLUDED_BASE_H_
-#  include "base.h"
-#endif
-
-#ifndef INCLUDED_TASKLIST
-#  include "TaskList.h"
-#endif
-
-#ifndef INCLUDED_LIST_DATA
-#  include "ListData.h"
-#endif
-
-#ifndef INCLUDED_DMA_MANAGER
-#  include "DmaManager.h"
-#endif
+#include "base.h"
+#include "TaskList.h"
+#include "ListData.h"
+#include "DmaManager.h"
+#include "SchedTaskBase.h"
+#include "SchedTask.h"
+#include "SchedTaskList.h"
+#include "TaskGroup.h"
 
-#ifndef INCLUDED_SCHED_TASK_BASE
-#  include "SchedTaskBase.h"
-#endif
-
-#ifndef INCLUDED_SCHED_TASK
-#  include "SchedTask.h"
-#endif
-
-#ifndef INCLUDED_SCHED_TASKLIST
-#  include "SchedTaskList.h"
-#endif
-
-#ifndef INCLUDED_TASK_GROUP
-#  include "TaskGroup.h"
-#endif
 
 #define MAX_USER_TASK 32
 #define MAX_SYSTEM_TASK 2
--- a/include/TaskManager/TaskList.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/TaskList.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,13 +1,9 @@
 #ifndef INCLUDED_TASKLIST
 #define INCLUDED_TASKLIST
 
-#ifndef INCLUDED_BASE_H_
-#  include "base.h"
-#endif
+#include "base.h"
+#include "Task.h"
 
-#ifndef INCLUDED_TASK
-#  include "Task.h"
-#endif
 
 // sizeof(Task)*TASK_MAX_SIZE = 512 byte
 #define TASK_MAX_SIZE 16
--- a/include/TaskManager/base.h	Sun Jun 07 17:44:08 2009 +0900
+++ b/include/TaskManager/base.h	Sun Jun 07 19:45:41 2009 +0900
@@ -1,3 +1,5 @@
+#ifndef INCLUDED_BASE_H_
+
 #include <new>
 #include <stdlib.h>
 #include <stdio.h>
@@ -23,3 +25,4 @@
 # define BASE_NEW_DELETE(T)
 #endif
 
+#endif