changeset 567:47b61865ea8c

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2009 23:54:58 +0900
parents 006c4e9e6acb (diff) 5c76db2a07fa (current diff)
children 8fca17aa57df
files TaskManager/ChangeLog TaskManager/Fifo/FifoDmaManager.h TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/HTaskInfo.cc TaskManager/kernel/ppe/Task.cc TaskManager/kernel/ppe/Task.h TaskManager/kernel/ppe/TaskManager.cc TaskManager/kernel/ppe/TaskManager.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskManager.h TaskManager/kernel/sys_task/SysTask.h example/basic/main.cc example/many_task/sort.cc example/post_function/main.cc example/renew_task/main.cc example/renew_task/ppe/Renew1.cc
diffstat 71 files changed, 2286 insertions(+), 577 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Oct 20 20:34:47 2009 +0900
+++ b/.hgtags	Thu Oct 22 23:54:58 2009 +0900
@@ -1,3 +1,6 @@
 ce5755f544c1a882c7e28b7c78d8b31a82bd9eda cvs
 1f4c3f3238e6278fa3c73594e027036a1404ec34 fullHD_omedetou
 30568cef3899caea3db0fb9e28b0e6f889c60679 double-linked-task-list
+0000000000000000000000000000000000000000 ball_bound
+0000000000000000000000000000000000000000 513
+53f6939d7c970bbde5bbe9f32b64463f4ded8f01 ball_bound
--- a/Renderer/Engine/MainLoop.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/MainLoop.h	Thu Oct 22 23:54:58 2009 +0900
@@ -9,4 +9,4 @@
 };
 
 typedef MainLoop *MainLoopPtr;
-#endif MAINLOOP
+#endif /* MAINLOOP */
--- a/Renderer/Engine/Makefile	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/Makefile	Thu Oct 22 23:54:58 2009 +0900
@@ -4,11 +4,11 @@
 	@echo "Make for Mac OS X"
 	@$(MAKE) -f Makefile.macosx
 
-cell: 
+cell: FORCE
 	@echo "Make for PS3 (Cell)"
 	@$(MAKE) -f Makefile.cell
 
-linux: 
+linux: FORCE
 	@echo "Make for Linux"
 	@$(MAKE) -f Makefile.linux
 
@@ -22,8 +22,8 @@
 	@$(MAKE) -f Makefile.linux depend
 
 FORCE:
-	-mkdir -p ../include/Cerium
-	rsync `find . -name Test -prune -or -name '*.h' -print` ../../include/Cerium
+	-mkdir -p ../../include/Cerium
+	rsync `find . -name Test -prune -or -name spe -prune -or -name task -prune -or -name '*.h' -print` ../../include/Cerium
 
 
 clean:
--- a/Renderer/Engine/Makefile.cell	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/Makefile.cell	Thu Oct 22 23:54:58 2009 +0900
@@ -26,7 +26,7 @@
 all: $(TARGET) speobject
 
 $(TARGET): $(OBJS) $(TASK_OBJS)
-	$(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
+	$(AR) crus $@ $(OBJS) $(TASK_OBJS) 
 
 SGList.o: create_sg_list
 	$(CC) $(CFLAGS) $(INCLUDE) -c SGList.cc -o $@
--- a/Renderer/Engine/SceneGraphRoot.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -6,18 +6,23 @@
 #include "sys.h"
 #include "TextureHash.h"
 #include "texture.h"
-#include <stdlib.h>
+//#include "SGList.h"
+#include "Application.h"
 
-static int cnt = 0;
+int cnt = 0;
+static const int SGLIST_LENGTH = 138;
 
-#define SGLIST_INIT_LENGTH 128
+
+SceneGraphRoot *sgroot;
 
 SceneGraphRoot::SceneGraphRoot(float w, float h)
 {
-    sg_src = (SceneGraphPtr)malloc(sizeof(SceneGraphPtr)*SGLIST_INIT_LENGTH );
-    sg_src_length = SGLIST_INIT_LENGTH ;
+    // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな
+    //
+    sg_src = new SceneGraphPtr[SGLIST_LENGTH];
     camera = new Camera(w, h);
     iterator = new SceneGraphIterator;
+    sglist = new SceneGraphList;
     controller = create_controller();
 
     sg_exec_tree = NULL;
@@ -25,6 +30,8 @@
     sg_available_list = NULL;
     sg_remove_list = NULL;
 
+    sgroot = this;
+
     // TODO
     //   今はとりあえず camera を Root にしています
     //   今はそれすらもしてません
@@ -51,7 +58,7 @@
 		cnt--;
     }
 
-    free(sg_src);
+    delete [] sg_src;
     delete camera;
     delete iterator;
     delete controller;
@@ -62,26 +69,9 @@
  *
  * @param sg SceneGraph created by xmlfile
  */
-
-extern const char *sglist_table[];
-
 void
 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg)
 {
-    for (int i = 0; i < sg_src_length && sglist_table[i]; i++) {
-	if (strcmp(sg->name, sglist_table[i]) == 0) {
-	    sg->sgid = i;
-	    if (i>= sg_src_length) {	    
-		sg_src_length += sizeof(SceneGraphPtr)*SGLIST_INIT_LENGTH ;
-		sg_src = (SceneGraphPtr)realloc(sg_src, sg_src_length);
-	    }
-	    sg_src[i] = sg;
-	    return;
-	}
-    }
-
-    fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n",
-			__FUNCTION__, __LINE__, sg->name);
 }
 
 void
@@ -109,7 +99,7 @@
     xmlDocPtr doc;
     xmlNodePtr cur;
     SceneGraphPtr tmp;
-    
+
     /* パース DOM生成 */
     doc = xmlParseFile(xmlfile);
     cur = xmlDocGetRootElement(doc);
@@ -119,18 +109,20 @@
 
     /* XMLのノードを一つずつ解析  */
     for (cur=cur->children; cur; cur=cur->next) {
-		/* 扱うのはsurfaceオンリー  */
-		if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
-			continue;
-		}
+	/* 扱うのはsurfaceオンリー  */
+	if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
+	    continue;
+	}
 
-		/* ポリゴン(SceneGraph)生成  */
-		tmp = new SceneGraph(manager, cur);
+	/* ポリゴン(SceneGraph)生成  */
+	tmp = new SceneGraph(manager, cur);	
 
-		registSceneGraph(tmp);
+	addSceneGraphList(manager, tmp);
+	registSceneGraphList(tmp);
     }
 
     xmlFreeDoc(doc);
+
 }
 
 SceneGraphPtr
@@ -139,12 +131,12 @@
     SceneGraphPtr src;
     SceneGraphPtr p;
 
-    if (id < 0 || id > sg_src_length) {
+    if (id < 0 || id > SGLIST_LENGTH) {
 		return NULL;
     }
 
     /* オリジナルの SceneGraph */
-    src = sg_src+id;
+    src = sg_src[id];
 
     /* ユーザーにはオリジナルの clone を返す */
     p = src->clone();
@@ -154,6 +146,102 @@
     return p;
 }
 
+void
+SceneGraphRoot::registSceneGraphList(SceneGraphPtr sg)
+{
+    /*
+      SceneGraphRoot にメンバ変数 SceneGraphList を持たせておくか
+      SceneGraphList sglist
+      sg->name で検索して、有れば sg_src に追加。
+      sgid は sglist のメンバ変数 sgid で管理する感じ
+     */    
+
+    SgStruct *s = sglist->get(sg->name);
+    if (s != NULL) {
+	sg->sgid = sglist->sgid;
+	s->id = sglist->sgid;
+	sg_src[sg->sgid] = sg;
+	sglist->sgid++;
+	return;
+    }
+
+    fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n",
+			__FUNCTION__, __LINE__, sg->name);
+}
+
+void
+SceneGraphRoot::createFromXMLmemory(TaskManager *manager, char *data, int len)
+{
+    xmlDocPtr doc;
+    xmlNodePtr cur;
+    
+    // size は取れるはず、テスト用に mmap したデータを使う
+    /* パース DOM生成 */
+
+    doc = xmlParseMemory(data, len);
+    cur = xmlDocGetRootElement(doc);
+
+    /* ??  */
+    xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D");
+
+    /* XMLのノードを一つずつ解析  */
+    for (cur=cur->children; cur; cur=cur->next) {
+	/* 扱うのはsurfaceオンリー  */
+	if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
+	    continue;
+	}
+
+	/* ポリゴン(SceneGraph)生成  */
+	SceneGraphPtr tmp = new SceneGraph(manager, cur);	
+	
+	addSceneGraphList(manager, tmp);
+	
+	registSceneGraphList(tmp);
+    }
+    
+    xmlFreeDoc(doc);
+}
+
+/* 生成された SceneGraph のを sglist に登録 */
+void
+SceneGraphRoot::addSceneGraphList(TaskManager *manager, SceneGraphPtr tmp)
+{
+    SgStruct *sg_t = (SgStruct *)manager->allocate(sizeof(SgStruct));
+    sg_t->name = tmp->name;
+    sglist->addLast(sg_t);
+}
+
+SceneGraphPtr
+SceneGraphRoot::createSceneGraph(const char *name)
+{
+    SceneGraphPtr src;
+    SceneGraphPtr p;
+
+    // SceneGraphList から name を検索して id 取得
+    SgStruct *e = sglist->get(name);
+    int id = e->id;
+    if (id < 0) {
+	return NULL;
+    }
+    
+    /* オリジナルの SceneGraph */
+    src = sg_src[id];
+
+    /* ユーザーにはオリジナルの clone を返す */
+    p = src->clone();
+
+    addNext(p);
+
+    return p;
+}
+
+int
+SceneGraphRoot::getSgid(const char *name)
+{
+    SgStruct *e = sglist->get(name);
+    return e->id;
+}
+
 /**
  * 何も表示しない、move,collision もしない SceneGraph を生成
  * いずれ、Transform3D 的なものに回す予定
@@ -208,14 +296,69 @@
     /*removeのflagをもとにtreeを形成*/
     /* spe から送り返されてきた property の配列を見て生成する for()*/
     /*
-	  for (Property *t = property[0]; is_end(t); t++){
-	  SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る
-	  t->scenegraph = s; // property list には SceneGraphへのポインタが入っている
-	  application->scenegraph_connector(property[0], s); // add する
-	  }
+    for (Property *t = (Property*)app->property[0]; is_end(t); t++){
+	SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る
+	t->scenegraph = s; // property list には SceneGraphへのポインタが入っている
+	app->scenegraph_connector(property[0], s); // add する
+    } 
+    */   
+    
+
+    // 現在、allExecute が終わった時点では
+    // camera->children が User SceneGraph の root になる
+
+    /**
+     * NULL じゃなかったら、setSceneData が呼ばれてるから
+     * そっちを次の Scene にする
+     */
+
+    sg_exec_tree = camera->children;
+}
+
+void
+SceneGraphRoot::speExecute(int screen_w, int screen_h, Application *app)
+{
+    // SceneGraphPtr t = sg_exec_tree;
+    // SceneGraphPtr cur_parent = camera;
+
+    // 前フレームで描画した SceneGraph は削除
+    allRemove(sg_remove_list);
+
+    // 前フレームに作られた SceneGraph は描画用に移行
+    // 現フレームでの操作は以下の tree,list には適用されない
+    sg_draw_tree = sg_exec_tree;
+    sg_remove_list = sg_available_list;
+
+    // 現フレームで新しく SceneGraph がコピーされるので初期化
+    sg_exec_tree = NULL;
+    sg_available_list = NULL;
+
+    camera->move_execute(screen_w, screen_h);
+    camera->update(screen_w, screen_h);
+
+    camera->children = NULL;
+    camera->lastChild = NULL;
+    
+
+    if(sg_exec_tree != NULL) {
+	return;
+    }
+
+    /*removeのflagをもとにtreeを形成*/
+    /* spe から送り返されてきた property の配列を見て生成する for()*/
+    /* Application内に移動 */
+
+    // app->property_ope(sg_available_list);
+
+    /* 
+    for (Property *t = (Property *)properties[0]; is_end(t); t++){
+	SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る
+	t->scenegraph = s; // property list には SceneGraphへのポインタが入っている
+	app->scenegraph_connector(property[0], s); // add する
+    }  
     */
-
-      
+    
+    
 
     // 現在、allExecute が終わった時点では
     // camera->children が User SceneGraph の root になる
--- a/Renderer/Engine/SceneGraphRoot.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Thu Oct 22 23:54:58 2009 +0900
@@ -5,16 +5,33 @@
 #include "SceneGraphArray.h"
 #include "Camera.h"
 #include "SceneGraphIterator.h"
+// #include "Application.h"
+#include "SceneGraphList.h"
+#include "SgStruct.h"
+// #include "TaskManager.h"
+#include <sys/types.h>
+
+typedef struct {
+    caddr_t file_mmap;
+    off_t size;
+} st_mmap_t;
+
+class Application;
 
 class SceneGraphRoot {
 public:
     /* Constructor, Destructor */
     SceneGraphRoot(float w, float h);
-    ~SceneGraphRoot(void);
+    ~SceneGraphRoot();
 
     /* Variables */
+    TaskManager *tmanager;
+    
+    // sgid と name を持った SgStruct のリスト
+    SceneGraphList *sglist;
+
     // xml から読み込んだ、オリジナルの SceneGraph
-    SceneGraphPtr sg_src;
+    SceneGraphPtr *sg_src;
     int sg_src_length;
 
     // move, collision 用の SceneGraph (tree)
@@ -48,33 +65,49 @@
      */
     /* User API */
     void createFromXMLfile(TaskManager *manager, const char *);
+    //void createFromXMLmemory(TaskManager *manager, const char *xml);
+    //void createFromXMLmemory(TaskManager *manager, st_mmap_t mmap_t);
+    void createFromXMLmemory(TaskManager *manager, char *data, int len);
     SceneGraphPtr createSceneGraph(int id);
-    SceneGraphPtr createSceneGraph(void);
+    SceneGraphPtr createSceneGraph();
+    SceneGraphPtr createSceneGraph(const char *name);
+    int getSgid(const char *name);
+
     void setSceneData(SceneGraphPtr sg);
-    Pad *getController(void);
-    SceneGraphIteratorPtr getIterator(void);
+    Pad *getController();
+    SceneGraphIteratorPtr getIterator();
     SceneGraphIteratorPtr getIterator(SceneGraphPtr list);
-    CameraPtr getCamera(void);
+    CameraPtr getCamera();
 
     /* Other System API */
     void allExecute(int screen_w, int screen_h);
-    void checkRemove(void);
-    SceneGraphPtr getExecuteSceneGraph(void);
-    SceneGraphPtr getDrawSceneGraph(void);
-    void updateControllerState(void);
+    void checkRemove();
+    SceneGraphPtr getExecuteSceneGraph();
+    SceneGraphPtr getDrawSceneGraph();
+    void updateControllerState();
 
     void speExecute(int screen_w, int screen_h);
+    void speExecute(int screen_w, int screen_h, Application *app);
 
     /* System API */
     void registSceneGraph(SceneGraphPtr sg);
+    void registSceneGraphList(SceneGraphPtr sg);
+    void addSceneGraphList(TaskManager *manager, SceneGraphPtr tmp);
     void addNext(SceneGraphPtr sg);
     void allRemove(SceneGraphPtr list);
+
+    int getLast() {
+	return sglist->getLast()->id;
+    }
+
 };
 
 typedef SceneGraphRoot *SceneGraphRootPtr;
 
-#endif
 
 // 大域変数は無くすこと
-extern SceneGraphRootPtr sgroot;
-extern SceneGraphRootPtr sgroot_2;
+extern SceneGraphRoot *sgroot;
+
+#endif
+
+/* end */
--- a/Renderer/Engine/lindaapi.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/lindaapi.h	Thu Oct 22 23:54:58 2009 +0900
@@ -1,8 +1,15 @@
-//  $Id: lindaapi.h,v 1.8 2005/12/21 07:29:38 yasumura Exp $
-//
+#ifndef _LINDAAPI_H
+
+#define _LINDAAPI_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*  $Id$ */
 
 /*----------------------------------------------------------------------
- ޥ
+  マクロ定義
 ----------------------------------------------------------------------*/
 
 #define FAIL            (-1)
@@ -13,8 +20,10 @@
 
 #define INT_SIZE    4     // Byte = sizeof(int)
 
+#define LDSERV_PORT     11511
+
 /*----------------------------------------------------------------------
- ѥåȥեޥå
+ パケットフォーマット
  char     short  int    int
  Mode +   ID   + Seq  + Data_len + Padding + Data
  0        1      3      7          11        12
@@ -24,63 +33,65 @@
 #define LINDA_ID_OFFSET            1
 #define LINDA_SEQ_OFFSET           3
 #define LINDA_DATA_LENGTH_OFFSET   7
-#define LINDA_TID_OFFSET           11
 #define LINDA_HEADER_SIZE          12
 
 /*----------------------------------------------------------------------
- ¤
+  構造体定義
 ----------------------------------------------------------------------*/
 typedef struct psx_reply{
     unsigned char *answer;
     unsigned int seq;
     struct psx_reply *next;
     char mode;
-    void(*callback)(char * tuple, void * obj);
+    void(*callback)(unsigned char * tuple, void * obj);
     void * obj;
-} REPLY, *REPLY_PTR;
-
+} REPLY;
+          
 typedef struct command_queue{
+    struct command_queue *next;
+    unsigned int tspace_id;        /* ID of destination Tuple Space */
+    unsigned int size;
     unsigned char *command;
-    struct command_queue *next;
-    unsigned int size;
-} COMMAND, *COMMAND_PTR;
+} COMMAND;
+
 
 /*----------------------------------------------------------------------
- Ūؿƥץ졼
+  Linda API
 ----------------------------------------------------------------------*/
 
-int start_linda(char *hostname);
-void unix_chkserv();
-extern void psx_free(char *tuple);
+extern void init_linda(void);
+extern int open_linda(char *hostname, int port);
+extern int open_linda_java(char *hostname, int port);
+extern int close_linda(int tspace_id);
 
-int psx_out(unsigned int id, unsigned char *data, unsigned int size);
-int psx_ld(unsigned int id, char mode, void(*callback)(char *,void *),void * obj);
+extern void psx_free(void*);
 
-#define psx_in(id)      psx_ld(id, 'i', NULL, NULL)
-#define psx_rd(id)      psx_ld(id, 'r', NULL, NULL)
-#define psx_ck(id)      psx_ld(id, 'c', NULL, NULL)
-#define psx_wait_rd(id) psx_ld(id, 'w', NULL, NULL)
-
-#define psx_callback_in(id,callback,obj)       psx_ld(id, 'i', callback, obj)
-#define psx_callback_rd(id,callback,obj)       psx_ld(id, 'r', callback, obj)
-#define psx_callback_ck(id,callback,obj)       psx_ld(id, 'c', callback, obj)
-#define psx_callback_wait_rd(id,callback,obj)  psx_ld(id, 'w', callback, obj)
+extern unsigned char *psx_reply(unsigned int seq);
+extern void psx_sync_n(void);
+extern unsigned int psx_get_datalength(unsigned char *);
+extern unsigned int psx_get_seq(unsigned char *);
+extern unsigned short psx_get_id(unsigned char *);
+extern unsigned char psx_get_mode(unsigned char *);
+extern unsigned char * psx_get_data(unsigned char *);
 
-unsigned char *psx_reply(int seq);
-void psx_sync_n();
-//void psx_free(unsigned char *);
-int psx_queue(unsigned int id, unsigned int size, unsigned char *data, char mode,
-              void(*callback)(char *,void *),void * obj);
-int psx_get_datalength(unsigned char *);
-unsigned char *psx_get_data(unsigned char *);
-int psx_get_seq(unsigned char *);
-short psx_get_id(unsigned char *);
-char psx_get_mode(unsigned char *);
+extern int psx_out(unsigned int tspace_id, unsigned int id,
+                   unsigned char *data, unsigned int size);
+extern int psx_ld(unsigned int tspace_id, unsigned int id,
+                  char mode, void(*callback)(unsigned char *,void *),void * obj);
+
+#define psx_in(tid, id)      psx_ld(tid, id, 'i', NULL, NULL)
+#define psx_rd(tid, id)      psx_ld(tid, id, 'r', NULL, NULL)
+#define psx_ck(tid, id)      psx_ld(tid, id, 'c', NULL, NULL)
+#define psx_wait_rd(tid, id) psx_ld(tid, id, 'w', NULL, NULL)
 
-int unix_open();                        /* UNIX ̿ߤ */
-int unix_read(int,char *,unsigned int); /* UNIX ɤ߹ */
-int unix_read_w(int,char *,int);        /* UNIX ɤ߹(non wait) */
-int unix_write(int,unsigned char *,unsigned int);/* UNIX ؽ񤭹 */
-int unix_write_w(int,unsigned char *,unsigned int);/* UNIX ؽ񤭹(non wait) */
-int send_able();                        /* ɤ߽񤭤Ǥѥåȿ */
+#define psx_callback_in(tid, id,callback,obj)      psx_ld(tid, id, 'i', callback, obj)
+#define psx_callback_rd(tid, id,callback,obj)      psx_ld(tid, id, 'r', callback, obj)
+#define psx_callback_ck(tid, id,callback,obj)      psx_ld(tid, id, 'c', callback, obj)
+#define psx_callback_wait_rd(tid, id,callback,obj) psx_ld(tid, id, 'w', callback, obj)
+
 
+
+#ifdef __cplusplus
+};  // for extern "C"
+#endif
+#endif // _LINDAAPI_H
--- a/Renderer/Engine/main.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/main.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -5,16 +5,17 @@
 #include "Application.h"
 
 /* prototype */
-static int init(TaskManager *manager, int argc, char *argv[]);
+extern int init(TaskManager *manager, int argc, char *argv[]);
 static void TMend(TaskManager *manager);
 
 extern void task_initialize();
 extern Application *application();
+extern int init(TaskManager *manager, int argc, char *argv[]);
 
-// 帯域変数は禁止
+// 大域変数は禁止
 //static Viewer *screen;
 
-
+/*
 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n\
   -cpu Number of SPE (default 1)\n\
   -width, -height window size (default 640x480)\n\
@@ -26,6 +27,7 @@
       4: テクスチャテスト:2048x1536\n\
       5: 地球が動き、その周りを月が自転、公転する\n\
       6 以降: キューブが跳ね返りながら、勝手にキューブが増えて行く\n";
+ */
 
 int
 init(TaskManager *manager, int argc, char *argv[])
@@ -72,18 +74,18 @@
     screen->video_init(manager);
     screen->run_init(manager, application());
 
-    manager->set_TMend(TMend);
 
     return 0;
 }
 
+#if 0
 int
 TMmain(TaskManager *manager, int argc, char *argv[])
 {
     task_initialize();
+    manager->set_TMend(TMend);
     return init(manager, argc, argv);
 
-    //return 0;
 }
 
 void
@@ -91,3 +93,5 @@
 {
     printf("test_nogl end\n");
 }
+
+#endif
--- a/Renderer/Engine/viewer.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/viewer.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -12,22 +12,21 @@
 #include "Pad.h"
 #include "Application.h"
 
-static void post2runLoop(void *viewer);
-static void post2runDraw(void *viewer);
-static void post2speRendering(void *viewer);
-static void post2speDraw(void *viewer);
-// static void post2speRunLoop(void *viewer);
-//static void post2runMove(void *viewer);
-//static void post2exchange_sgroot(void *viewer);
-//static void post2speRunLoop(void *viewer);
-static void post2runMoveDrawLoop(void *viewer);
+static void post2runLoop(SchedTask *s,void *viewer,void *s1);
+static void post2runDraw(SchedTask *s,void *viewer,void *s1);
+static void post2speRendering(SchedTask *s,void *viewer,void *s1);
+static void post2speDraw(SchedTask *s,void *viewer,void *s1);
+static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1);
 
 /* measure for FPS (Frame Per Second) */
 int start_time;
 int this_time;
 int frames;
+// static void post2speRunLoop(void *viewer);
+//static void post2runMove(void *viewer);
+//static void post2exchange_sgroot(void *viewer);
+//static void post2speRunLoop(void *viewer);
 
-SceneGraphRootPtr sgroot;
 //SceneGraphRootPtr sgroot_2;
 
 /* Data Pack sent to Other CPUs (ex. SPE) */
@@ -91,23 +90,6 @@
     SDL_GL_SwapBuffers();
 }
 
-void 
-Viewer::createFromXMLfile(const char *file) 
-{
-    sgroot->createFromXMLfile(manager, file);
-}
-
-SceneGraph *
-Viewer::createSceneGraph(int id)
-{
-    return sgroot->createSceneGraph(id);
-}
-
-void
-Viewer::setSceneData(SceneGraph *g)
-{
-    sgroot->setSceneData(g);
-}
 
 void
 Viewer::run_init(TaskManager *manager, Application *app)
@@ -119,6 +101,7 @@
     frames     = 0;
 
     sgroot = new SceneGraphRoot(this->width, this->height);
+    sgroot->tmanger = this;
 
     MainLoop *mainloop = app->init(this, this->width, this->height);
 
@@ -200,7 +183,7 @@
    
     HTaskPtr task_switch = manager->create_task(TASK_SWITCH);
     task_switch->wait_for(task_next);
-    task_switch->set_post(post2runMoveDrawLoop, (void*)this);
+    task_switch->set_post(post2runMoveDrawLoop, (void*)this, 0);
     task_switch->spawn();
 }
 
@@ -250,7 +233,7 @@
 }
 
 static void
-post2runMoveDrawLoop(void *viewer_)
+post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg)
 {
     Viewer *viewer = (Viewer*)viewer_;
     
@@ -278,14 +261,14 @@
     HTaskPtr switch_task = viewer->manager->create_task(TASK_SWITCH);
     viewer->draw_dummy = draw_dummy;
     switch_task->wait_for(draw_dummy);
-    draw_task->set_post(post2speRendering, (void*)viewer);
+    draw_task->set_post(post2speRendering, (void*)viewer, 0);
 
     switch_task->wait_for(move_task);
     switch_task->wait_for(draw_task);
     move_task->spawn();
     draw_task->spawn();
 
-    switch_task->set_post(post2runMoveDrawLoop, (void*)viewer);
+    switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0);
     switch_task->spawn();
     
 }
@@ -305,7 +288,7 @@
 {
     HTaskPtr task_next = initLoop();
 
-    task_next->set_post(&post2runLoop, (void *)this); // set_post(function(this->run_loop()), NULL)
+    task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL)
     task_next->spawn();
 }
 
@@ -333,7 +316,7 @@
 }
 
 void
-post2rendering(void *viewer_)
+post2rendering(SchedTask *s, void *viewer_, void *arg)
 {
     Viewer *viewer = (Viewer *)viewer_;
     HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY);
@@ -347,14 +330,14 @@
     
     // Barrier 同期
     // run_draw() を呼ぶ post2runDraw
-    task_next->set_post(post2runDraw, (void*)this); // set_post(function(this->run_draw()), NULL)
+    task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL)
     task_next->spawn();
 
     // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ
 }
 
 static void
-post2runLoop(void *viewer_)
+post2runLoop(SchedTask *s, void *viewer_, void *arg)
 {
     Viewer *viewer = (Viewer*)viewer_;
     HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY);
@@ -389,7 +372,7 @@
 }
 
 static void 
-post2runDraw(void *viewer_)
+post2runDraw(SchedTask *s, void *viewer_, void *arg)
 {
     Viewer *viewer = (Viewer*)viewer_;
     HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY);
@@ -402,7 +385,7 @@
 {
     common_draw(task_next);
 
-    task_next->set_post(post2runLoop, (void*)this); // set_post(function(this->run_loop()), NULL)
+    task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL)
     task_next->spawn();
     // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ    
 
@@ -422,7 +405,7 @@
 }
 
 static void
-post2speRendering(void *viewer_)
+post2speRendering(SchedTask *s, void *viewer_, void *arg)
 {
     Viewer *viewer = (Viewer*)viewer_;
     HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY);
@@ -435,13 +418,13 @@
     common_rendering(task_next);
 
     this->draw_dummy->wait_for(task_next);
-    task_next->set_post(post2speDraw, (void*)this);
+    task_next->set_post(post2speDraw, (void*)this, 0);
     task_next->spawn();
 
 }
 
 static void 
-post2speDraw(void *viewer_)
+post2speDraw(SchedTask *s, void *viewer_, void *arg)
 {
     Viewer *viewer = (Viewer*)viewer_;
     HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY);
--- a/Renderer/Engine/viewer.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Engine/viewer.h	Thu Oct 22 23:54:58 2009 +0900
@@ -8,6 +8,9 @@
 #include "KeyStat.h"
 #include "MainLoop.h"
 #include "Application.h"
+#include "SceneGraphRoot.h"
+
+class SceneGraphRoot;
 
 class Application;
 
@@ -36,6 +39,8 @@
     Uint32 video_flags;
     Uint32 *pixels;
 
+    SceneGraphRoot *sgroot;
+
     virtual void video_init(TaskManager *manager) = 0;
     void init();
 
@@ -63,11 +68,44 @@
     void getKey();
     void get_send_controll();
 
-    void createFromXMLfile(const char *file);
-    SceneGraph *createSceneGraph(int id);
-    void setSceneData(SceneGraph *g);
+    // void createFromXMLfile(const char *file);
+    // SceneGraph *createSceneGraph(int id);
+    // SceneGraph *createSceneGraph();
+    // void setSceneData(SceneGraph *g);
     void mainLoop();
 
+    void createFromXMLfile(const char *file)
+    {
+	sgroot->createFromXMLfile(manager, file);
+    }
+
+    SceneGraph * createSceneGraph(int id)
+    {
+	return sgroot->createSceneGraph(id);
+    }
+
+    SceneGraph * createSceneGraph(const char *id)
+    {
+	return sgroot->createSceneGraph(id);
+    }
+
+    int getSgid(const char *id)
+    {
+	return sgroot->getSgid(id);
+    }
+
+    SceneGraph * createSceneGraph()
+    {
+	return sgroot->createSceneGraph();
+    }
+
+    void setSceneData(SceneGraph *g)
+    {
+	sgroot->setSceneData(g);
+    }
+
+
+
 private:
     HTaskPtr initLoop();
     void speLoop();
--- a/Renderer/Test/Chain.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/Chain.h	Thu Oct 22 23:54:58 2009 +0900
@@ -22,4 +22,7 @@
     void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h);
     void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg);
 
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+
 };
--- a/Renderer/Test/Makefile	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/Makefile	Thu Oct 22 23:54:58 2009 +0900
@@ -1,42 +1,10 @@
-include ./Makefile.def
-
-LIBS += -lFifoManager -lCerium
-
-CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
-LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
-
-.SUFFIXES: .cc .o .xml
-
-.cc.o:
-	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
-
-all: ball_bound
-
-BALL_BOUND_OBJ = ball_bound.o
-BALL_BOUND_XML = xml_file/Ball.xml
 
-ball_bound : $(BALL_BOUND_OBJ) $(BALL_BOUND_XML).o 
-	$(CC) -o $@ $< $(BALL_BOUND_XML).o  $(LIBS)
-
-ball_bound.cc : $(BALL_BOUND_XML).h 
-
-$(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h : $(BALL_BOUND_XML)
-	perl $(TOOL)/create_sglist.pl -o $@ $(BALL_BOUND_XML)
-
+all: 
+	make -f Makefile.macosx
 
-run: $(TARGET)
-	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
-
-debug: $(TARGET)
-	sudo ppu-gdb ./$(TARGET) 
-
-depend:
-	$(RM) depend.inc
-	$(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc
+cell:
+	make -f Makefile.cell
 
 clean:
-	rm -f $(TARGET) $(OBJS) $(TASK_OBJS) *.o
-	rm -f *~ \#*
-	rm -f $(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h $(BALL_BOUND_OBJ)
-
--include depend.inc
+	make -f Makefile.macosx clean
+	make -f Makefile.cell clean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/Makefile.cell	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,84 @@
+include ./Makefile.def
+
+LIBS +=  -lCerium -lCellManager  -lspe2 -lpthread
+
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
+LIBS   += `sdl-config --libs` -lSDL_image -lGL `xml2-config --libs` 
+
+
+.SUFFIXES: .cc .o .xml
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum
+
+speobject:
+	cd spe; $(MAKE)
+
+run: $(TARGET)
+	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
+run-hd: $(TARGET)
+	sudo /usr/sbin/ps3-video-mode -v 133
+	sudo ./$(TARGET) -video fb -width 1920 -height 1080 -bpp 32
+
+
+spe-main:
+	ln -s ../Engine/spe-main .
+
+
+BALL_BOUND_OBJ = ball_bound.o
+ball_bound : $(BALL_BOUND_OBJ) 
+	$(CC) -o $@ $?   $(LIBS)
+
+BOSS_OBJ = boss1_action.o
+boss1_action : $(BOSS_OBJ) 
+	$(CC) -o $@ $?   $(LIBS)
+
+DIRECTION_OBJ = direction.o
+direction : $(DIRECTION_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+GAPLAN_OBJ = gaplant.o gaplant_action.o back_action.o ball_action.o
+gaplant : $(GAPLAN_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+IESHOOT_OBJ = ieshoot.o
+ieshoot : $(IESHOOT_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+NODE_OBJ = node.o
+node : $(NODE_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+PANEL_OBJ = panel.o
+panel : $(PANEL_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+UNIV_OBJ = universe.o
+universe : $(UNIV_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+UNTITLED_OBJ = untitled.o
+untitled : $(UNTITLED_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+VACUUM_OBJ = vacuum.o cube.o game_over.o title.o
+vacuum : $(VACUUM_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+debug: $(TARGET)
+	sudo ppu-gdb ./$(TARGET) 
+
+depend:
+	$(RM) depend.inc
+	$(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc
+
+clean:
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS) *.o
+	rm -f *~ \#*
+	rm -f $(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h $(BALL_BOUND_OBJ)
+
+-include depend.inc
+
+
--- a/Renderer/Test/Makefile.macosx	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/Makefile.macosx	Thu Oct 22 23:54:58 2009 +0900
@@ -1,40 +1,65 @@
 include ./Makefile.def
 
-SRCS_TMP = $(wildcard *.cc) $(wildcard Application/*.cc)
-SRCS_EXCLUDE =  # 
-SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
-OBJS = $(SRCS:.cc=.o)
-
-TASK_DIR  = task
-TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
-TASK_SRCS_EXCLUDE = span_pack_draw.cc
-TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
-TASK_OBJS = $(TASK_SRCS:.cc=.o)
-
-LIBS += -lFifoManager
+LIBS += -lFifoManager -lCerium
 
 CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
 LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
 
-.SUFFIXES: .cc .o
+.SUFFIXES: .cc .o  .xml .xml.h .xml.cc
 
 .cc.o:
 	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
 
-all: $(TARGET)
+all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum send_linda dynamic
+
+
+BALL_BOUND_OBJ = ball_bound.o
+ball_bound : $(BALL_BOUND_OBJ) 
+	$(CC) -o $@ $?   $(LIBS)
+
+BOSS_OBJ = boss1_action.o
+boss1_action : $(BOSS_OBJ) 
+	$(CC) -o $@ $?   $(LIBS)
 
-$(TARGET) : $(OBJS) $(TASK_OBJS)
-	$(AR) crus $@ $(OBJS) $(TASK_OBJS) 
+DIRECTION_OBJ = direction.o
+direction : $(DIRECTION_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+GAPLAN_OBJ = gaplant.o gaplant_action.o back_action.o ball_action.o
+gaplant : $(GAPLAN_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+IESHOOT_OBJ = ieshoot.o
+ieshoot : $(IESHOOT_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
 
-# SGList.o: create_sg_list
-# 	$(CC) $(CFLAGS) $(INCLUDE) -c SGList.cc -o $@
+NODE_OBJ = node.o
+node : $(NODE_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+PANEL_OBJ = panel.o
+panel : $(PANEL_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+UNIV_OBJ = universe.o
+universe : $(UNIV_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
 
-create_sg_list:
-	@if [ ! -f SGList.h ]; then \
-		cd tools/;\
-		./create_sglist.pl ../xml_file/*.xml;\
-	fi
+UNTITLED_OBJ = untitled.o
+untitled : $(UNTITLED_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+VACUUM_OBJ = vacuum.o cube.o game_over.o title.o
+vacuum : $(VACUUM_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
 
+DYNAMIC_OBJ = dynamic_create.o 
+dynamic : $(DYNAMIC_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+SENDLINDA_OBJ = send_linda.o
+send_linda : $(SENDLINDA_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
 
 run: $(TARGET)
 	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
@@ -47,8 +72,8 @@
 	$(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc
 
 clean:
-	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS) *.o
 	rm -f *~ \#*
-	rm -f SGList.h SGList.cc
+	rm -f $(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h $(BALL_BOUND_OBJ)
 
 -include depend.inc
--- a/Renderer/Test/back_action.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/back_action.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,7 +1,7 @@
 #include <iostream>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
 #include "ball_action.h"
+#include "xml_file/gap_plane_test.xml.h"
 using namespace std;
 
 void
@@ -10,7 +10,7 @@
     Pad *pad = sgroot->getController();
 
     if (pad->triangle.isPush()) {
-	SceneGraphPtr ball = sgroot->createSceneGraph(Ball);
+	SceneGraphPtr ball = sgroot->createSceneGraph("Ball");
 	ball->xyz[0] = -100;
 	ball->set_move_collision(ball_move, ball_coll);
 	node->addChild(ball);
--- a/Renderer/Test/ball_action.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/ball_action.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,6 +1,6 @@
 #include <iostream>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+
 using namespace std;
 
 void
--- a/Renderer/Test/ball_bound.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/ball_bound.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -2,9 +2,9 @@
 #include <stdlib.h>
 #include "SceneGraphRoot.h"
 #include "MainLoop.h"
-#include "xml_file/Ball.xml.h"
 #include "ball_bound.h"
 
+
 // prototype
 static void ball_move(SceneGraphPtr node, int screen_w, int screen_h);
 static void ball_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree);
@@ -104,13 +104,8 @@
     }
 }
 
-extern Application *
-application() {
-    return new ball_bound();
-}
-
 MainLoopPtr 
-ball_bound::init(Viewer *viewer, int screen_w, int screen_h)
+ball_bound::init(Viewer *sgroot, int screen_w, int screen_h)
 {
     SceneGraphPtr ball;
 
@@ -118,9 +113,9 @@
     // random な値が欲しいなら、man random に方法が書いてあります。
     srandom(100);
 
-    viewer->createFromXMLfile("xml_file/Ball.xml");
+    sgroot->createFromXMLfile("xml_file/Ball.xml");
 
-    ball = viewer->createSceneGraph(Ball);
+    ball = sgroot->createSceneGraph("Ball");
     ball->set_move_collision(ball_move, ball_collision);
 
     h0 = screen_h/2;
@@ -131,9 +126,35 @@
     ball->xyz[1] = h0;
     ball->xyz[2] = 30.0f;
 
-    viewer->setSceneData(ball);
+    sgroot->setSceneData(ball);
+
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new ball_bound();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
 
-    return viewer;
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
 }
 
 /* end */
--- a/Renderer/Test/boss1_action.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/boss1_action.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,4 +1,5 @@
-#include "SGList.h"
+#include "SceneGraphRoot.h"
+#include "MainLoop.h"
 #include "boss1_action.h"
 
 /*
@@ -114,7 +115,7 @@
   }
   
   if (pad->circle.isPush()) {
-    SceneGraphPtr shot = sgroot->createSceneGraph(P_SHOT1);
+    SceneGraphPtr shot = sgroot->createSceneGraph("P_SHOT1");
     shot->set_move_collision(shot_move, shot_collision);
     shot->xyz[0] = node->xyz[0];
     shot->xyz[1] = node->xyz[1] - player_radius;
@@ -122,6 +123,8 @@
   }    
 }
 
+static int boss1sgid;
+
 static void
 player_collision(SceneGraphPtr node, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
@@ -134,8 +137,8 @@
   SceneGraphIteratorPtr it = sgroot->getIterator(tree);
   
   
-  for (; it->hasNext(BOSS1);) {
-    it->next(BOSS1);
+  for (; it->hasNext(boss1sgid);) {
+    it->next(boss1sgid);
     SceneGraphPtr enemy = it->get();
     
     //各変数の初期化
@@ -179,8 +182,8 @@
   SceneGraphIteratorPtr it = sgroot->getIterator(tree);
   
   
-  for (; it->hasNext(BOSS1);) {
-    it->next(BOSS1);
+  for (; it->hasNext(boss1sgid);) {
+    it->next(boss1sgid);
     SceneGraphPtr enemy = it->get();
     
     x_distant = node->xyz[0] - enemy->xyz[0];
@@ -191,7 +194,7 @@
     
     //円同士のcollision
     if(distance <  boss_radius_y) {
-      SceneGraphPtr blast = sgroot->createSceneGraph(BLAST1);
+      SceneGraphPtr blast = sgroot->createSceneGraph("BLAST1");
       
       blast->set_move_collision(blast_move, null_collision);
       blast->xyz[0] = node->xyz[0];
@@ -202,10 +205,19 @@
   }
 }
 
+extern Application *
+application() {
+    return new boss1_action();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+static int blast8;
+
 static void
 blast_move(SceneGraphPtr node, int screen_w, int screen_h)
 {
-  if(node->sgid > BLAST8) {
+  if(node->sgid > blast8) {
     SceneGraphPtr blast = sgroot->createSceneGraph(node->sgid - 1);
     blast->set_move_collision(blast_move, null_collision);
     blast->xyz[0] = node->xyz[0];
@@ -213,7 +225,7 @@
     node->addBrother(blast);
   }
   
-  if (node->sgid == BLAST8) {
+  if (node->sgid == blast8) {
     node->flag_drawable = 1;
   }
   
@@ -223,31 +235,30 @@
   node->frame += 1;
 }
   
-void
-boss1_init(TaskManager *manager, int screen_w, int screen_h)
+MainLoopPtr
+boss1_action::init(Viewer *sgroot, int screen_w, int screen_h)
 {
-  SceneGraphPtr root;
-  SceneGraphPtr player;
-  SceneGraphPtr boss1;
-  SceneGraphPtr left_parts;
-  SceneGraphPtr right_parts;
 
-  sgroot->createFromXMLfile(manager, "xml_file/boss1.xml");
-  sgroot->createFromXMLfile(manager, "xml_file/player1.xml");
-  sgroot->createFromXMLfile(manager, "xml_file/p_shot.xml");
-  sgroot->createFromXMLfile(manager, "xml_file/blast.xml");
-  
+  sgroot->createFromXMLfile("xml_file/boss1.xml");
+  sgroot->createFromXMLfile("xml_file/player1.xml");
+  sgroot->createFromXMLfile("xml_file/p_shot.xml");
+  sgroot->createFromXMLfile("xml_file/blast.xml");
+ 
+  blast8 = sgroot->getSgid("BLAST8");
+ 
   //rootとなるSceneGraphを生成
-  root = sgroot->createSceneGraph();
+  SceneGraphPtr root = sgroot->createSceneGraph();
   
   //自機の初期化
-  player = sgroot->createSceneGraph(PLAYER);
+  SceneGraphPtr player = sgroot->createSceneGraph("PLAYER");
   player->xyz[0] = screen_w/2;
   player->xyz[1] = screen_h - player_radius;
   root->addChild(player);
 
   //ボスの初期化
-  boss1 = sgroot->createSceneGraph(BOSS1);
+  SceneGraphPtr boss1 = sgroot->createSceneGraph("BOSS1");
+  boss1sgid = boss1->sgid;
+
   boss1->xyz[0] = screen_w/2;
   boss1->xyz[1] = boss_radius_y;
   //  boss1->xyz[2] = first_boss1_depth;
@@ -255,9 +266,9 @@
   root->addChild(boss1);
 
   //ボスの左右パーツを追加
-  left_parts = sgroot->createSceneGraph(BOSS1_L);
+  SceneGraphPtr left_parts = sgroot->createSceneGraph("BOSS1_L");
   boss1->addChild(left_parts);
-  right_parts = sgroot->createSceneGraph(BOSS1_R);
+  SceneGraphPtr right_parts = sgroot->createSceneGraph("BOSS1_R");
   boss1->addChild(right_parts);
 
   //各機体の動きと当たり判定をセット
@@ -266,4 +277,26 @@
   
   //仕上げ
   sgroot->setSceneData(root);
+    return sgroot;
 }
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+
--- a/Renderer/Test/boss1_action.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/boss1_action.h	Thu Oct 22 23:54:58 2009 +0900
@@ -3,7 +3,15 @@
 
 #include <math.h>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+
+class boss1_action : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
 
 static const float player_speed = 10.0f;
 static const float player_radius = 42.0f;
--- a/Renderer/Test/chain.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/chain.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -106,7 +106,7 @@
 }
 
 void
-Chain::init(TaskManager *manager, int w, int h)
+Chain::init(Viewer *sgroot, int w, int h)
 {
     SceneGraphPtr root_chain, chain;
     ChainPropertyPtr rcv;
@@ -159,5 +159,33 @@
     chain_init->spawn();
 
     sgroot->setSceneData(root_chain);
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new Chain();
 }
 
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+
--- a/Renderer/Test/chain_old.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/chain_old.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -126,8 +126,8 @@
 
 }
 
-void
-chain_old_init(TaskManager *manager, int w, int h)
+MainLoopPtr
+chain_old::init(Viewer *sgroot, int w, int h)
 {
     SceneGraphPtr root_old_chain, chain;
     CHAIN_VARS rcv;
@@ -156,4 +156,34 @@
     cv[0].can_move = FALSE;
 
     sgroot->setSceneData(root_old_chain);
+    return sgroot;
 }
+
+extern Application *
+application() {
+    return new ball_bound();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- a/Renderer/Test/cube.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/cube.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,7 +1,6 @@
 #include <math.h>
 #include "SceneGraphRoot.h"
 #include "vacuum.h"
-#include "SGList.h"
 #define SELECT 2
 
 void
@@ -52,6 +51,8 @@
 
 }
 
+extern int redcube ;
+extern int enemy ;
 
 void
 cube_split(SceneGraphPtr root,SceneGraphPtr tree)
@@ -62,10 +63,10 @@
   //  SceneGraphPtr root_common_move = root->parent;
 
   if(random()%SELECT) {
-    p = sgroot->createSceneGraph(REDCUBE);
+    p = sgroot->createSceneGraph(redcube);
   }
   else {
-    p = sgroot->createSceneGraph(ENEMY);
+    p = sgroot->createSceneGraph(enemy);
   }
 
     root->set_move_collision(cube_move_right, cube_collision);
@@ -98,9 +99,9 @@
   float dx, dy,ddx,ddy, r;
   float q = 0;
 
-  for (; it->hasNext(REDCUBE);) {
+  for (; it->hasNext(redcube);) {
 
-    it->next(REDCUBE);
+    it->next(redcube);
     SceneGraphPtr mcube = it->get();
     dx = node->xyz[0] - mcube->xyz[0];
     dy = node->xyz[1] - mcube->xyz[1];
@@ -138,8 +139,8 @@
   float dx, dy,ddx,ddy, r;
   float q = 0;
 
-  for (; it->hasNext(ENEMY);) {
-    it->next(ENEMY);
+  for (; it->hasNext(enemy);) {
+    it->next(enemy);
     SceneGraphPtr mcube = it->get();
 
     dx = node->xyz[0] - mcube->xyz[0];
--- a/Renderer/Test/direction.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/direction.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,5 +1,5 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "direction.h"
 
 static void
 x_move(SceneGraphPtr node, int w, int h)
@@ -61,19 +61,19 @@
 {
 }
 
-void
-direction_init(TaskManager *manager)
+MainLoopPtr 
+direction::init(Viewer *sgroot, int screen_w, int screen_h)
 {
     SceneGraphPtr dx;
     SceneGraphPtr dy;
     SceneGraphPtr dz;
     SceneGraphPtr back;
 
-    sgroot->createFromXMLfile(manager, "xml_file/direction.xml");
+    sgroot->createFromXMLfile("xml_file/direction.xml");
 
-    dx = sgroot->createSceneGraph(Dirx);
-    dy = sgroot->createSceneGraph(Diry);
-    dz = sgroot->createSceneGraph(Dirz);
+    dx = sgroot->createSceneGraph("Dirx");
+    dy = sgroot->createSceneGraph("Diry");
+    dz = sgroot->createSceneGraph("Dirz");
     back = sgroot->createSceneGraph();
     
     back->addChild(dx);
@@ -90,4 +90,32 @@
     back->angle[1] = -30.0f;
 
     sgroot->setSceneData(back);
+    return sgroot;
 }
+
+extern Application *
+application() {
+    return new direction();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/direction.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class direction : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/dynamic_create.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,280 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include "SceneGraphRoot.h"
+#include "lindaapi.h"
+#include "dynamic_create.h"
+
+#define PORT 10000
+
+#define SERIAL_REGIST_TUPLE_NO 1
+
+/*
+  typedef struct {
+  caddr_t file_mmap;
+  off_t size;
+  } st_mmap_t;
+*/
+
+typedef struct client_ {
+    int id;
+    SceneGraphPtr sgp;
+    struct client_ *next;
+} client_t;
+
+typedef struct {
+    int tid;
+    int sid;
+    int read_id;
+    SceneGraphPtr node;
+    TaskManager *manager;
+    client_t *clist;
+} callback_arg;
+
+
+void
+client_list_init(TaskManager* manager, client_t *clist)
+{
+    clist->id = -1;
+    clist->next = clist;
+}
+
+void
+client_list_update(TaskManager *manager, client_t *clist, int id, SceneGraphPtr sgp)
+{
+    //client_t *c;
+    // for (c = clist->next; c != clist; c = c->next) {
+    // 	if (c->id == id) {
+    // 		c->sgp = sgp;
+    // 		return;
+    // 	}
+    // }
+	
+    // c->next = (client_t *)manager->allocate(sizeof(client_t));
+    // c->next->id = id;
+    // c->next->sgp = sgp;
+    // c->next->next = clist;
+}
+
+void
+client_list_delete(TaskManager *manager, client_t *clist, int id)
+{
+    client_t *c, *prev;
+    for (c = clist->next, prev = clist; c->next != clist; c = c->next) {
+	if (c->id == id) {
+	    prev->next = c->next;
+	    return;
+	}
+	prev = clist;
+    }
+    if (c->id == id) {
+	prev->next = c->next;
+	return;
+    }
+}
+
+int
+fix_byte(int size,int fix_byte_size)
+{
+    size = (size/fix_byte_size)*fix_byte_size  + ((size%fix_byte_size)!= 0)*fix_byte_size;
+    
+    return size;
+}
+
+st_mmap_t
+my_mmap(char *filename)
+{
+    int fd = -1;
+    int map = MAP_PRIVATE;
+    st_mmap_t st_mmap;
+    struct stat sb;
+
+    if ((fd = open(filename, O_RDONLY, 0666)) == 0 ) {
+	fprintf(stderr, "Can't open %s\n", filename);
+    }
+
+    if (fstat(fd, &sb)) {
+	fprintf(stderr, "Can't fstat %s\n", filename);
+    }
+
+    printf("file size %d\n", (int)sb.st_size);
+	
+    st_mmap.size = fix_byte(sb.st_size, 4096);
+
+    printf("fix 4096byte file size %d\n", (int)st_mmap.size);
+
+    st_mmap.file_mmap = (char *)mmap(NULL, st_mmap.size, PROT_READ, map, fd, (off_t)0);
+    if (st_mmap.file_mmap == (caddr_t)-1) {
+	fprintf(stderr, "Can't mmap file\n");
+	perror(NULL);
+	exit(0);
+    }
+
+    return st_mmap;	
+}
+
+static void
+earth_collision(SceneGraphPtr node, int screen_w, int screen_h,
+		SceneGraphPtr tree)
+{    
+}
+
+static void
+moon_collision(SceneGraphPtr node, int screen_w, int screen_h,
+	       SceneGraphPtr tree)
+{
+}
+
+static void
+moon_move(SceneGraphPtr node, int screen_w, int screen_h)
+{
+    //node->angle[0] += 3.0f;
+    node->xyz[1] += 1.0f;
+}
+
+
+static void
+earth_move(SceneGraphPtr node, int screen_w, int screen_h)
+{
+    psx_sync_n();
+}
+
+SceneGraphPtr
+create_sg(TaskManager *manager, SceneGraphPtr node, unsigned char *data, int len, int serial_id)
+{
+    SceneGraphPtr object;
+
+    sgroot->createFromXMLmemory(sgroot->tmanager, (char *)data, len);
+    object = sgroot->createSceneGraph(sgroot->getLast());
+    object->id = serial_id;
+    object->set_move_collision(moon_move, moon_collision);
+    node->addChild(object);
+
+    return object;
+}
+
+void
+del_callback(unsigned char *data, void *arg)
+{
+    free(data);
+}
+
+void
+psx_del(int t, int id)
+{
+    psx_callback_in(t, id, del_callback, NULL);
+}
+
+static void
+callback_get_xml(unsigned char *xml_tuple, void *arg) {
+    int xml_len = psx_get_datalength(xml_tuple);
+    callback_arg *carg = (callback_arg *)arg;
+    unsigned char *xml_data = xml_tuple+LINDA_HEADER_SIZE;
+    SceneGraphPtr sgp;
+    // ここで create
+    sgp = create_sg(carg->manager, carg->node, xml_data, xml_len, carg->sid);
+    client_list_update(carg->manager, carg->clist, carg->sid, sgp);
+    free(arg);
+    free(xml_tuple);
+}
+
+static void
+callbacker(unsigned char *tuple, void *arg) {
+    int serial_id, xml_id;
+	
+    unsigned char *data;
+    callback_arg *carg = (callback_arg *)arg;
+	
+    // 最初の4byteデータは使わない
+    data = tuple+LINDA_HEADER_SIZE;
+    // clientのSerialIDを取得
+    serial_id = ntohl(*(int *)data);
+    
+    // タプルを解放
+    psx_del(carg->tid, SERIAL_REGIST_TUPLE_NO);
+    
+    // xml fileを取得する もうすでにxml fileが送信済みである事を期待
+    // つまり、送信者がserial_idを送る前にxml fileを送信していなくてはならない
+    xml_id = serial_id * 10;
+    callback_arg *copy_arg = (callback_arg *)carg->manager->allocate(sizeof(callback_arg));
+    *copy_arg = *carg;
+    copy_arg->sid = serial_id;
+    psx_callback_in(carg->tid, xml_id, callback_get_xml, (void *)copy_arg);
+    
+    /* dataは'\0'で終わっている事を期待     (writerで保証する)  */
+    //printf("get data[%d]: `%s'\n", len, data);
+    free(tuple);
+    
+    psx_callback_wait_rd(carg->tid, carg->read_id, callbacker, arg);
+}
+
+void
+linda_init(TaskManager *manager, client_t *clist, SceneGraphPtr node)
+{
+    init_linda();
+    callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg));
+
+    carg->tid = open_linda_java("localhost", PORT);
+    carg->read_id = SERIAL_REGIST_TUPLE_NO;    
+    carg->node = node;
+    carg->manager = manager;
+    carg->clist = clist;
+    psx_callback_wait_rd(carg->tid, carg->read_id, callbacker, carg);
+}
+
+MainLoopPtr 
+dynamic_create::init(Viewer *sgroot, int screen_w, int screen_h)
+{
+    //SceneGraphPtr earth;
+    client_t *clist;
+    clist = (client_t *)sgroot->manager->allocate(sizeof(client_t));
+	
+    client_list_init(sgroot->manager, clist);
+
+    SceneGraphPtr parent;
+    parent = sgroot->createSceneGraph();
+    parent->set_move_collision(earth_move, earth_collision);
+    parent->xyz[0] += 300;
+
+    linda_init(sgroot->manager, clist,  parent);
+    
+    // SceneGraphRoot に、使用する SceneGraph を設定する
+    // このとき、ユーザーが記述した SceneGraph の root を渡す。
+    sgroot->setSceneData(parent);
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new dynamic_create();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/dynamic_create.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,11 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class dynamic_create : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
--- a/Renderer/Test/game_over.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/game_over.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,6 +1,5 @@
 #include "SceneGraphRoot.h"
 #include "vacuum.h"
-#include "SGList.h"
 
 
 void
@@ -9,7 +8,7 @@
 
   SceneGraphPtr over;
 
-  over = sgroot->createSceneGraph(GAMEOVER);
+  over = sgroot->createSceneGraph("GAMEOVER");
   over->xyz[0] = w/2;
   over->xyz[1] = h/2;
   over->set_move_collision(gameover_idle,gameover_collision);
@@ -31,7 +30,7 @@
 
     SceneGraphPtr title;
 
-    title = sgroot->createSceneGraph(TITLE);
+    title = sgroot->createSceneGraph("TITLE");
     title->xyz[0] = screen_w/2;
     title->xyz[1] = screen_h/2;
     title->set_move_collision(no_move_idle, title_collision);
--- a/Renderer/Test/gaplant.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/gaplant.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,15 +1,15 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
 #include "gaplant_action.h"
+#include "gaplant.h"
 #include "back_action.h"
 
-void
-init_gaplant(TaskManager *manager, int w, int h)
+MainLoopPtr
+gaplant::init(Viewer *sgroot, int w, int h)
 {
     SceneGraphPtr back;
     SceneGraphPtr gaplant;
-    sgroot->createFromXMLfile(manager, "xml_file/gap_plane_test.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/Ball.xml");
+    sgroot->createFromXMLfile("xml_file/gap_plane_test.xml");
+    sgroot->createFromXMLfile("xml_file/Ball.xml");
 
     back = sgroot->createSceneGraph();
     back->set_move_collision(back_move, back_coll);
@@ -19,12 +19,44 @@
     gaplant->angle[1] = 0;
     gaplant->angle[2] = 0;
     gaplant->set_move_collision(gaplant_move, gaplant_coll);
- 
-    for (int i = arm_L_D; i <= foot_L_A; i++) {
+
+    int foot =  sgroot->getSgid("foot_L_A");
+    for (int i = sgroot->getSgid("arm_L_D"); i <= foot; i++) {
 	SceneGraphPtr p = sgroot->createSceneGraph(i);
 	gaplant->addChild(p);
     }
 
     back->addChild(gaplant);
     sgroot->setSceneData(back);        
+    return sgroot;
 }
+
+
+
+extern Application *
+application() {
+    return new gaplant();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
--- a/Renderer/Test/gaplant.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/gaplant.h	Thu Oct 22 23:54:58 2009 +0900
@@ -1,2 +1,15 @@
 const double CHECK_HIT_RAD = 110;
 const double BALL_RAD = 100;
+
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class gaplant : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/gaplant_action.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/gaplant_action.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,7 +1,7 @@
 #include <iostream>
 #include <cmath>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "xml_file/gap_plane_test.xml.h"
 #include "gaplant.h"
 using namespace std;
 
--- a/Renderer/Test/ieshoot.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/ieshoot.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,5 +1,5 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "ieshoot.h"
 
 static const float jiki_speed = 6.0f;
 static const float jiki_radius = 32.0f;
@@ -40,9 +40,9 @@
 {
     SceneGraphIteratorPtr it = sgroot->getIterator(tree);
     static int damage = 0;
-
-    for (; it->hasNext(IETAMA);) {
-	it->next(IETAMA);
+    int ietama = sgroot->getSgid("IETAMA");
+    for (; it->hasNext(ietama);) {
+	it->next(ietama);
 	SceneGraphPtr tama = it->get();
 
 	if (node->xyz[0] - boss_radius_x < tama->xyz[0] + tama_radius
@@ -52,7 +52,7 @@
 
 	    node->set_move_collision(ieboss_move, ieboss_collision_invincibil);
 
-	    SceneGraphPtr iebosstama = sgroot->createSceneGraph(Earth);
+	    SceneGraphPtr iebosstama = sgroot->createSceneGraph("Earth");
 	    iebosstama->set_move_collision(iebosstama_move, ietama_collision);
 	    iebosstama->xyz[0] = node->xyz[0];
 	    iebosstama->xyz[1] = node->xyz[1] + boss_radius_y;
@@ -179,7 +179,7 @@
     }
 
     if (pad->circle.isPush()) {
-	SceneGraphPtr ietama = sgroot->createSceneGraph(IETAMA);
+	SceneGraphPtr ietama = sgroot->createSceneGraph("IETAMA");
 	ietama->set_move_collision(ietama_move, ietama_collision);
 	ietama->xyz[0] = node->xyz[0];
 	ietama->xyz[1] = node->xyz[1];
@@ -188,29 +188,57 @@
 }
 
 
-void
-ieshoot_init(TaskManager *manager)
+MainLoopPtr
+ieshoot::init(Viewer *sgroot, int w, int h)
 {
     SceneGraphPtr iejiki;
     SceneGraphPtr enemy;
     SceneGraphPtr back;
 
-    sgroot->createFromXMLfile(manager, "xml_file/ietama.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/ieboss.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/iejiki.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/universe.xml");
+    sgroot->createFromXMLfile( "xml_file/ietama.xml");
+    sgroot->createFromXMLfile( "xml_file/ieboss.xml");
+    sgroot->createFromXMLfile( "xml_file/iejiki.xml");
+    sgroot->createFromXMLfile( "xml_file/universe.xml");
 
     back = sgroot->createSceneGraph();
 
-    iejiki = sgroot->createSceneGraph(IEJIKI);
+    iejiki = sgroot->createSceneGraph("IEJIKI");
     iejiki->set_move_collision(iejiki_move, iejiki_collision);
     iejiki->xyz[2] = 20;
     back->addChild(iejiki);
 
-    enemy = sgroot->createSceneGraph(IEBOSS);
+    enemy = sgroot->createSceneGraph("IEBOSS");
     enemy->set_move_collision(ieboss_move, ieboss_collision);
     enemy->xyz[1] = boss_radius_y;
     back->addChild(enemy);
 
     sgroot->setSceneData(back);
+    return sgroot;
 }
+
+extern Application *
+application() {
+    return new ieshoot();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/ieshoot.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,12 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class ieshoot : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/init_position.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/init_position.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,11 +1,11 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
 #include "player_action.h"
 #include "enemy_action.h"
 #include "camera_action.h"
+#include "init_position.h"
 
-void
-init_position(TaskManager *manager, int w, int h)
+MainLoopPtr
+posiotion::init(Viewer *sgroot, int w, int h)
 {
     SceneGraphPtr back;
     SceneGraphPtr player;
@@ -33,4 +33,5 @@
     }
 
     sgroot->setSceneData(back);
+    return sgroot;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/init_position.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,12 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class position : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/long_cube.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/long_cube.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,5 +1,5 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "long_cube.h"
 
 // prototype
 static void lcube_move(SceneGraphPtr node, int screen_w, int screen_h);
@@ -18,8 +18,8 @@
 }
 
 
-void
-lcube_init(TaskManager *manager, int screen_w, int screen_h)
+MainLoopPtr
+lcube_init(Viewer *sgroot, int screen_w, int screen_h)
 {
     SceneGraphPtr lcube;
 
@@ -28,4 +28,5 @@
     lcube->set_move_collision(lcube_move, lcube_collision);
 
     sgroot->setSceneData(lcube);
+    return sgroot;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/long_cube.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,12 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class long_cube : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/node.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/node.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "SceneGraphRoot.h"
 #include "SceneGraph.h"
-#include "xml_file/cube.h"
+#include "node.h"
 
 static void
 cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
@@ -62,11 +62,42 @@
     }
 }
 
-void
-node_init(TaskManager *manager)
+MainLoopPtr
+node::init(Viewer *sgroot, int screen_w, int screen_h)
 {
-    sgroot->createFromXMLfile(manager, "xml_file/cube.xml");
+    sgroot->createFromXMLfile( "xml_file/cube.xml");
+    SceneGraphPtr Cube = sgroot->createSceneGraph("Cube");
     Cube->set_move_collision(cube_move, cube_collision);
     Cube->stack_xyz[0] = 2.0f;
     Cube->stack_xyz[1] = 2.0f;
+    return sgroot;
 }
+
+extern Application *
+application() {
+    return new node();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/node.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class node : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/panel.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/panel.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,5 +1,5 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "panel.h"
 
 static void panel_move(SceneGraphPtr node, int screen_w, int screen_h);
 static void panel_collision(SceneGraphPtr node, int screen_w, int screen_h,
@@ -16,23 +16,60 @@
 {
 }
 
-void
-panel_init(TaskManager *manager, int bg)
+int bg = 0;
+
+MainLoopPtr
+panel::init(Viewer *sgroot, int screen_w, int screen_h)
 {
     SceneGraphPtr panel;
 
     if (bg == 2) {
-		sgroot->createFromXMLfile(manager, "xml_file/panel_512.xml");
-		panel = sgroot->createSceneGraph(PANEL_512);
+		sgroot->createFromXMLfile( "xml_file/panel_512.xml");
+		panel = sgroot->createSceneGraph("PANEL_512");
     } else if (bg == 3) {
-		sgroot->createFromXMLfile(manager, "xml_file/panel_1024.xml");
-		panel = sgroot->createSceneGraph(PANEL_1024);
+		sgroot->createFromXMLfile( "xml_file/panel_1024.xml");
+		panel = sgroot->createSceneGraph("PANEL_1024");
     } else {
-		sgroot->createFromXMLfile(manager, "xml_file/panel_2048.xml");
-		panel = sgroot->createSceneGraph(PANEL_2048);
+		sgroot->createFromXMLfile( "xml_file/panel_2048.xml");
+		panel = sgroot->createSceneGraph("PANEL_2048");
     }
 
     panel->set_move_collision(panel_move, panel_collision);
     panel->xyz[2] = 30.0f;
     sgroot->setSceneData(panel);
+    return sgroot;
 }
+
+extern Application *
+application() {
+    return new panel();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl -sg [123] [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    for(int i=0;i<argc;i++) {
+         if (strcmp(argv[i],"-sg")==0) {
+             bg = atoi(argv[i+1]);
+         }
+    }
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/panel.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class panel : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/send_linda.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,213 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include "SceneGraphRoot.h"
+#include "lindaapi.h"
+#include "send_linda.h"
+
+#define HOSTNAME "localhost"
+#define PORT_NUM 10000
+#define LISTEN_PORT 1
+#define MULTI_NUM 10
+
+void
+root_move(SceneGraphPtr node, int w, int h)
+{
+    Pad *pad = sgroot->getController();
+
+    if (pad->right.isHold() || pad->left.isHold()) {
+	if (pad->right.isHold()) {
+	    node->xyz[0] += 5.0f;
+	} else if (pad->left.isHold()) {
+	    node->xyz[0] -= 5.0f;
+	}
+    }
+    
+    if (pad->down.isHold() || pad->up.isHold() ) {
+	if (pad->down.isHold()) {
+	    node->xyz[1] += 5.0f;
+	} else if (pad->up.isHold()) {
+	    node->xyz[1] -= 5.0f;
+	}
+    }
+
+    /*
+      ここでキー入力を向こうに送る
+     */
+    
+}
+
+void
+root_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+{
+}
+
+void
+move(SceneGraphPtr node, int w, int h)
+{
+}
+
+void
+collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+{
+}
+
+void *
+file_map(const char *filename, int *size) {
+    int fd;
+    void *addr;
+    struct stat sb;
+
+    if ((fd = open(filename, O_RDONLY)) == -1) {
+	fprintf(stderr, "Can't open %s\n", filename);
+	perror(NULL);
+    }
+    if (fstat(fd, &sb) == -1) {
+	fprintf(stderr, "Can't fstat %s\n", filename);
+	perror(NULL);
+    }
+    *size = sb.st_size;
+    addr = mmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
+    if (addr == MAP_FAILED) {
+	perror("mmap error\n");
+	exit(EXIT_FAILURE);
+    }
+    close(fd);
+
+    return addr;
+}
+
+
+void
+linda_init(char *addr, int *size)
+{
+    
+}
+
+int get_serial_id(int fd) {
+    char *data;
+    int serial;
+    int seq;
+    
+    seq = psx_in(fd, 65535);
+    psx_sync_n();
+    data = (char *)psx_reply(seq);
+    serial = atoi(data + LINDA_HEADER_SIZE);
+    psx_free(data);
+    
+    return serial;
+}
+
+
+void
+send_xml(int tspace, int xml_id, void *addr, int size) {
+    psx_out(tspace, xml_id, (unsigned char *)addr, size);
+    psx_sync_n();
+}
+
+/*
+void
+mainLoop(int tid, int write_id, int fd)
+{
+    void *addr;
+    struct stat sb;
+    
+    if (fstat(fd, &sb) == -1) {
+	perror("fstat");
+	exit(1);
+    }
+    addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+    if (addr==NULL) {
+	perror("mmap");
+	exit(1);
+    }
+
+    printf("file size=%d\n", sb.st_size);
+
+    psx_out(tid, write_id, addr, sb.st_size);
+    psx_sync_n();
+
+    return;
+}
+*/
+
+static char *xml;
+
+MainLoopPtr 
+send_linda::init(Viewer *sgroot, int screen_w, int screen_h)
+{
+    void *addr;
+    int size;
+    int tspace;
+    int serial;
+    int xml_id;
+
+    SceneGraphPtr sgp;
+    SceneGraphPtr root;
+    root = sgroot->createSceneGraph();
+    root->set_move_collision(root_move, root_collision);
+
+    // createFromXMLfile で object name のリストを生成して返したい
+    sgroot->createFromXMLfile( xml);
+    // 今だけは決め打ち、本当はリストを回して object 数 create したい
+    sgp = sgroot->createSceneGraph("Ball");
+    sgp->set_move_collision(move, collision);
+    
+    root->addChild(sgp);
+    
+    init_linda();
+    addr = file_map(xml, &size);
+    tspace = open_linda_java(HOSTNAME, PORT_NUM);    
+    serial = get_serial_id(tspace);
+    xml_id = serial * 10;
+    send_xml(tspace, xml_id, addr, size);   	    
+    
+    int client_id = htonl(serial);
+    send_xml(tspace, LISTEN_PORT, (void *)client_id, sizeof(int));
+
+    sgroot->setSceneData(root);
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new send_linda();
+}
+
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+
+    for(int i=0;i<argc;i++) {
+	if (strcmp(argv[i],"-xml") == 0 && i+1<=argc) {
+	    xml = argv[i+1];
+	}
+    }
+
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/send_linda.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,11 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class send_linda : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
--- a/Renderer/Test/title.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/title.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,6 +1,7 @@
 #include "SceneGraphRoot.h"
 #include "vacuum.h"
-#include "SGList.h"
+
+extern int redcube;
 
 void
 title_collision(SceneGraphPtr node, int w, int h,SceneGraphPtr tree)
@@ -13,14 +14,14 @@
     SceneGraphPtr vacuum;
     SceneGraphPtr back = sgroot->createSceneGraph(); 
 
-    vacuum = sgroot->createSceneGraph(BIGCUBE);
+    vacuum = sgroot->createSceneGraph("BIGCUBE");
     vacuum->xyz[0] = w/2;
     vacuum->xyz[1] = h*0.8;
     vacuum->set_move_collision(vacuum_move, vacuum_coll);
     
     back->addChild(vacuum);
     
-    add_cubecollision_object(REDCUBE,vacuum,w,h);
+    add_cubecollision_object(redcube,vacuum,w,h);
     
     sgroot->setSceneData(back);
       
--- a/Renderer/Test/universe.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/universe.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "universe.h"
 
 static void
 earth_collision(SceneGraphPtr node, int screen_w, int screen_h,
@@ -40,23 +40,23 @@
     }
 }
 
-void
-universe_init(TaskManager *manager)
+MainLoopPtr
+universe::init(Viewer *sgroot, int screen_w, int screen_h)
 {
     SceneGraphPtr earth;
     SceneGraphPtr moon;
 
-    sgroot->createFromXMLfile(manager, "xml_file/universe.xml");
+    sgroot->createFromXMLfile( "xml_file/universe.xml");
 
     // SGList.h にある SceneGraph ID から SceneGraph を生成する
-    earth = sgroot->createSceneGraph(Earth);
+    earth = sgroot->createSceneGraph("Earth");
 
     // SceneGraph の move と collision を設定
     earth->set_move_collision(earth_move, earth_collision);
     earth->stack_xyz[0] = 3.0f;
     earth->stack_xyz[1] = 3.0f;
     
-    moon = sgroot->createSceneGraph(Moon);
+    moon = sgroot->createSceneGraph("Moon");
     moon->set_move_collision(moon_move, moon_collision);
     
     // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon)
@@ -65,4 +65,35 @@
     // SceneGraphRoot に、使用する SceneGraph を設定する
     // このとき、ユーザーが記述した SceneGraph の root を渡す。
     sgroot->setSceneData(earth);
+    return sgroot;
 }
+
+
+extern Application *
+application() {
+    return new universe();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/universe.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,12 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class universe : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/untitled.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/untitled.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "untitled.h"
 #include <math.h>
 
 static void
@@ -73,8 +73,8 @@
   
 }
 
-void
-untitled_init(TaskManager *manager)
+MainLoopPtr
+untitled::init(Viewer *sgroot, int screen_w, int screen_h)
 {
     SceneGraphPtr test00;
     SceneGraphPtr test01;
@@ -87,7 +87,7 @@
     SceneGraphPtr test08;
     SceneGraphPtr test09;
 
-    sgroot->createFromXMLfile(manager, "xml_file/Venus.xml");
+    sgroot->createFromXMLfile( "xml_file/Venus.xml");
 
     // SGList.h にある SceneGraph ID から SceneGraph を生成する
     /*
@@ -102,16 +102,16 @@
     test08 = sgroot->createSceneGraph(cubetest002);
     test09 = sgroot->createSceneGraph(cubetest001);
     */
-    test00 = sgroot->createSceneGraph(Venus000);
-    test01 = sgroot->createSceneGraph(Venus009);
-    test02 = sgroot->createSceneGraph(Venus008);
-    test03 = sgroot->createSceneGraph(Venus007);
-    test04 = sgroot->createSceneGraph(Venus006);
-    test05 = sgroot->createSceneGraph(Venus005);
-    test06 = sgroot->createSceneGraph(Venus004);
-    test07 = sgroot->createSceneGraph(Venus003);
-    test08 = sgroot->createSceneGraph(Venus002);
-    test09 = sgroot->createSceneGraph(Venus001);
+    test00 = sgroot->createSceneGraph("Venus000");
+    test01 = sgroot->createSceneGraph("Venus009");
+    test02 = sgroot->createSceneGraph("Venus008");
+    test03 = sgroot->createSceneGraph("Venus007");
+    test04 = sgroot->createSceneGraph("Venus006");
+    test05 = sgroot->createSceneGraph("Venus005");
+    test06 = sgroot->createSceneGraph("Venus004");
+    test07 = sgroot->createSceneGraph("Venus003");
+    test08 = sgroot->createSceneGraph("Venus002");
+    test09 = sgroot->createSceneGraph("Venus001");
     
     // SceneGraph の move と collision を設定
     test00->set_move_collision(cubetest_move, cubetest_collision);
@@ -145,5 +145,34 @@
     // SceneGraphRoot に、使用する SceneGraph を設定する
     // このとき、ユーザーが記述した SceneGraph の root を渡す。
     sgroot->setSceneData(test00);
-    
+    return sgroot;    
+}
+
+extern Application *
+application() {
+    return new untitled();
 }
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/untitled.h	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,12 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class untitled : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
--- a/Renderer/Test/vacuum.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/vacuum.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,7 +1,6 @@
 #include <math.h>
 #include "vacuum.h"
 #include "SceneGraphRoot.h"
-#include "SGList.h"
 #define ENCOUNT 55
 using namespace std;
 
@@ -27,6 +26,9 @@
 
 }
 
+int redcube;
+int enemy;
+
 void
 vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
             SceneGraphPtr tree)
@@ -35,10 +37,10 @@
 
     if(node->frame%ENCOUNT == ENCOUNT-1) {
       if(random()%2) {
-      add_cubecollision_object(REDCUBE,node,screen_w,screen_h);
+      add_cubecollision_object(redcube,node,screen_w,screen_h);
       }
       else {
-      add_cubecollision_object(ENEMY,node,screen_w,screen_h);
+      add_cubecollision_object(enemy,node,screen_w,screen_h);
       }
     }
 
@@ -60,22 +62,22 @@
 lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it)
 {
 
-  SceneGraphPtr enemy;
+  SceneGraphPtr e;
   SceneGraphPtr near_enemy = NULL;
   float dx,dy,r,range = 100;
   // Pad *pad = sgroot->getController();
 
-  for(;it->hasNext(ENEMY);) {
+  for(;it->hasNext(enemy);) {
 
-      it->next(ENEMY);
-      enemy = it->get();
-      dx = enemy->xyz[0] - node->xyz[0];
-      dy = enemy->xyz[1] - node->xyz[1];
+      it->next(enemy);
+      e = it->get();
+      dx = e->xyz[0] - node->xyz[0];
+      dy = e->xyz[1] - node->xyz[1];
       r = sqrt(dx*dx+dy*dy);
 
-      if(range > r && enemy->stack_xyz[2] == 0) {
+      if(range > r && e->stack_xyz[2] == 0) {
         range = r;
-        near_enemy = enemy;
+        near_enemy = e;
       }
   }
 
@@ -85,7 +87,7 @@
     SceneGraphPtr lockon;
     //    SceneGraphPtr near_enemy_common_move = near_enemy->parent;
     near_enemy->stack_xyz[2] = 1;
-    lockon = sgroot->createSceneGraph(LOCK);
+    lockon = sgroot->createSceneGraph("LOCK");
     lockon->set_move_collision(no_move_idle,lockon_collision);
     //near_enemy_common_move->addChild(lockon);
     near_enemy->addChild(lockon);
@@ -156,19 +158,51 @@
 }
 
 
-void
-vacuum_init2(TaskManager *manager, int w, int h)
+MainLoopPtr
+vacuum::init(Viewer *sgroot, int w, int h)
 {
     SceneGraphPtr title;
 
-    sgroot->createFromXMLfile(manager, "xml_file/gamecube.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/title.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/gameover.xml");
+    sgroot->createFromXMLfile( "xml_file/gamecube.xml");
+    sgroot->createFromXMLfile( "xml_file/title.xml");
+    sgroot->createFromXMLfile( "xml_file/gameover.xml");
 
-    title = sgroot->createSceneGraph(TITLE);
+    title = sgroot->createSceneGraph("TITLE");
     title->xyz[0] = w/2;
     title->xyz[1] = h/2;
     title->set_move_collision(no_move_idle, title_collision);
 
     sgroot->setSceneData(title);
+
+    redcube = sgroot->getSgid("REDCUBE");
+    enemy = sgroot->getSgid("ENEMY");
+
+    return sgroot;
 }
+
+extern Application *
+application() {
+    return new vacuum();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
--- a/Renderer/Test/vacuum.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/Renderer/Test/vacuum.h	Thu Oct 22 23:54:58 2009 +0900
@@ -1,28 +1,38 @@
 #ifndef VACUUM_H
 #define VACUUM_H
 
-#include "SGList.h"
+#include <math.h>
+#include <stdlib.h>
 #include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class vacuum : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+};
+
 
-void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h);
-void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h);
-void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h);
-void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-void cube_split(SceneGraphPtr root,SceneGraphPtr tree);
-void vacuum_move(SceneGraphPtr node, int w, int h);
-void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree);
-void title_idle(SceneGraphPtr node, int screen_w, int screen_h);
-void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-void scene_change(int w,int h,SceneGraphPtr node);
-void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h);
-void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node);
-void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h);
-void gameover_scene(int w,int h, SceneGraphPtr node);
-void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h);
-void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it);
-void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree);
-void cube_rotate(SceneGraphPtr node,int w,int h);
+extern void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h);
+extern void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h);
+extern void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h);
+extern void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void cube_split(SceneGraphPtr root,SceneGraphPtr tree);
+extern void vacuum_move(SceneGraphPtr node, int w, int h);
+extern void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree);
+extern void title_idle(SceneGraphPtr node, int screen_w, int screen_h);
+extern void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void scene_change(int w,int h,SceneGraphPtr node);
+extern void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h);
+extern void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node);
+extern void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h);
+extern void gameover_scene(int w,int h, SceneGraphPtr node);
+extern void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h);
+extern void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it);
+extern void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree);
+extern void cube_rotate(SceneGraphPtr node,int w,int h);
 
 #endif
--- a/TaskManager/ChangeLog	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/ChangeLog	Thu Oct 22 23:54:58 2009 +0900
@@ -1,27 +1,3 @@
-2009-10-16 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
-
-    create_task が Task を返したり HTask を返すのはよろしくない。
-    HTask はHostに閉じていて、Task は転送可能って方が良いでしょう。
-
-    TaskGroup は謎だが、無視して良いのではないだろうか? HTaskで
-    double linked list 作るなら、それでschedulingすれば良い。
-
-    TaskList (本当は配列) は、なくしてしまうのが良いと思う。
-    Task(可変長) を List DMA で転送して、向こう側で HTask queue を構成する
-    方が合理的でしょう。
-
-    TaskList はそれ自体が、HTask であるべきだと思う。
-    mail で self (HTask address)を返すことはしないで、
-    TaskListTask の outData で返す。
-
-    SPU側には、single task を転送して起動するAPIだけを用意する。
-    TaskListTask が残りのTaskをList DMAで取得し、順次実行する。
-       List DMAで取得したTaskデータの集合は、HTaskに格納される
-
-    とか、なんとかすると変更が大きいんだよな...
-
-    param と inData がかぶってる。param は便利だけどね。
-
 2009-10-11 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
 
     単純な、rbuf, wbuf + write return size の task のAPI
--- a/TaskManager/Fifo/FifoDmaManager.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.h	Thu Oct 22 23:54:58 2009 +0900
@@ -24,6 +24,7 @@
 
     void dma_loadList(ListDataPtr list, void *buff, uint32 mask);
     void dma_storeList(ListDataPtr, void *buff, uint32 mask);
+    //void* dma_loadList(ListDataPtr list, void *buff, uint32 mask);
 };
 
 #endif
--- a/TaskManager/kernel/ppe/HTask.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/HTask.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,4 +1,24 @@
 #include "HTask.h"
+#include "ListData.h"
+#include "TaskManagerImpl.h"
+
+
+/*!
+  manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ
+ 
+  ってやるより
+ 
+  task2->set_depend(task1);
+ 
+  ってやったほうがわかりやすいよねー的な話し合いで
+  下のようなAPIを作りました
+*/
+
+void
+HTask::spawn(void)
+{
+    mimpl->spawn_task(this);
+}
 
 /*!
   @brief この Task が待ち合わせする Task を指定する
@@ -12,29 +32,21 @@
 void
 HTask::wait_for(HTaskPtr master)
 {
-    TaskQueuePtr m, s;
-
-    m = wait_i->create(master);
-    s = wait_i->create(this);
-
-    master->wait_me->addLast(s);
-    this->wait_i->addLast(m);
-    s->waiter = m;
-
+    mimpl->set_task_depend(master, this);
 }
 
 void
 HTask::set_cpu(CPU_TYPE type)
 {
-    cpu_type = type;
+    mimpl->set_task_cpu(this, type);
 }
 
 void
-HTask::set_post(PostFunction func_,void *read, void *write)
+HTask::set_post(PostFunction func,void *arg1, void *arg2)
 {
-    post_func = func_;
-    post_arg1 = read;
-    post_arg2 = write;
+    this->post_func = func;
+    this->post_arg1 = arg1;
+    this->post_arg2 = arg2;
 }
 
 /* end */
--- a/TaskManager/kernel/ppe/HTask.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/HTask.h	Thu Oct 22 23:54:58 2009 +0900
@@ -15,8 +15,6 @@
   @class
   
   @brief
-
-  Host に依存した Task の情報
   
   Cerium の Task で、spawn() でキューに格納されて順次実行される。
   cpu の指定があれば並列に実行される。
@@ -30,16 +28,17 @@
 
     TaskQueueInfo *wait_me;  // List of task waiting for me
     TaskQueueInfo *wait_i;   // List of task for which I am waiting
-
     PostFunction post_func;
     void *post_arg1;
     void *post_arg2;
     CPU_TYPE cpu_type;
+    TaskManagerImpl *mimpl;
 
     HTask *waiter;
     HTask *next;
     HTask *prev;
 
+    void spawn(void);
     void wait_for(HTask *);
     void set_cpu(CPU_TYPE type);    
     void set_post(PostFunction func, void *read, void *write);
--- a/TaskManager/kernel/ppe/HTaskInfo.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/HTaskInfo.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -64,13 +64,13 @@
     q->waiter = NULL;
 
     q->command  = cmd;
-    // q->inData.clear();
-    // q->outData.clear();
+    q->inData.clear();
+    q->outData.clear();
     q->self = (int) q;
     q->param_size = 0;
 
     q->post_func = NULL;
-    // q->mimpl     = NULL;
+    q->mimpl     = NULL;
     q->cpu_type  = CPU_PPE;
 
     // q->wait_me.clear();
--- a/TaskManager/kernel/ppe/Task.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/Task.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -11,7 +11,6 @@
 int
 Task::add_inData_t(unsigned int addr, int size)
 {
-    ListData *inData = (ListData*) rbuf;
     return add_data(inData, addr, size);
 }
 
@@ -26,7 +25,6 @@
 int
 Task::add_outData_t(unsigned int addr, int size)
 {
-    ListData *outData = (ListData*) wbuf;
     return add_data(outData, addr, size);
 }
 
@@ -52,21 +50,18 @@
  * perror みたいにしたほうがわかりやすいかな。
  */
 int
-Task::add_data(ListData *list, uint32 addr, int size)
+Task::add_data(ListData& list, uint32 addr, int size)
 {
-    if (list->length >= MAX_LIST_DMA_SIZE) return -1;
+    if (list.length >= MAX_LIST_DMA_SIZE) return -1;
 
-    list->bound[list->length] = list->size;
+    list.bound[list.length] = list.size;
 
     // size でも制限かけるべき?
-    list->size += size;
+    list.size += size;
 
-    ListElementPtr elm = &list->element[list->length++];
+    ListElementPtr elm = &list.element[list.length++];
     elm->addr = addr;
     elm->size = size;
 
     return 0;
 }
-
-
-/* end */
--- a/TaskManager/kernel/ppe/Task.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/Task.h	Thu Oct 22 23:54:58 2009 +0900
@@ -8,26 +8,6 @@
 #define MAX_PARAMS 8
 
 class TaskQueue;
-class SchedTask;
-
-
-/*!
-  @class
-  
-  @brief
-
-  Host に依存しない  Task 
-
-  以下の三つの可変長データを含む 
-    param
-    inData
-    outData 
-  param は inData の最初の部分となる
-
-  self はメインホストの中のHTaskのアドレスで、task id として使う
-
- */
-
 
 class Task {
 public: // variables
@@ -36,22 +16,16 @@
 
     int command;         // 4 byte
     int self;         // 4 byte
-    int rsize;
-    int wsize;
+
     int param_size;        // 4 byte
-    void *rbuf;
-    void *wbuf;
-    int param[MAX_PARAMS];
-
-#if 0
+    int param[MAX_PARAMS]; // 4*MAX_PARAMS byte
     ListData inData  __attribute__ ((aligned (DEFAULT_ALIGNMENT)));  // 4 byte 64bit であるべき
     ListData outData  __attribute__ ((aligned (DEFAULT_ALIGNMENT))); // 4 byte 64bit であるべき
-#endif
 
 public: // functions
     int add_inData_t(unsigned int addr, int size);  // unsigned int ではなく 64bit
     int add_outData_t(unsigned int addr, int size); // unsigned int ではなく 64bit
-    int add_data(ListData *list, unsigned int addr, int size);
+    int add_data(ListData &list, unsigned int addr, int size);
     int add_param(int param);
 
 #define add_inData(addr, size)			\
--- a/TaskManager/kernel/ppe/TaskManager.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManager.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -54,12 +54,6 @@
     return m_impl->create_task(cmd);
 }
 
-HTaskPtr 
-TaskManager::create_task(int cmd, void *read, int rsize, void *write, int wsize)
-{
-    return m_impl->create_task(cmd,read,rsize,write,wsize);
-}
-
 /**
  * TaskManaer 終了時に実行される関数の設定
  */
--- a/TaskManager/kernel/ppe/TaskManager.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManager.h	Thu Oct 22 23:54:58 2009 +0900
@@ -5,6 +5,7 @@
 #include "Random.h"
 #include "MemList.h"
 #include "Scheduler.h"
+#include "HTask.h"
 
 class TaskManager {
 public:
@@ -19,8 +20,6 @@
 
     /* user function */
     HTaskPtr create_task(int cmd);
-    /* simple task creation */
-    HTaskPtr create_task(int cmd, void *read, int rsize, void *write, int wsize);
     void run();
     void *allocate(int size);
     void set_TMend(void (*endf)(TaskManager *manager));
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -1,14 +1,19 @@
 #include <stdio.h>
 #include "TaskManagerImpl.h"
+#include "types.h"
+#include "error.h"
 #include "SchedTask.h"
 #include "SchedTaskManager.h"
-#include "types.h"
-#include "error.h"
 #include "../sys_task/SysTask.h"
 
 static HTaskPtr systask_start;
 static HTaskPtr systask_finish;
 
+static void
+noaction(SchedTask *s, void *read, void *write)
+{
+}
+
 TaskManagerImpl::TaskManagerImpl(int num)
     : machineNum(num) {
     activeTaskQueue = new HTaskInfo();
@@ -17,11 +22,6 @@
     taskQueueImpl = new TaskQueueInfo(); 
 }
 
-static void
-noaction(SchedTask *s, void *read, void *write)
-{
-}
-
 /**
  * 一番最初に PPE で実行される systask_start
  * 一番最後に、全てのタスクの終了を待つ systask_finish
@@ -34,10 +34,10 @@
 
     schedTaskManager = new SchedTaskManager(this);
 
-    systask_start = create_task(SYSTASK_START,0,0,0,0);
-    systask_finish = create_task(SYSTASK_FINISH,0,0,0,0);
+    systask_start = create_task(SYSTASK_START);
+    systask_finish = create_task(SYSTASK_FINISH);
 
-    spawn(systask_start);
+    systask_start->spawn();
 
     // systask_finish で spawn すると
     //   systask_finish->wait_for(systask_finish);
@@ -46,19 +46,6 @@
     append_waitTask(systask_finish);
 }
 
-void *
-TaskManagerImpl::get_rbuf()
-{
-    return 0;
-}
-
-void *
-TaskManagerImpl::get_wbuf()
-{
-    return 0;
-}
-
-
 HTaskPtr
 TaskManagerImpl::create_task(int cmd)
 {
@@ -66,35 +53,36 @@
 
     new_task = htaskImpl->create(cmd);
     new_task->post_func = noaction;
-    new_task->rbuf = get_rbuf();
-    new_task->wbuf = get_wbuf();
+    new_task->mimpl = this;
 
     return new_task;
 }
 
-HTaskPtr
-TaskManagerImpl::create_task(int cmd, void *read, int rsize, void *write, int wsize)
+/**
+ * task の依存関係を設定
+ * master task が終わってから、slave task を実行するように
+ * master->wait_for(slave);
+ */
+void
+TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave)
 {
-    HTaskPtr new_task;
+    TaskQueuePtr m, s;
 
-    new_task = htaskImpl->create(cmd);
-    new_task->post_func = noaction;
-    new_task->rbuf = read;
-    new_task->rsize = rsize;
-    new_task->wbuf = write;
-    new_task->wsize = wsize;
+    m = taskQueueImpl->create(master);
+    s = taskQueueImpl->create(slave);
 
-    return new_task;
+    master->wait_me->addLast(s);
+    slave->wait_i->addLast(m);
+    s->waiter = m;
 }
 
-
 /**
  * タスクを実行可能キューまたは待機キューへ追加する。
  * 依存関係が満たされていれば active, まだだったら wait へ。
  * task->spawn();
  */
 void
-TaskManagerImpl::spawn(HTask *task)
+TaskManagerImpl::spawn_task(HTaskPtr task)
 {
     // waiter // master
     // waitee // slave
@@ -117,6 +105,18 @@
 }
 
 /**
+ * タスクが実行する CPU を選択する
+ *
+ * 現在は CPU_PPE, CPU_SPE, SPE_ANY, SPE_0, SPE_1, ..., SPE_5
+ * types.h に書いてます。
+ */
+void
+TaskManagerImpl::set_task_cpu(HTaskPtr task, CPU_TYPE type)
+{
+    task->cpu_type = type;
+}
+
+/**
  * 終了したタスクから依存の処理とか
  * post_func() はこのタスクが終了したら実行する関数。
  *
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.h	Thu Oct 22 23:54:58 2009 +0900
@@ -41,12 +41,9 @@
 
     // user
     HTaskPtr create_task(int cmd);
-    HTaskPtr create_task(int cmd, void *read, int rsize, void *write, int wsize);
-
-    void spawn(HTaskPtr);
+    void set_task_depend(HTaskPtr master, HTaskPtr slave);
+    void spawn_task(HTaskPtr);
     void set_task_cpu(HTaskPtr, CPU_TYPE);
-    void *get_rbuf();
-    void *get_wbuf();
     virtual void* allocate(int size) = 0;
     virtual void* allocate(int size,int align) = 0;
     virtual Scheduler* get_scheduler() = 0;
--- a/TaskManager/kernel/schedule/SchedTask.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -10,6 +10,8 @@
 
 extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT];
 
+//#define NO_PIPELINE
+
 /**
    Task Object を作る
  */
@@ -52,6 +54,12 @@
     this->stderr_ = stderr;
     this->stdin_ = stdin;
 
+    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;
+
 }
 
 /**
@@ -59,19 +67,87 @@
  */
 SchedTask::~SchedTask()
 {
+    if (flag_renewTask == SCHED_TASK_RENEW) {
+        /**
+         * list != NULL の場合、
+         * この Task が list の最後の Task になるので (SchedTask::next 参照)
+         * このタイミングで list を解放する
+         *   (free に渡されるアドレスが正しいものとなる)。
+         * それ以外の Task では当然解放しない。
+         *  list == NULL なので、free に渡しても無問題
+         */
+        free(list);
+    }
+
+
 }
 
+/**
+ * このタスクを Renew Task とし、それに応じた関数をセットする
+ */
+void
+SchedTask::setRenew()
+{
+    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  = &_task->inData;
+    outListData = &_task->outData;
     scheduler   = sc;
     cur_index   = index;
+
     scheduler->mainMem_wait();
 
+    (this->*ex_init)();
+}
+
+/**
+ * PPE 内で生成されたタスクの ex_init()
+ */
+void
+SchedTask::ex_init_normal()
+{
+#if 0
+    // task list に入れたので既に読んでいる?
+    //
+    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
+#endif
+
+    taskGroup = new TaskGroup;
+    taskGroup->command = (int)task->self;
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_init()
+ * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので
+ * ex_init_normal() と違い、ここでは値を渡すだけ
+ */
+void
+SchedTask::ex_init_renew()
+{
+    inListData = &task->inData;
+    outListData = &task->outData;
+    taskGroup = (TaskGroupPtr)task->self;
 }
 
 void
@@ -79,39 +155,83 @@
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
+#if 0
+#if !defined(NO_PIPELINE)
+    scheduler->dma_wait(DMA_READ_IN_LIST);
+    scheduler->dma_wait(DMA_READ_OUT_LIST);
+#endif
+#endif
     // object creation をSchedTask生成時にやらないので、
     // exec の直前のread で十分に間に合う
-    // next task の load
-    loadSchedTask(scheduler, &list->tasks[cur_index]);
-    writebuf = scheduler->allocate(wsize);
+    if (cur_index < list->length) {
+	// load next task
+	loadSchedTask(scheduler, &list->tasks[cur_index]);
+    }
+
+    writebuf = scheduler->allocate(outListData->size);
 
     // 読むデータが一つもなければ無視
-    if (rsize == 0) return;
+    if (inListData->length == 0) return;
 
     // load Input Data
-    readbuf = scheduler->allocate(rsize);
-    read_tag = get_tag();
-    scheduler->dma_load(readbuf, rsize, read_tag);
+    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)();
 }
 
+/**
+ * PPE 内で生成されたタスクの ex_read()
+ *
+ * [Todo]
+ *   データの読み込み場所を readbuf ではなく、
+ *   ユーザ自身で決めれるようになるといいかもしれない。
+ *
+ *   # TaskManager が勝手に消すことなく、
+ *   # ユーザが SPE 上に持ち続けることができるため。
+ *   # もちろん管理はユーザに任せるわけだ。
+ */
+void
+SchedTask::ex_read_normal()
+{
+}
 
 void
 SchedTask::exec()
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
-    scheduler->dma_wait(read_tag);
+#if !defined(NO_PIPELINE)
+    scheduler->dma_wait(DMA_READ);
     task_list[task->command].wait(scheduler,task->command);
+#endif
+
     task_list[task->command].run(this, readbuf, writebuf);
 
     free(readbuf);
 
+    if (taskGroup->status() != 0) {
+        task->self = (int)taskGroup->command;
+        delete taskGroup;
+        taskGroup = NULL;
+    }
+
+
     // 書き込む領域がなければ無視
-    if (wsize->length > 0) {
-	write_tag = get_tag();
-        scheduler->dma_store(writebuf, wsize, write_tag);
+    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
@@ -119,27 +239,187 @@
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
-    scheduler->dma_wait(write_tag);
+#if !defined(NO_PIPELINE)
+    scheduler->dma_wait(DMA_WRITE);
     free(writebuf);
-    (*post_func)(this,0,0);
+#endif
+
+    if ((int)task->self == MY_SPE_NOP) return;
+
+    (this->*ex_write)();
+}
+
+
+/**
+ * SPE 内で生成されたタスクの ex_read()
+ */
+void
+SchedTask::ex_read_renew()
+{
+    writebuf = scheduler->allocate(outListData->size);
+}
+
+/**
+ * PPE 内で生成されたタスクの ex_exec()
+ */
+void
+SchedTask::ex_exec_normal()
+{
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_exec()
+ */
+void
+SchedTask::ex_exec_renew()
+{
 }
 
 
+
+/**
+ * PPE 内で生成されたタスクの ex_write()
+ *
+ * このタスク内で新たにタスクが生成され、
+ * 且つそのタスクの終了を待つ必要がある場合、
+ * PPE に終了したことは知らせない(command は送信しない)
+ */
+void
+SchedTask::ex_write_normal()
+{
+    /**
+     * このタスク内で新たにタスクが生成されなかった
+     * or 生成されたが、そのタスクの終了を待つ必要は無い
+     */
+    if (renew_flag == 0) {
+        scheduler->mail_write((int)task->self);
+    }
+}
+
+/**
+ * SPE 内で生成されたタスクの ex_write()
+ *
+ *  A <- 親タスク
+ *  | \
+ *  B   C <- SPE 内で生成されたタスク
+ *
+ * A は SPE 内で B, C を生成したとする。
+ * B と C が終了したら、A が PPE に送るはずだったコマンドが
+ * 子タスクに引き継がれているので、最後に実行された子タスクが
+ * PPE に mail 送信する。
+ */
+void
+SchedTask::ex_write_renew()
+{
+    uint32 cmd;
+
+    taskGroup->remove(task);
+    cmd = taskGroup->status();
+
+    // タスク内で作られた全てのタスクが終了した
+    if (cmd != 0) {
+        delete taskGroup;
+        scheduler->mail_write(cmd);
+    }
+}
+
 SchedTaskBase*
 SchedTask::next(Scheduler *scheduler, SchedTaskBase *p)
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
-    TaskPtr nextTask = (Task*)activeQueue.poll();
-    if (nextTask) {
-        SchedTask *nextSched = createSchedTask(scheduler, nextTask);
-	nextSched->init(list, nextTask, cur_index, scheduler);
-	return nextSched;
+    // delete p;  move to Scheduler
+
+    return (this->*ex_next)();
+}
+
+SchedTaskBase*
+SchedTask::ex_next_normal()
+{
+    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(scheduler, nextTask);
+            ((SchedTask*)nextSched)->init(list, nextTask, cur_index,
+                                              // scheduler->get_curReadBuf(),
+                                              // scheduler->get_curWriteBuf(),
+                                              scheduler);
+            return nextSched;
+        }
     } else {
-	return new SchedNop2Ready(scheduler);
+        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()
+{
+    TaskPtr nextTask;
+    SchedTask *nextSched;
+
+    if (cur_index < list->length) {
+        nextTask = &list->tasks[cur_index++];
+        nextSched = createSchedTask(scheduler, 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(scheduler, 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()
@@ -147,6 +427,68 @@
     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)
@@ -154,10 +496,23 @@
     return task->param[index];
 }
 
-HTaskPtr
+TaskPtr
 SchedTask::create_task(int cmd)
 {
-    HTaskPtr htask = scheduler->create_task(cmd);
+    TaskListPtr taskList = scheduler->get_renewListBuf();
+    TaskPtr p = &taskList->tasks[taskList->length++];
+    p->command = cmd;
+
+    // already allocated 
+    // p->inData = (ListData*)scheduler->allocate(sizeof(ListData));
+    // p->outData = (ListData*)scheduler->allocate(sizeof(ListData));
+
+    p->inData.clear();
+    p->outData.clear();
+
+    p->self = (int)MY_SPE_NOP;
+    p->param_size = 0;
+
     return p;
 }
 
@@ -166,9 +521,13 @@
  * @param[in] waitTask タスク内で生成したタスクの登録(spawn()に相当)
  */
 void
-SchedTask::spawn(HTaskPtr task)
+SchedTask::wait_task(TaskPtr waitTask)
 {
-    activeQueue.addFirst(task);
+    waitTask->self = (int)taskGroup;
+
+    scheduler->add_groupTask(taskGroup, waitTask);
+
+    renew_flag++;
 }
 
 void*
--- a/TaskManager/kernel/schedule/SchedTask.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.h	Thu Oct 22 23:54:58 2009 +0900
@@ -9,7 +9,6 @@
 #include "ListData.h"
 #include "TaskGroup.h"
 #include "MemList.h"
-#include "HTask.h"
 
 class SchedTask : public SchedTaskBase {
 public:
@@ -29,20 +28,41 @@
     TaskListPtr list;
     TaskPtr task;
 
+    // read/write 用の ListData
+    ListDataPtr inListData;
+    ListDataPtr outListData;
+
     /**
      * read データ、write 用のバッファ
      * readbuf には タスク登録時に設定した入力データが入っている。
      * writebuf にデータを描き込んでおくと、
      * タスク登録時に設定した出力先に書き込む
      */
-    int rsize;
     void *readbuf;
-    int wsize;
     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 (SchedTask::*ex_read)();
+    void (SchedTask::*ex_exec)();
+    void (SchedTask::*ex_write)();
+    SchedTaskBase* (SchedTask::*ex_next)();
+
     /* functions */
 
     // override
@@ -56,12 +76,30 @@
     //---  System API ---
     SchedTask* get_nextTask(TaskListPtr list);
 
+    /**
+     * PPE で生成されたタスクに対する
+     * init, read,exec,write,next の付属(?)処理
+     */
+    void ex_init_normal();
+    void ex_read_normal();
+    void ex_exec_normal();
+    void ex_write_normal();
+    SchedTaskBase* ex_next_normal();
+
+    /**
+     * SPE で生成されたタスクに対する
+     * inti, ead,exec,write,next の付属(?)処理
+     */
+    void ex_init_renew();
+    void ex_read_renew();
+    void ex_exec_renew();
+    void ex_write_renew();
+    SchedTaskBase* ex_next_renew();
 
 public:
     /* functions */
 
-    void spwan(HTask *task);
-
+    void setRenew();
     void init(TaskListPtr _list, TaskPtr _task, int index,
                     // ListDataPtr rbuf, ListDataPtr wbuf, 
 		    Scheduler* sc);
@@ -78,9 +116,9 @@
     int get_outputSize(int index);
     int get_param(int index);
 
-    void set_post(PostFunction func,void *read, void *write);
 
-    HTaskPtr create_task(int cmd);
+    TaskPtr create_task(int cmd);
+    void wait_task(TaskPtr waitTask);
 
     void* global_alloc(int id, int size);
     void* global_get(int id);
@@ -132,6 +170,8 @@
 
 };
 
+const int SCHED_TASK_NORMAL = 0;
+const int SCHED_TASK_RENEW  = 1;
 
 extern SchedTask* createSchedTask(Scheduler *,TaskPtr);
 extern void loadSchedTask(Scheduler *scheduler,TaskPtr task);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/schedule/SchedTaskManager.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -0,0 +1,49 @@
+
+#include "TaskManagerImpl.h"
+#include "SchedTaskManager.h"
+
+SchedTaskManager::SchedTaskManager(TaskManagerImpl *m_)
+{
+    m = m_;
+}
+
+SchedTaskManager::~SchedTaskManager()
+{
+}
+
+HTaskPtr SchedTaskManager::create_task(int cmd)
+{
+    return m->create_task(cmd);
+}
+
+void SchedTaskManager::set_task_depend(HTaskPtr master, HTaskPtr slave)
+{
+    m->set_task_depend(master, slave);
+}
+
+void SchedTaskManager::spawn_task(HTaskPtr t)
+{
+    m->spawn_task(t);
+}
+
+void SchedTaskManager::set_task_cpu(HTaskPtr t, CPU_TYPE cpu)
+{
+    m->set_task_cpu(t, cpu);
+}
+
+void* SchedTaskManager::allocate(int size) 
+{
+    return m->allocate(size) ;
+}
+
+void* SchedTaskManager::allocate(int size,int align) 
+{
+    return m->allocate(size,align) ;
+}
+
+Scheduler* SchedTaskManager::get_scheduler() 
+{
+    return m->get_scheduler() ;
+}
+
+/* end */
--- a/TaskManager/kernel/schedule/SchedTaskManager.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTaskManager.h	Thu Oct 22 23:54:58 2009 +0900
@@ -1,19 +1,36 @@
-#ifndef SchedTaskManager_H
-#define SchedTaskManager_H
+#ifndef INCLUDED_SCHED_TASK_MANAGER
+#define INCLUDED_SCHED_TASK_MANAGER
 
+#include <stdio.h>
+#include <stdlib.h>
+#include "base.h"
 #include "SchedTask.h"
 #include "TaskManagerImpl.h"
 
 class SchedTaskManager : public SchedTask {
+public:
+    /* constructor */
+    SchedTaskManager(TaskManagerImpl *m);
 
-public:
+    virtual ~SchedTaskManager();
 
-    TaskManagerImpl *manager;
+    BASE_NEW_DELETE(SchedTask);
+
+    /* variables */
 
-    SchedTaskManager(TaskManagerImpl *m) {
-	manager = m;
-    }
+    // Task を実行するスケジューラ自身
+    TaskManagerImpl *m;
+    
+public:
+    /* functions */
 
+    // user
+    HTaskPtr create_task(int cmd);
+    void set_task_depend(HTaskPtr master, HTaskPtr slave);
+    void spawn_task(HTaskPtr);
+    void set_task_cpu(HTaskPtr, CPU_TYPE);
+    void* allocate(int size);
+    void* allocate(int size,int align);
+    Scheduler* get_scheduler();
 };
-
-#endif 
+#endif
--- a/TaskManager/kernel/schedule/Scheduler.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -364,8 +364,8 @@
 static void
 wait_load(Scheduler *m, int task_id)
 {
+#if 0
     MemorySegment *s = task_list[task_id].segment;
-#if 0
     if (s)
 	fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data);
     else
--- a/TaskManager/kernel/sys_task/SysTask.h	Tue Oct 20 20:34:47 2009 +0900
+++ b/TaskManager/kernel/sys_task/SysTask.h	Thu Oct 22 23:54:58 2009 +0900
@@ -1,6 +1,6 @@
 #include "Scheduler.h"
 
-enum SysTask_ID {
+enum SysTask_ID{
     SYSTASK_START = MAX_USER_TASK,
     SYSTASK_FINISH,
 };
--- a/example/basic/main.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/example/basic/main.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -28,7 +28,7 @@
  * タスク終了後の data1, data2 の確認
  */
 void
-twice_result(SchedTask *s, void *a, void *b)
+twice_result(void *a)
 {
     int* data = (int*)a;
     print_data(data, length, "after");
@@ -90,7 +90,7 @@
     /*
      * set_post() で ppe task を渡せるようにしたい
      */
-    twice->set_post(twice_result, (void*)data, 0);
+    twice->set_post(twice_result, (void*)data);
 
     // add Active Queue
     twice->spawn();    
--- a/example/many_task/sort.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/example/many_task/sort.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -13,7 +13,7 @@
 static int last_half_block_num;
 static TaskManager *manager;
 
-static void sort_restart(SchedTask *s, void *, void *);
+static void sort_restart(void *);
 static void sort_start();
 
 /**
@@ -44,7 +44,7 @@
  * @param d 生成された btask の数
  */
 static void
-sort_restart(SchedTask *s, void *d, void *e)
+sort_restart(void *d)
 {
     static int cnt = 0;
     int max = (int)d;
@@ -111,7 +111,7 @@
 	for (int i = 0; i < half_num; i++) {
 	    bsort[i]->wait_for(fsort[i]);
 	    bsort[i]->wait_for(fsort[i+1]);
-	    bsort[i]->set_post(sort_restart, (void*)(half_num), 0);
+	    bsort[i]->set_post(sort_restart, (void*)(half_num));
 	    bsort[i]->spawn();
 	}
     }
--- a/example/post_function/main.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/example/post_function/main.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -13,8 +13,8 @@
 const char *usr_help_str = "Usage: ./post [-cpu spe_num] [-count N]\n\
   -count  Number of print \"Hello, World!!\"";
 
-static void
-func1(SchedTask *s, void *p, void *q)
+void
+func1(void *p)
 {
     int i = (int)p;
 
@@ -23,7 +23,7 @@
     if (i > 0) {
 	HTaskPtr next = manager->create_task(HELLO_TASK);
 	next->add_param(i);
-	next->set_post(func1, (void*)i, 0);
+	next->set_post(func1, (void*)i);
 	next->set_cpu(SPE_ANY);
 	next->spawn();    
     }
@@ -49,7 +49,7 @@
 
     task = manager->create_task(HELLO_TASK);
     task->add_param(count);
-    task->set_post(func1, (void*)count, 0);
+    task->set_post(func1, (void*)count);
     task->set_cpu(SPE_ANY);
     task->spawn();
 }
--- a/example/renew_task/main.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/example/renew_task/main.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -2,7 +2,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include "TaskManager.h"
-#include "SchedTask.h"
 #include "Func.h"
 
 extern void task_init();
@@ -15,17 +14,21 @@
 static int task_count = 1;
 
 static void
-renewRepeat(SchedTask *manager,void *arg, void *arg1)
+renewRepeat(void *arg)
 {
+    TaskManager *manager = (TaskManager *)arg;
+
     if (count-->0) {
 	HTask *repeat = manager->create_task(RENEW_REPEAT);
-	repeat->set_post(renewRepeat, 0, 0);
+	repeat->set_post(renewRepeat, (void*)manager);
 	repeat->spawn();
 
+	HTask *renew;
+
 	printf("[PPE] Create Task : RenewStart\n\n");
 
 	for(int i=0;i<task_count;i++) {
-	    HTask *renew = manager->create_task(RENEW_START);
+	    renew = manager->create_task(RENEW_START);
 	    renew->set_cpu(SPE_ANY);
 	    renew->add_param(i);
 	    renew->add_param((int)&task_count);
@@ -36,6 +39,12 @@
     }
 }
 
+static int
+run(SchedTask *s, void *rbuf, void *wbuf)
+{
+    // RewnewRepeat Task
+    return 0;
+}
 
 static int
 init(int argc, char **argv)
@@ -60,7 +69,7 @@
     printf("[PPE] Create Task : RenewRepeat\n\n");
 
     repeat = manager->create_task(RENEW_REPEAT);
-    repeat->set_post(renewRepeat, 0, 0);
+    repeat->set_post(renewRepeat, (void*)manager);
 
     // add Active Queue
     repeat->spawn();    
@@ -83,5 +92,3 @@
 
     return 0;
 }
-
-/* end */
--- a/example/renew_task/ppe/Renew1.cc	Tue Oct 20 20:34:47 2009 +0900
+++ b/example/renew_task/ppe/Renew1.cc	Thu Oct 22 23:54:58 2009 +0900
@@ -11,17 +11,8 @@
     s->printf("[PPE] ** running Renew1\n");
     
     s->printf("[PPE] Create Task : Renew2\n");
-#if 0
     TaskPtr nextTask = s->create_task(RENEW2);
     s->wait_task(nextTask);
-#endif
-#if 1
-    HTaskPtr nextTask = s->create_task(RENEW2);
-    nextTask->spawn();
-#endif
-#if 1
-    s->set_post(task_list[RENEW2].entry,0,0);
-#endif
     
     s->printf("[PPE] ** finish  Renew1\n");
     s->printf("\n");