annotate include/TaskManager/Scheduler.h @ 347:ee3db22c03b9

error in SceneGraph.[cpp,h]
author e065746@localhost.localdomain
date Wed, 08 Jul 2009 15:04:03 +0900
parents 20f2459041cb
children b89ba1d96fff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
1 #ifndef INCLUDED_SCHEDULER
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
2 #define INCLUDED_SCHEDULER
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
3
301
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
4 #include "base.h"
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
5 #include "TaskList.h"
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
6 #include "ListData.h"
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
7 #include "DmaManager.h"
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
8 #include "SchedTaskBase.h"
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
9 #include "SchedTaskList.h"
bcb81858aa62 remove deprecated source. not work.
tkaito@localhost.localdomain
parents: 298
diff changeset
10 #include "TaskGroup.h"
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
11
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
12
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
13 #define MAX_USER_TASK 32
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
14 #define MAX_SYSTEM_TASK 2
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
15 #define MAX_TASK_OBJECT MAX_USER_TASK + MAX_SYSTEM_TASK
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
16 #define MAX_GLOBAL_AREA 32
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
17 #define MAX_MAINMEM_AREA 32
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
18
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
19 class SchedTaskBase;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
20 class SchedTask;
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
21 class SchedTaskList;
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
22
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
23 class Scheduler {
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
24 public:
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
25 virtual ~Scheduler(void);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
26
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
27 BASE_NEW_DELETE(Scheduler);
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
28
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
29 /* variables */
194
gongo@localhost.localdomain
parents: 187
diff changeset
30 int id;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
31
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
32 // double buffering
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
33 TaskListPtr buff_taskList[2];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
34 ListDataPtr buff_inListData[2];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
35 ListDataPtr buff_outListData[2];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
36
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
37 int buffFlag_taskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
38 int buffFlag_inListData;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
39 int buffFlag_outListData;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
40
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
41 /* TaskList 関連 */
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
42
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
43 /**
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
44 * 実行中 TaskList の現在の位置 (list->tasks[index])
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
45 *
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
46 * bakIndex_taskList がある理由
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
47 * taskList の途中で renew task が作られたとき、
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
48 * 即座に実行するため、TaskList -> RenewTaskList と移って処理する。
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
49 * RenewTaskList が終了したとき、再び TaskList に戻ってくるが
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
50 * Renew Task を生成した所から再スタートするため、
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
51 * taskList の index を覚えておく (backup)
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
52 * 同様に TaskList も覚えておく
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
53 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
54 int bakIndex_taskList;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
55 TaskListPtr bak_curTaskList;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
56
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
57
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
58 /**
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
59 * タスク内で生成されたタスクを入れる
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
60 * Linked List で管理
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
61 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
62 TaskListPtr renewCur_taskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
63 TaskListPtr renewTop_taskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
64
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
65 /**
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
66 * 実行中 TaskList が Renew されたものかどうかのフラグ
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
67 * Renew の場合、ListData は DMA する必要ないとか
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
68 * いろいろな判定に使えるかもしれん
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
69 * if (flag == 1) taskList is Renew
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
70 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
71 int flag_renewTaskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
72
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
73 /**
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
74 * タスク内 (T1) でタスク (Tc = T2, T3, ..) が複数生成された場合、
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
75 * Tc が全て終わってから、T1 の終了コマンドを PPE に送る。
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
76 * なので、Tc を process group として記憶しておく。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
77 *
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
78 * Tc が taskGroup のアドレスを持つので
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
79 * Scheduler が持つ taskGroup 変数は一つだけで(多分)おk
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
80 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
81 TaskGroupPtr taskGroup;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
82
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
83 /* GlobalMemoryList */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
84 void* globalList[MAX_GLOBAL_AREA];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
85
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
86 /* MainMemory Allocate Command List */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
87 void* mainMemList[MAX_MAINMEM_AREA];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
88
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
89 // Task Object Table
291
3569d31705b6 document
kono@localhost.localdomain
parents: 255
diff changeset
90 // this is named TaskObject but it is not an object.
3569d31705b6 document
kono@localhost.localdomain
parents: 255
diff changeset
91 // It is a pointer to an object creation function
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
92 typedef SchedTask* (*TaskObject)(void);
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
93
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
94 DmaManager* connector;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
95
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
96 // Pipeline Stage
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
97 SchedTaskBase* task1;
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
98 SchedTaskBase* task2;
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
99 SchedTaskBase* task3;
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
100
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
101 /* functions */
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
102 void init(void);
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
103 void run(void);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
104 virtual void init_impl(void) {};
50
7927e00fb8e2 *** empty log message ***
gongo
parents: 42
diff changeset
105 void finish(void);
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
106
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
107 TaskListPtr get_curListBuf(void);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
108 ListDataPtr get_curReadBuf(void);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
109 ListDataPtr get_curWriteBuf(void);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
110 TaskListPtr get_renewListBuf(void);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
111
187
gongo@localhost.localdomain
parents: 184
diff changeset
112 void set_backupTaskList(TaskListPtr cur_taskList);
gongo@localhost.localdomain
parents: 184
diff changeset
113 void set_backupTaskListIndex(int cur_index);
gongo@localhost.localdomain
parents: 184
diff changeset
114 SchedTaskList* get_nextRenewTaskList(void);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
115 TaskListPtr get_backupTaskList(void);
187
gongo@localhost.localdomain
parents: 184
diff changeset
116 int get_backupTaskListIndex(void);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
117
298
58fd16298954 from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 291
diff changeset
118 // なんか名前が変だが。。。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
119 /* TaskGroup */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
120 TaskGroupPtr set_groupTask(uint32 command);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
121 void add_groupTask(TaskGroupPtr group, TaskPtr task);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
122 void remove_groupTask(TaskGroupPtr group, TaskPtr task);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
123 void reload_groupTask(void);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
124 uint32 status_groupTask(TaskGroupPtr group);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
125
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
126 /* GlobalMemory */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
127 void* global_alloc(int id, int size);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
128 void* global_get(int id);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
129 void global_free(int id);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
130
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
131 virtual void *allocate(int size) { return NULL; };
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
132
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
133 virtual void mainMem_alloc(int id, int size) {};
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
134 virtual void mainMem_wait(void) {};
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
135 void *mainMem_get(int id);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
136
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
137 /* DMA Transfer */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
138 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
139 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
140 void dma_wait(uint32 mask);
255
6bb8725e60ae show dma wait
tkaito@localhost.localdomain
parents: 194
diff changeset
141 void show_dma_wait() { connector->show_dma_wait(id); };
334
20f2459041cb [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 302
diff changeset
142 void show_dma_wait(int id) { connector->show_dma_wait(id); };
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
143 void mail_write(uint32 data);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
144 uint32 mail_read(void);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
145 void dma_loadList(ListDataPtr list, void *, uint32 mask);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
146 void dma_storeList(ListDataPtr list, void *, uint32 mask);
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
147 };
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
148
302
b0d37afab06a working on macosx
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 301
diff changeset
149 extern void register_task(int cmd, Scheduler::TaskObject task);
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
150 #endif
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
151
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
152
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
153 #define SchedConstructor(str) \
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
154 str(void) {} \
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
155 BASE_NEW_DELETE(str) \
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
156
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
157 #define SchedDefineTask(str) \
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
158 SchedTask* createTask_##str(void) \
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
159 { \
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
160 return new str(); \
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
161 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
162
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
163 #define SchedExternTask(str) \
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
164 extern \
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 109
diff changeset
165 SchedTask* createTask_##str(void);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
166
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
167 #define SchedRegisterTask(cmd, str) \
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 70
diff changeset
168 register_task(cmd, createTask_##str);