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