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