Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/SchedTask.cc @ 603:42c94f85c779
long -> memaddr (64 or 32)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 07 Nov 2009 14:13:29 +0900 |
parents | 1733f3cbfa28 |
children | 0decff4e867b |
rev | line source |
---|---|
308 | 1 #include <stdlib.h> |
2 #include <string.h> | |
42 | 3 #include "SchedTask.h" |
308 | 4 #include "SchedTaskList.h" |
5 #include "SchedNop2Ready.h" | |
6 #include "DmaManager.h" | |
7 #include "error.h" | |
8 #include "TaskManager.h" | |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
9 #include <stdarg.h> |
180
5cde66c926b4
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
10 |
308 | 11 extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; |
12 | |
567 | 13 //#define NO_PIPELINE |
14 | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
15 /** |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
16 Task Object を作る |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
17 */ |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
18 |
439 | 19 |
308 | 20 SchedTask * |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
21 createSchedTask(Scheduler *scheduler, TaskPtr task) |
302 | 22 { |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
463
diff
changeset
|
23 return new SchedTask(); |
308 | 24 } |
25 | |
373 | 26 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
27 /** |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
28 code load を始める。既に get_segment hash に入っていれば何もしない。 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
29 最初の一回は SchedTaskList:: next から呼ばれる。 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
30 この段階では、SchedTask object は、まだ作られてない。 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
31 */ |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
32 void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
33 loadSchedTask(Scheduler *scheduler,TaskPtr task) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
34 { |
439 | 35 // fprintf(stderr,"loadSchedTask %d\n",task->command); |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
36 task_list[task->command].load(scheduler,task->command); |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
37 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
38 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
39 |
308 | 40 SchedTask::SchedTask() |
41 { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
42 list = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
43 task = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
44 inListData = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
45 outListData = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
46 readbuf = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
47 writebuf = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
48 scheduler = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
49 taskGroup = NULL; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
50 renew_flag = 0; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
51 cur_index = 0; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
52 flag_renewTask = SCHED_TASK_NORMAL; |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
53 this->stdout_ = stdout; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
54 this->stderr_ = stderr; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
55 this->stdin_ = stdin; |
373 | 56 |
567 | 57 ex_init = &SchedTask::ex_init_normal; |
58 ex_read = &SchedTask::ex_read_normal; | |
59 ex_exec = &SchedTask::ex_exec_normal; | |
60 ex_write = &SchedTask::ex_write_normal; | |
61 ex_next = &SchedTask::ex_next_normal; | |
62 | |
308 | 63 } |
64 | |
65 /** | |
66 * dma_store の wait を行う | |
67 */ | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
68 SchedTask::~SchedTask() |
308 | 69 { |
567 | 70 if (flag_renewTask == SCHED_TASK_RENEW) { |
71 /** | |
72 * list != NULL の場合、 | |
73 * この Task が list の最後の Task になるので (SchedTask::next 参照) | |
74 * このタイミングで list を解放する | |
75 * (free に渡されるアドレスが正しいものとなる)。 | |
76 * それ以外の Task では当然解放しない。 | |
77 * list == NULL なので、free に渡しても無問題 | |
78 */ | |
79 free(list); | |
80 } | |
81 | |
82 | |
308 | 83 } |
84 | |
567 | 85 /** |
86 * このタスクを Renew Task とし、それに応じた関数をセットする | |
87 */ | |
88 void | |
89 SchedTask::setRenew() | |
90 { | |
91 flag_renewTask = SCHED_TASK_RENEW; | |
92 | |
93 ex_init = &SchedTask::ex_init_renew; | |
94 ex_read = &SchedTask::ex_read_renew; | |
95 ex_exec = &SchedTask::ex_exec_renew; | |
96 ex_write = &SchedTask::ex_write_renew; | |
97 ex_next = &SchedTask::ex_next_renew; | |
98 } | |
308 | 99 |
100 void | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
101 SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, |
567 | 102 // ListDataPtr rbuf, ListDataPtr wbuf, |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
499
diff
changeset
|
103 Scheduler* sc) |
308 | 104 { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
105 list = _list; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
106 task = _task; |
567 | 107 inListData = &_task->inData; |
108 outListData = &_task->outData; | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
109 scheduler = sc; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
110 cur_index = index; |
567 | 111 |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
112 scheduler->mainMem_wait(); |
308 | 113 |
567 | 114 (this->*ex_init)(); |
115 } | |
116 | |
117 /** | |
118 * PPE 内で生成されたタスクの ex_init() | |
119 */ | |
120 void | |
121 SchedTask::ex_init_normal() | |
122 { | |
123 #if 0 | |
124 // task list に入れたので既に読んでいる? | |
125 // | |
126 scheduler->dma_load(inListData, (uint32)&task->inData, | |
127 sizeof(ListData), DMA_READ_IN_LIST); | |
128 scheduler->dma_load(outListData, (uint32)&task->outData, | |
129 sizeof(ListData), DMA_READ_OUT_LIST); | |
130 #if defined(NO_PIPELINE) | |
131 scheduler->dma_wait(DMA_READ_IN_LIST); | |
132 scheduler->dma_wait(DMA_READ_OUT_LIST); | |
133 #endif | |
134 #endif | |
135 | |
136 taskGroup = new TaskGroup; | |
137 taskGroup->command = (int)task->self; | |
138 } | |
139 | |
140 /** | |
141 * SPE 内で生成されたタスクの ex_init() | |
142 * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので | |
143 * ex_init_normal() と違い、ここでは値を渡すだけ | |
144 */ | |
145 void | |
146 SchedTask::ex_init_renew() | |
147 { | |
148 inListData = &task->inData; | |
149 outListData = &task->outData; | |
150 taskGroup = (TaskGroupPtr)task->self; | |
308 | 151 } |
152 | |
502
36b323130b1b
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
153 void |
36b323130b1b
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
154 SchedTask::read() |
36b323130b1b
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
155 { |
506 | 156 __debug("[SchedTask:%s]\n", __FUNCTION__); |
157 | |
567 | 158 #if 0 |
159 #if !defined(NO_PIPELINE) | |
160 scheduler->dma_wait(DMA_READ_IN_LIST); | |
161 scheduler->dma_wait(DMA_READ_OUT_LIST); | |
162 #endif | |
163 #endif | |
506 | 164 // object creation をSchedTask生成時にやらないので、 |
165 // exec の直前のread で十分に間に合う | |
567 | 166 if (cur_index < list->length) { |
167 // load next task | |
168 loadSchedTask(scheduler, &list->tasks[cur_index]); | |
169 } | |
170 | |
171 writebuf = scheduler->allocate(outListData->size); | |
506 | 172 |
173 // 読むデータが一つもなければ無視 | |
567 | 174 if (inListData->length == 0) return; |
506 | 175 |
176 // load Input Data | |
567 | 177 readbuf = scheduler->allocate(inListData->size); |
178 scheduler->dma_loadList(inListData, readbuf, DMA_READ); | |
506 | 179 |
567 | 180 #if defined(NO_PIPELINE) |
181 scheduler->dma_wait(DMA_READ); | |
182 #endif | |
183 | |
184 (this->*ex_read)(); | |
502
36b323130b1b
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
185 } |
36b323130b1b
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
186 |
567 | 187 /** |
188 * PPE 内で生成されたタスクの ex_read() | |
189 * | |
190 * [Todo] | |
191 * データの読み込み場所を readbuf ではなく、 | |
192 * ユーザ自身で決めれるようになるといいかもしれない。 | |
193 * | |
194 * # TaskManager が勝手に消すことなく、 | |
195 * # ユーザが SPE 上に持ち続けることができるため。 | |
196 * # もちろん管理はユーザに任せるわけだ。 | |
197 */ | |
198 void | |
199 SchedTask::ex_read_normal() | |
200 { | |
201 } | |
308 | 202 |
203 void | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
204 SchedTask::exec() |
308 | 205 { |
206 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
207 | |
567 | 208 #if !defined(NO_PIPELINE) |
209 scheduler->dma_wait(DMA_READ); | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
210 task_list[task->command].wait(scheduler,task->command); |
567 | 211 #endif |
212 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
213 task_list[task->command].run(this, readbuf, writebuf); |
308 | 214 |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
215 free(readbuf); |
308 | 216 |
567 | 217 if (taskGroup->status() != 0) { |
218 task->self = (int)taskGroup->command; | |
219 delete taskGroup; | |
220 taskGroup = NULL; | |
221 } | |
222 | |
223 | |
519 | 224 // 書き込む領域がなければ無視 |
567 | 225 if (outListData->length > 0) { |
226 scheduler->dma_storeList(outListData, writebuf, DMA_WRITE); | |
227 | |
228 #if defined(NO_PIPELINE) | |
229 scheduler->dma_wait(DMA_WRITE); | |
230 free(writebuf); | |
231 #endif | |
308 | 232 } |
567 | 233 |
234 (this->*ex_exec)(); | |
308 | 235 } |
236 | |
237 void | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
238 SchedTask::write() |
308 | 239 { |
240 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
373 | 241 |
567 | 242 #if !defined(NO_PIPELINE) |
243 scheduler->dma_wait(DMA_WRITE); | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
244 free(writebuf); |
567 | 245 #endif |
246 | |
247 if ((int)task->self == MY_SPE_NOP) return; | |
248 | |
249 (this->*ex_write)(); | |
250 } | |
251 | |
252 | |
253 /** | |
254 * SPE 内で生成されたタスクの ex_read() | |
255 */ | |
256 void | |
257 SchedTask::ex_read_renew() | |
258 { | |
259 writebuf = scheduler->allocate(outListData->size); | |
260 } | |
261 | |
262 /** | |
263 * PPE 内で生成されたタスクの ex_exec() | |
264 */ | |
265 void | |
266 SchedTask::ex_exec_normal() | |
267 { | |
268 } | |
269 | |
270 /** | |
271 * SPE 内で生成されたタスクの ex_exec() | |
272 */ | |
273 void | |
274 SchedTask::ex_exec_renew() | |
275 { | |
308 | 276 } |
277 | |
278 | |
567 | 279 |
280 /** | |
281 * PPE 内で生成されたタスクの ex_write() | |
282 * | |
283 * このタスク内で新たにタスクが生成され、 | |
284 * 且つそのタスクの終了を待つ必要がある場合、 | |
285 * PPE に終了したことは知らせない(command は送信しない) | |
286 */ | |
287 void | |
288 SchedTask::ex_write_normal() | |
289 { | |
290 /** | |
291 * このタスク内で新たにタスクが生成されなかった | |
292 * or 生成されたが、そのタスクの終了を待つ必要は無い | |
293 */ | |
294 if (renew_flag == 0) { | |
295 scheduler->mail_write((int)task->self); | |
296 } | |
297 } | |
298 | |
299 /** | |
300 * SPE 内で生成されたタスクの ex_write() | |
301 * | |
302 * A <- 親タスク | |
303 * | \ | |
304 * B C <- SPE 内で生成されたタスク | |
305 * | |
306 * A は SPE 内で B, C を生成したとする。 | |
307 * B と C が終了したら、A が PPE に送るはずだったコマンドが | |
308 * 子タスクに引き継がれているので、最後に実行された子タスクが | |
309 * PPE に mail 送信する。 | |
310 */ | |
311 void | |
312 SchedTask::ex_write_renew() | |
313 { | |
314 uint32 cmd; | |
315 | |
316 taskGroup->remove(task); | |
317 cmd = taskGroup->status(); | |
318 | |
319 // タスク内で作られた全てのタスクが終了した | |
320 if (cmd != 0) { | |
321 delete taskGroup; | |
322 scheduler->mail_write(cmd); | |
323 } | |
324 } | |
325 | |
308 | 326 SchedTaskBase* |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
327 SchedTask::next(Scheduler *scheduler, SchedTaskBase *p) |
308 | 328 { |
329 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
330 | |
567 | 331 // delete p; move to Scheduler |
332 | |
333 return (this->*ex_next)(); | |
334 } | |
335 | |
336 SchedTaskBase* | |
337 SchedTask::ex_next_normal() | |
338 { | |
339 if (cur_index < list->length) { | |
340 SchedTaskBase *nextSched; | |
341 | |
342 nextSched = scheduler->get_nextRenewTaskList(); | |
343 | |
344 // RenewTask がある | |
345 if (nextSched) { | |
346 scheduler->set_backupTaskList(list); | |
347 scheduler->set_backupTaskListIndex(cur_index); | |
348 return nextSched; | |
349 } else { | |
350 TaskPtr nextTask = &list->tasks[cur_index++]; | |
351 nextSched = createSchedTask(scheduler, nextTask); | |
352 ((SchedTask*)nextSched)->init(list, nextTask, cur_index, | |
353 // scheduler->get_curReadBuf(), | |
354 // scheduler->get_curWriteBuf(), | |
355 scheduler); | |
356 return nextSched; | |
357 } | |
308 | 358 } else { |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
359 memaddr nextList = (memaddr)list->next; |
567 | 360 |
361 if (nextList == 0) { | |
362 return new SchedNop2Ready(scheduler); | |
363 } else { | |
364 return createSchedTaskList(nextList, scheduler, | |
365 SCHED_TASKLIST_NORMAL); | |
366 } | |
308 | 367 } |
368 } | |
369 | |
567 | 370 /** |
371 * | |
372 */ | |
373 SchedTaskBase* | |
374 SchedTask::ex_next_renew() | |
375 { | |
376 TaskPtr nextTask; | |
377 SchedTask *nextSched; | |
378 | |
379 if (cur_index < list->length) { | |
380 nextTask = &list->tasks[cur_index++]; | |
381 nextSched = createSchedTask(scheduler, nextTask); | |
382 | |
383 // RenewTaskList を実行中なので | |
384 nextSched->setRenew(); | |
385 nextSched->init(list, nextTask, cur_index, | |
386 // scheduler->get_curReadBuf(), | |
387 // scheduler->get_curWriteBuf(), | |
388 scheduler); | |
389 | |
390 /** | |
391 * この理由は SchedTask:~SchedTask() で | |
392 */ | |
393 list = NULL; | |
394 return nextSched; | |
395 } else { | |
396 SchedTaskBase *nextList; | |
397 | |
398 nextList = scheduler->get_nextRenewTaskList(); | |
399 | |
400 if (nextList) { | |
401 return nextList; | |
402 } else { | |
403 TaskListPtr nextList = scheduler->get_backupTaskList(); | |
404 | |
405 // 中断した TaskList がある | |
406 if (nextList) { | |
407 cur_index = scheduler->get_backupTaskListIndex(); | |
408 | |
409 nextTask = &nextList->tasks[cur_index++]; | |
410 nextSched = createSchedTask(scheduler, nextTask); | |
411 | |
412 nextSched->init(nextList, nextTask, cur_index, | |
413 // scheduler->get_curReadBuf(), | |
414 // scheduler->get_curWriteBuf(), | |
415 scheduler); | |
416 return nextSched; | |
417 } else { | |
418 return new SchedNop2Ready(scheduler); | |
419 } | |
420 } | |
421 } | |
422 } | |
308 | 423 |
424 int | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
425 SchedTask::get_cpuid() |
308 | 426 { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
427 return scheduler->id; |
308 | 428 } |
429 | |
567 | 430 /** |
431 * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 | |
432 * buffer から対応するデータを返す。 | |
433 */ | |
434 void* | |
435 SchedTask::get_input(void *buff, int index) | |
436 { | |
437 if (buff != NULL) { | |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
438 return (void*)((memaddr)buff + inListData->bound[index]); |
567 | 439 } else { |
440 return NULL; | |
441 } | |
442 } | |
443 | |
444 /** | |
445 * get_input(index) のアドレスを返す | |
446 */ | |
447 uint32 | |
448 SchedTask::get_inputAddr(int index) | |
449 { | |
450 return inListData->element[index].addr; | |
451 } | |
452 | |
453 /** | |
454 * get_input(index) のサイズを返す | |
455 */ | |
456 int | |
457 SchedTask::get_inputSize(int index) | |
458 { | |
459 return inListData->element[index].size; | |
460 } | |
461 | |
462 /** | |
463 * write buffer の領域を返す。 | |
464 */ | |
465 void* | |
466 SchedTask::get_output(void *buff, int index) | |
467 { | |
468 if (buff != NULL) { | |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
469 return (void*)((memaddr)buff + outListData->bound[index]); |
567 | 470 } else { |
471 return NULL; | |
472 } | |
473 } | |
474 | |
475 /** | |
476 * get_output(index) のアドレスを返す | |
477 */ | |
478 uint32 | |
479 SchedTask::get_outputAddr(int index) | |
480 { | |
481 return outListData->element[index].addr; | |
482 } | |
483 | |
484 /** | |
485 * get_output(index) のサイズを返す | |
486 */ | |
487 int | |
488 SchedTask::get_outputSize(int index) | |
489 { | |
490 return outListData->element[index].size; | |
491 } | |
308 | 492 |
493 int | |
494 SchedTask::get_param(int index) | |
495 { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
496 return task->param[index]; |
308 | 497 } |
498 | |
567 | 499 TaskPtr |
308 | 500 SchedTask::create_task(int cmd) |
501 { | |
567 | 502 TaskListPtr taskList = scheduler->get_renewListBuf(); |
503 TaskPtr p = &taskList->tasks[taskList->length++]; | |
504 p->command = cmd; | |
505 | |
506 // already allocated | |
507 // p->inData = (ListData*)scheduler->allocate(sizeof(ListData)); | |
508 // p->outData = (ListData*)scheduler->allocate(sizeof(ListData)); | |
509 | |
510 p->inData.clear(); | |
511 p->outData.clear(); | |
512 | |
513 p->self = (int)MY_SPE_NOP; | |
514 p->param_size = 0; | |
515 | |
308 | 516 return p; |
517 } | |
518 | |
519 /** | |
520 * | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
521 * @param[in] waitTask タスク内で生成したタスクの登録(spawn()に相当) |
308 | 522 */ |
523 void | |
567 | 524 SchedTask::wait_task(TaskPtr waitTask) |
308 | 525 { |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
526 waitTask->self = (memaddr)taskGroup; |
567 | 527 |
528 scheduler->add_groupTask(taskGroup, waitTask); | |
529 | |
530 renew_flag++; | |
308 | 531 } |
532 | |
533 void* | |
534 SchedTask::global_alloc(int id, int size) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
535 return scheduler->global_alloc(id, size); |
308 | 536 } |
537 | |
538 void* | |
539 SchedTask::global_get(int id) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
540 return scheduler->global_get(id); |
308 | 541 } |
542 | |
543 void | |
373 | 544 SchedTask::global_set(int id, void *addr) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
545 scheduler->global_set(id, addr); |
373 | 546 } |
547 | |
548 void | |
308 | 549 SchedTask::global_free(int id) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
550 scheduler->global_free(id); |
308 | 551 } |
552 | |
373 | 553 MemList* |
554 SchedTask::createMemList(int size, int count) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
555 return scheduler->createMemList(size, count); |
373 | 556 } |
557 | |
308 | 558 void |
559 SchedTask::mainMem_alloc(int id, int size) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
560 scheduler->mainMem_alloc(id, size); |
308 | 561 } |
562 | |
563 void | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
564 SchedTask::mainMem_wait() { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
565 scheduler->mainMem_wait(); |
308 | 566 } |
567 | |
568 void* | |
569 SchedTask::mainMem_get(int id) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
570 return scheduler->mainMem_get(id); |
308 | 571 } |
572 | |
573 void* | |
574 SchedTask::allocate(int size) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
575 return scheduler->allocate(size); |
308 | 576 } |
577 | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
578 |
308 | 579 void |
580 SchedTask::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
581 scheduler->dma_load(buf, addr, size, mask); |
308 | 582 } |
583 | |
584 void | |
585 SchedTask::dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
586 scheduler->dma_store(buf, addr, size, mask); |
308 | 587 } |
588 | |
589 void | |
590 SchedTask::dma_wait(uint32 mask) { | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
591 scheduler->dma_wait(mask); |
308 | 592 } |
593 | |
334
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
594 void |
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
595 SchedTask::show_dma_wait() { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
596 scheduler->show_dma_wait(); |
334
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
597 } |
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
598 |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
599 MemorySegment * SchedTask::get_segment(memaddr addr, MemList *m) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
600 return scheduler->get_segment(addr,m); |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
601 } |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
602 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
603 void SchedTask::put_segment(MemorySegment *s) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
604 scheduler->put_segment(s); |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
605 } |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
606 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
607 void SchedTask::wait_segment(MemorySegment *s) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
608 scheduler->wait_segment(s); |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
609 } |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
610 |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
611 /* system call */ |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
612 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
613 int |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
614 SchedTask::fprintf(FILE * stream, const char * format, ...) |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
615 { |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
616 va_list ap; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
617 va_start(ap,format); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
618 int ret = vfprintf(stream,format, ap); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
619 va_end(ap); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
620 return ret; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
621 } |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
622 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
623 int |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
624 SchedTask::printf(const char * format, ...) |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
625 { |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
626 va_list ap; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
627 va_start(ap,format); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
628 int ret= vfprintf(stdout,format, ap); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
629 va_end(ap); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
630 return ret; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
631 } |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
632 |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
633 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
634 |
308 | 635 /* end */ |