Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/Scheduler.h @ 460:b0ca9e34f7f0
fix Scheduler.h
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 29 Sep 2009 11:51:25 +0900 |
parents | 95a856a2d552 |
children | 01b321c86747 |
rev | line source |
---|---|
42 | 1 #ifndef INCLUDED_SCHEDULER |
2 #define INCLUDED_SCHEDULER | |
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" |
373 | 11 #include "MemList.h" |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
12 #include "MemHash.h" |
109 | 13 |
14 #define MAX_USER_TASK 32 | |
15 #define MAX_SYSTEM_TASK 2 | |
16 #define MAX_TASK_OBJECT MAX_USER_TASK + MAX_SYSTEM_TASK | |
17 #define MAX_GLOBAL_AREA 32 | |
18 #define MAX_MAINMEM_AREA 32 | |
19 | |
42 | 20 class SchedTaskBase; |
109 | 21 class SchedTask; |
184 | 22 class SchedTaskList; |
42 | 23 |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
24 typedef SchedTask* (*TaskObjectCreator)(Scheduler *); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
25 |
42 | 26 class Scheduler { |
27 public: | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
28 virtual ~Scheduler(); |
109 | 29 |
30 BASE_NEW_DELETE(Scheduler); | |
42 | 31 |
32 /* variables */ | |
194 | 33 int id; |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
34 MemHash *hash; |
109 | 35 |
36 // double buffering | |
37 TaskListPtr buff_taskList[2]; | |
38 ListDataPtr buff_inListData[2]; | |
39 ListDataPtr buff_outListData[2]; | |
40 | |
41 int buffFlag_taskList; | |
42 int buffFlag_inListData; | |
43 int buffFlag_outListData; | |
44 | |
298 | 45 /* TaskList 関連 */ |
109 | 46 |
47 /** | |
298 | 48 * 実行中 TaskList の現在の位置 (list->tasks[index]) |
373 | 49 * |
298 | 50 * bakIndex_taskList がある理由 |
51 * taskList の途中で renew task が作られたとき、 | |
52 * 即座に実行するため、TaskList -> RenewTaskList と移って処理する。 | |
53 * RenewTaskList が終了したとき、再び TaskList に戻ってくるが | |
54 * Renew Task を生成した所から再スタートするため、 | |
55 * taskList の index を覚えておく (backup) | |
56 * 同様に TaskList も覚えておく | |
109 | 57 */ |
184 | 58 int bakIndex_taskList; |
59 TaskListPtr bak_curTaskList; | |
373 | 60 |
109 | 61 |
62 /** | |
298 | 63 * タスク内で生成されたタスクを入れる |
64 * Linked List で管理 | |
109 | 65 */ |
66 TaskListPtr renewCur_taskList; | |
67 TaskListPtr renewTop_taskList; | |
68 | |
69 /** | |
298 | 70 * 実行中 TaskList が Renew されたものかどうかのフラグ |
71 * Renew の場合、ListData は DMA する必要ないとか | |
72 * いろいろな判定に使えるかもしれん | |
109 | 73 * if (flag == 1) taskList is Renew |
74 */ | |
75 int flag_renewTaskList; | |
76 | |
77 /** | |
298 | 78 * タスク内 (T1) でタスク (Tc = T2, T3, ..) が複数生成された場合、 |
79 * Tc が全て終わってから、T1 の終了コマンドを PPE に送る。 | |
80 * なので、Tc を process group として記憶しておく。 | |
109 | 81 * |
298 | 82 * Tc が taskGroup のアドレスを持つので |
83 * Scheduler が持つ taskGroup 変数は一つだけで(多分)おk | |
109 | 84 */ |
85 TaskGroupPtr taskGroup; | |
86 | |
87 /* GlobalMemoryList */ | |
88 void* globalList[MAX_GLOBAL_AREA]; | |
89 | |
90 /* MainMemory Allocate Command List */ | |
91 void* mainMemList[MAX_MAINMEM_AREA]; | |
92 | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
93 /* Code Area */ |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
94 MemList *code_segment_pool; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
95 |
109 | 96 // Task Object Table |
291 | 97 // this is named TaskObject but it is not an object. |
98 // It is a pointer to an object creation function | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
99 // 大きいので、SPEには置かない方が本当は良い... |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
100 typedef struct { |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
101 TaskObjectCreator creator; |
441 | 102 memaddr location; // location address in a.out |
103 memaddr end; | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
104 uint32 entry_offset; // offset for create(); |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
105 MemorySegment *segment; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
106 void (*load)(Scheduler *,int); |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
107 void (*wait)(Scheduler *,int); |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
108 } TaskObject, *TaskObjectPtr; |
42 | 109 |
110 DmaManager* connector; | |
109 | 111 |
112 // Pipeline Stage | |
42 | 113 SchedTaskBase* task1; |
114 SchedTaskBase* task2; | |
115 SchedTaskBase* task3; | |
116 | |
117 /* functions */ | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
118 void init(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
119 void run(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
120 virtual void init_impl() {}; |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
121 void finish(); |
42 | 122 |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
123 TaskListPtr get_curListBuf(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
124 ListDataPtr get_curReadBuf(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
125 ListDataPtr get_curWriteBuf(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
126 TaskListPtr get_renewListBuf(); |
109 | 127 |
187 | 128 void set_backupTaskList(TaskListPtr cur_taskList); |
129 void set_backupTaskListIndex(int cur_index); | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
130 SchedTaskList* get_nextRenewTaskList(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
131 TaskListPtr get_backupTaskList(); |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
132 int get_backupTaskListIndex(); |
184 | 133 |
298 | 134 // なんか名前が変だが。。。 |
109 | 135 /* TaskGroup */ |
136 TaskGroupPtr set_groupTask(uint32 command); | |
137 void add_groupTask(TaskGroupPtr group, TaskPtr task); | |
138 void remove_groupTask(TaskGroupPtr group, TaskPtr task); | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
139 void reload_groupTask(); |
109 | 140 uint32 status_groupTask(TaskGroupPtr group); |
141 | |
142 /* GlobalMemory */ | |
143 void* global_alloc(int id, int size); | |
144 void* global_get(int id); | |
373 | 145 void global_set(int id, void *addr); |
109 | 146 void global_free(int id); |
373 | 147 MemList* createMemList(int size, int count); |
109 | 148 virtual void *allocate(int size) { return NULL; }; |
149 | |
150 virtual void mainMem_alloc(int id, int size) {}; | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
151 virtual void mainMem_wait() {}; |
109 | 152 void *mainMem_get(int id); |
153 | |
389 | 154 MemorySegment * get_segment(memaddr addr, MemList *m); |
437 | 155 MemorySegment * get_segment(memaddr addr, MemList *m, int size); |
442 | 156 void allocate_code_segment(int size, int count); |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
157 |
389 | 158 virtual uint32 get_tag(); |
159 void put_segment(MemorySegment *s); | |
160 void wait_segment(MemorySegment *s); | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
161 |
109 | 162 /* DMA Transfer */ |
163 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask); | |
164 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask); | |
165 void dma_wait(uint32 mask); | |
255 | 166 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
|
167 void show_dma_wait(int id) { connector->show_dma_wait(id); }; |
109 | 168 void mail_write(uint32 data); |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
169 uint32 mail_read(); |
109 | 170 void dma_loadList(ListDataPtr list, void *, uint32 mask); |
171 void dma_storeList(ListDataPtr list, void *, uint32 mask); | |
42 | 172 }; |
173 | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
174 extern void register_task(int cmd, TaskObjectCreator creator); |
430
fb62b7acc92b
code loading (on going...)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
426
diff
changeset
|
175 extern void register_dynamic_task(int cmd, |
441 | 176 memaddr start, int size, TaskObjectCreator creator, |
439 | 177 int entry_offset); |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
178 |
441 | 179 struct tbl { |
180 unsigned int vma; | |
181 unsigned int size; | |
182 unsigned int file_offset; | |
183 unsigned int buf; | |
184 }; | |
185 | |
42 | 186 #endif |
109 | 187 |
188 | |
373 | 189 #define SchedConstructor(str) \ |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
190 str() {} \ |
373 | 191 BASE_NEW_DELETE(str) \ |
109 | 192 |
373 | 193 #define SchedDefineTask(str) \ |
460 | 194 extern "C" { \ |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
195 SchedTask* createTask_##str(Scheduler *manager) \ |
373 | 196 { \ |
197 return new str(); \ | |
460 | 198 } \ |
109 | 199 } |
200 | |
373 | 201 #define SchedExternTask(str) \ |
460 | 202 extern "C" { \ |
203 extern SchedTask* createTask_##str(Scheduler *manager) ; \ | |
204 } | |
109 | 205 |
373 | 206 #define SchedRegisterTask(cmd, str) \ |
109 | 207 register_task(cmd, createTask_##str); |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
208 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
209 #define SchedDefineDynamicTask(str,segment) \ |
441 | 210 extern "C" { \ |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
211 SchedTask* createTask_##str(Scheduler *manager) \ |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
212 { \ |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
213 return new str(); \ |
441 | 214 } \ |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
215 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
216 |
437 | 217 #ifndef NO_OVERLAY |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
218 #define SchedExternDynamicTask(str,segment) \ |
441 | 219 extern "C" { \ |
220 extern unsigned long long _EAR_; \ | |
221 extern struct tbl _ovly_table[]; \ | |
222 extern SchedTask* createTask_##str(Scheduler *manager) ; \ | |
223 } | |
437 | 224 #else |
439 | 225 #define SchedExternDynamicTask(str,segment) SchedExternTask(str) |
437 | 226 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
227 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
228 |
437 | 229 #ifndef NO_OVERLAY |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
230 #define SchedRegisterDynamicTask(cmd, str, segment) \ |
441 | 231 register_dynamic_task(cmd, _EAR_+_ovly_table[segment].file_offset, \ |
232 _ovly_table[segment].size, \ | |
439 | 233 createTask_##str, \ |
441 | 234 createTask_##str##_offset); |
437 | 235 #else |
236 #define SchedRegisterDynamicTask(cmd, str, segment) SchedRegisterTask(cmd, str) | |
237 #endif | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
238 |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
239 |
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
389
diff
changeset
|
240 /* end */ |