Mercurial > hg > Game > Cerium
comparison TaskManager/kernel/schedule/SchedTask.cc @ 483:5f4ffff2c2aa draft
renew task worked. but not test_nogl...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 05 Oct 2009 20:29:28 +0900 |
parents | 796f72cb21d9 |
children | 3429986b8a28 |
comparison
equal
deleted
inserted
replaced
482:314031ecd723 | 483:5f4ffff2c2aa |
---|---|
37 } | 37 } |
38 | 38 |
39 | 39 |
40 SchedTask::SchedTask() | 40 SchedTask::SchedTask() |
41 { | 41 { |
42 __list = NULL; | 42 list = NULL; |
43 __task = NULL; | 43 task = NULL; |
44 __inListData = NULL; | 44 inListData = NULL; |
45 __outListData = NULL; | 45 outListData = NULL; |
46 __readbuf = NULL; | 46 readbuf = NULL; |
47 __writebuf = NULL; | 47 writebuf = NULL; |
48 __scheduler = NULL; | 48 scheduler = NULL; |
49 __taskGroup = NULL; | 49 taskGroup = NULL; |
50 __renew_flag = 0; | 50 renew_flag = 0; |
51 __cur_index = 0; | 51 cur_index = 0; |
52 __flag_renewTask = SCHED_TASK_NORMAL; | 52 flag_renewTask = SCHED_TASK_NORMAL; |
53 this->stdout_ = stdout; | 53 this->stdout_ = stdout; |
54 this->stderr_ = stderr; | 54 this->stderr_ = stderr; |
55 this->stdin_ = stdin; | 55 this->stdin_ = stdin; |
56 | 56 |
57 ex_init = &SchedTask::ex_init_normal; | 57 ex_init = &SchedTask::ex_init_normal; |
63 } | 63 } |
64 | 64 |
65 /** | 65 /** |
66 * dma_store の wait を行う | 66 * dma_store の wait を行う |
67 * このタスクが RenewTask だった場合、 | 67 * このタスクが RenewTask だった場合、 |
68 * __inListData や __outListData は | 68 * inListData や outListData は |
69 * Scheduler の持つ、使い回しの buffer ではなく | 69 * Scheduler の持つ、使い回しの buffer ではなく |
70 * 新たに allocate されたものなので、ここで free する | 70 * 新たに allocate されたものなので、ここで free する |
71 */ | 71 */ |
72 SchedTask::~SchedTask() | 72 SchedTask::~SchedTask() |
73 { | 73 { |
74 if (__flag_renewTask == SCHED_TASK_RENEW) { | 74 if (flag_renewTask == SCHED_TASK_RENEW) { |
75 free(__inListData); | 75 free(inListData); |
76 free(__outListData); | 76 free(outListData); |
77 | 77 |
78 /** | 78 /** |
79 * __list != NULL の場合、 | 79 * list != NULL の場合、 |
80 * この Task が __list の最後の Task になるので (SchedTask::next 参照) | 80 * この Task が list の最後の Task になるので (SchedTask::next 参照) |
81 * このタイミングで __list を解放する | 81 * このタイミングで list を解放する |
82 * (free に渡されるアドレスが正しいものとなる)。 | 82 * (free に渡されるアドレスが正しいものとなる)。 |
83 * それ以外の Task では当然解放しない。 | 83 * それ以外の Task では当然解放しない。 |
84 * __list == NULL なので、free に渡しても無問題 | 84 * list == NULL なので、free に渡しても無問題 |
85 */ | 85 */ |
86 free(__list); | 86 free(list); |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 } | 90 } |
91 | 91 |
92 /** | 92 /** |
93 * このタスクを Renew Task とし、それに応じた関数をセットする | 93 * このタスクを Renew Task とし、それに応じた関数をセットする |
94 */ | 94 */ |
95 void | 95 void |
96 SchedTask::__setRenew() | 96 SchedTask::setRenew() |
97 { | 97 { |
98 __flag_renewTask = SCHED_TASK_RENEW; | 98 flag_renewTask = SCHED_TASK_RENEW; |
99 | 99 |
100 ex_init = &SchedTask::ex_init_renew; | 100 ex_init = &SchedTask::ex_init_renew; |
101 ex_read = &SchedTask::ex_read_renew; | 101 ex_read = &SchedTask::ex_read_renew; |
102 ex_exec = &SchedTask::ex_exec_renew; | 102 ex_exec = &SchedTask::ex_exec_renew; |
103 ex_write = &SchedTask::ex_write_renew; | 103 ex_write = &SchedTask::ex_write_renew; |
104 ex_next = &SchedTask::ex_next_renew; | 104 ex_next = &SchedTask::ex_next_renew; |
105 } | 105 } |
106 | 106 |
107 void | 107 void |
108 SchedTask::__init__(TaskListPtr _list, TaskPtr _task, int index, | 108 SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, |
109 ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc) | 109 ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc) |
110 { | 110 { |
111 __list = _list; | 111 list = _list; |
112 __task = _task; | 112 task = _task; |
113 __inListData = rbuf; | 113 inListData = rbuf; |
114 __outListData = wbuf; | 114 outListData = wbuf; |
115 __scheduler = sc; | 115 scheduler = sc; |
116 __cur_index = index; | 116 cur_index = index; |
117 | 117 |
118 __scheduler->mainMem_wait(); | 118 scheduler->mainMem_wait(); |
119 | 119 |
120 (this->*ex_init)(); | 120 (this->*ex_init)(); |
121 } | 121 } |
122 | 122 |
123 /** | 123 /** |
124 * PPE 内で生成されたタスクの ex_init() | 124 * PPE 内で生成されたタスクの ex_init() |
125 */ | 125 */ |
126 void | 126 void |
127 SchedTask::ex_init_normal() | 127 SchedTask::ex_init_normal() |
128 { | 128 { |
129 __scheduler->dma_load(__inListData, (uint32)__task->inData, | 129 scheduler->dma_load(inListData, (uint32)task->inData, |
130 sizeof(ListData), DMA_READ_IN_LIST); | 130 sizeof(ListData), DMA_READ_IN_LIST); |
131 __scheduler->dma_load(__outListData, (uint32)__task->outData, | 131 scheduler->dma_load(outListData, (uint32)task->outData, |
132 sizeof(ListData), DMA_READ_OUT_LIST); | 132 sizeof(ListData), DMA_READ_OUT_LIST); |
133 #if defined(NO_PIPELINE) | 133 #if defined(NO_PIPELINE) |
134 __scheduler->dma_wait(DMA_READ_IN_LIST); | 134 scheduler->dma_wait(DMA_READ_IN_LIST); |
135 __scheduler->dma_wait(DMA_READ_OUT_LIST); | 135 scheduler->dma_wait(DMA_READ_OUT_LIST); |
136 #endif | 136 #endif |
137 | 137 |
138 __taskGroup = new TaskGroup; | 138 taskGroup = new TaskGroup; |
139 __taskGroup->command = __task->self; | 139 taskGroup->command = task->self; |
140 } | 140 } |
141 | 141 |
142 /** | 142 /** |
143 * SPE 内で生成されたタスクの ex_init() | 143 * SPE 内で生成されたタスクの ex_init() |
144 * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので | 144 * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので |
145 * ex_init_normal() と違い、ここでは値を渡すだけ | 145 * ex_init_normal() と違い、ここでは値を渡すだけ |
146 */ | 146 */ |
147 void | 147 void |
148 SchedTask::ex_init_renew() | 148 SchedTask::ex_init_renew() |
149 { | 149 { |
150 __inListData = __task->inData; | 150 inListData = task->inData; |
151 __outListData = __task->outData; | 151 outListData = task->outData; |
152 __taskGroup = (TaskGroupPtr)__task->self; | 152 taskGroup = (TaskGroupPtr)task->self; |
153 } | 153 } |
154 | 154 |
155 /** | 155 /** |
156 * [Todo] | 156 * [Todo] |
157 * データの読み込み場所を readbuf ではなく、 | 157 * データの読み込み場所を readbuf ではなく、 |
165 SchedTask::read() | 165 SchedTask::read() |
166 { | 166 { |
167 __debug("[SchedTask:%s]\n", __FUNCTION__); | 167 __debug("[SchedTask:%s]\n", __FUNCTION__); |
168 | 168 |
169 #if !defined(NO_PIPELINE) | 169 #if !defined(NO_PIPELINE) |
170 __scheduler->dma_wait(DMA_READ_IN_LIST); | 170 scheduler->dma_wait(DMA_READ_IN_LIST); |
171 __scheduler->dma_wait(DMA_READ_OUT_LIST); | 171 scheduler->dma_wait(DMA_READ_OUT_LIST); |
172 #endif | 172 #endif |
173 | 173 |
174 __writebuf = __scheduler->allocate(__outListData->size); | 174 writebuf = scheduler->allocate(outListData->size); |
175 | 175 |
176 // 読むデータが一つもなければ無視 | 176 // 読むデータが一つもなければ無視 |
177 if (__inListData->length == 0) return; | 177 if (inListData->length == 0) return; |
178 | 178 |
179 // load Input Data | 179 // load Input Data |
180 __readbuf = __scheduler->allocate(__inListData->size); | 180 readbuf = scheduler->allocate(inListData->size); |
181 __scheduler->dma_loadList(__inListData, __readbuf, DMA_READ); | 181 scheduler->dma_loadList(inListData, readbuf, DMA_READ); |
182 | 182 |
183 #if defined(NO_PIPELINE) | 183 #if defined(NO_PIPELINE) |
184 __scheduler->dma_wait(DMA_READ); | 184 scheduler->dma_wait(DMA_READ); |
185 #endif | 185 #endif |
186 | 186 |
187 (this->*ex_read)(); | 187 (this->*ex_read)(); |
188 } | 188 } |
189 | 189 |
191 SchedTask::exec() | 191 SchedTask::exec() |
192 { | 192 { |
193 __debug("[SchedTask:%s]\n", __FUNCTION__); | 193 __debug("[SchedTask:%s]\n", __FUNCTION__); |
194 | 194 |
195 #if !defined(NO_PIPELINE) | 195 #if !defined(NO_PIPELINE) |
196 __scheduler->dma_wait(DMA_READ); | 196 scheduler->dma_wait(DMA_READ); |
197 task_list[__task->command].wait(__scheduler,__task->command); | 197 task_list[task->command].wait(scheduler,task->command); |
198 #endif | 198 #endif |
199 | 199 |
200 task_list[__task->command].run(this, __readbuf, __writebuf); | 200 task_list[task->command].run(this, readbuf, writebuf); |
201 | 201 |
202 free(__readbuf); | 202 free(readbuf); |
203 | 203 |
204 if (__taskGroup->status() != 0) { | 204 if (taskGroup->status() != 0) { |
205 __task->self = __taskGroup->command; | 205 task->self = taskGroup->command; |
206 delete __taskGroup; | 206 delete taskGroup; |
207 __taskGroup = NULL; | 207 taskGroup = NULL; |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 // 書き込む領域がなければ無視 | 211 // 書き込む領域がなければ無視 |
212 if (__outListData->length > 0) { | 212 if (outListData->length > 0) { |
213 __scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE); | 213 scheduler->dma_storeList(outListData, writebuf, DMA_WRITE); |
214 | 214 |
215 #if defined(NO_PIPELINE) | 215 #if defined(NO_PIPELINE) |
216 __scheduler->dma_wait(DMA_WRITE); | 216 scheduler->dma_wait(DMA_WRITE); |
217 free(__writebuf); | 217 free(writebuf); |
218 #endif | 218 #endif |
219 } | 219 } |
220 | 220 |
221 (this->*ex_exec)(); | 221 (this->*ex_exec)(); |
222 } | 222 } |
225 SchedTask::write() | 225 SchedTask::write() |
226 { | 226 { |
227 __debug("[SchedTask:%s]\n", __FUNCTION__); | 227 __debug("[SchedTask:%s]\n", __FUNCTION__); |
228 | 228 |
229 #if !defined(NO_PIPELINE) | 229 #if !defined(NO_PIPELINE) |
230 __scheduler->dma_wait(DMA_WRITE); | 230 scheduler->dma_wait(DMA_WRITE); |
231 free(__writebuf); | 231 free(writebuf); |
232 #endif | 232 #endif |
233 | 233 |
234 if (__task->self == MY_SPE_NOP) return; | 234 if (task->self == MY_SPE_NOP) return; |
235 | 235 |
236 (this->*ex_write)(); | 236 (this->*ex_write)(); |
237 } | 237 } |
238 | 238 |
239 /** | 239 /** |
282 { | 282 { |
283 /** | 283 /** |
284 * このタスク内で新たにタスクが生成されなかった | 284 * このタスク内で新たにタスクが生成されなかった |
285 * or 生成されたが、そのタスクの終了を待つ必要は無い | 285 * or 生成されたが、そのタスクの終了を待つ必要は無い |
286 */ | 286 */ |
287 if (__renew_flag == 0) { | 287 if (renew_flag == 0) { |
288 __scheduler->mail_write(__task->self); | 288 scheduler->mail_write(task->self); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 /** | 292 /** |
293 * SPE 内で生成されたタスクの ex_write() | 293 * SPE 内で生成されたタスクの ex_write() |
304 void | 304 void |
305 SchedTask::ex_write_renew() | 305 SchedTask::ex_write_renew() |
306 { | 306 { |
307 uint32 cmd; | 307 uint32 cmd; |
308 | 308 |
309 __taskGroup->remove(__task); | 309 taskGroup->remove(task); |
310 cmd = __taskGroup->status(); | 310 cmd = taskGroup->status(); |
311 | 311 |
312 // タスク内で作られた全てのタスクが終了した | 312 // タスク内で作られた全てのタスクが終了した |
313 if (cmd != 0) { | 313 if (cmd != 0) { |
314 delete __taskGroup; | 314 delete taskGroup; |
315 __scheduler->mail_write(cmd); | 315 scheduler->mail_write(cmd); |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 SchedTaskBase* | 319 SchedTaskBase* |
320 SchedTask::next(Scheduler *scheduler, SchedTaskBase *p) | 320 SchedTask::next(Scheduler *scheduler, SchedTaskBase *p) |
327 } | 327 } |
328 | 328 |
329 SchedTaskBase* | 329 SchedTaskBase* |
330 SchedTask::ex_next_normal() | 330 SchedTask::ex_next_normal() |
331 { | 331 { |
332 if (__cur_index < __list->length) { | 332 if (cur_index < list->length) { |
333 SchedTaskBase *nextSched; | 333 SchedTaskBase *nextSched; |
334 | 334 |
335 nextSched = __scheduler->get_nextRenewTaskList(); | 335 nextSched = scheduler->get_nextRenewTaskList(); |
336 | 336 |
337 // RenewTask がある | 337 // RenewTask がある |
338 if (nextSched) { | 338 if (nextSched) { |
339 __scheduler->set_backupTaskList(__list); | 339 scheduler->set_backupTaskList(list); |
340 __scheduler->set_backupTaskListIndex(__cur_index); | 340 scheduler->set_backupTaskListIndex(cur_index); |
341 return nextSched; | 341 return nextSched; |
342 } else { | 342 } else { |
343 TaskPtr nextTask = &__list->tasks[__cur_index++]; | 343 TaskPtr nextTask = &list->tasks[cur_index++]; |
344 if (__cur_index < __list->length) { | 344 if (cur_index < list->length) { |
345 // load next task | 345 // load next task |
346 loadSchedTask(__scheduler, &__list->tasks[__cur_index]); | 346 loadSchedTask(scheduler, &list->tasks[cur_index]); |
347 } | 347 } |
348 nextSched = createSchedTask(__scheduler, nextTask); | 348 nextSched = createSchedTask(scheduler, nextTask); |
349 ((SchedTask*)nextSched)->__init__(__list, nextTask, __cur_index, | 349 ((SchedTask*)nextSched)->init(list, nextTask, cur_index, |
350 __scheduler->get_curReadBuf(), | 350 scheduler->get_curReadBuf(), |
351 __scheduler->get_curWriteBuf(), | 351 scheduler->get_curWriteBuf(), |
352 __scheduler); | 352 scheduler); |
353 return nextSched; | 353 return nextSched; |
354 } | 354 } |
355 } else { | 355 } else { |
356 uint32 nextList = (uint32)__list->next; | 356 uint32 nextList = (uint32)list->next; |
357 | 357 |
358 if (nextList == 0) { | 358 if (nextList == 0) { |
359 return new SchedNop2Ready(__scheduler); | 359 return new SchedNop2Ready(scheduler); |
360 } else { | 360 } else { |
361 return createSchedTaskList(nextList, __scheduler, | 361 return createSchedTaskList(nextList, scheduler, |
362 SCHED_TASKLIST_NORMAL); | 362 SCHED_TASKLIST_NORMAL); |
363 } | 363 } |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
371 SchedTask::ex_next_renew() | 371 SchedTask::ex_next_renew() |
372 { | 372 { |
373 TaskPtr nextTask; | 373 TaskPtr nextTask; |
374 SchedTask *nextSched; | 374 SchedTask *nextSched; |
375 | 375 |
376 if (__cur_index < __list->length) { | 376 if (cur_index < list->length) { |
377 nextTask = &__list->tasks[__cur_index++]; | 377 nextTask = &list->tasks[cur_index++]; |
378 if (__cur_index < __list->length) { | 378 if (cur_index < list->length) { |
379 // load next task | 379 // load next task |
380 loadSchedTask(__scheduler, &__list->tasks[__cur_index]); | 380 loadSchedTask(scheduler, &list->tasks[cur_index]); |
381 } | 381 } |
382 nextSched = createSchedTask(__scheduler, nextTask); | 382 nextSched = createSchedTask(scheduler, nextTask); |
383 | 383 |
384 // RenewTaskList を実行中なので | 384 // RenewTaskList を実行中なので |
385 nextSched->__setRenew(); | 385 nextSched->setRenew(); |
386 nextSched->__init__(__list, nextTask, __cur_index, | 386 nextSched->init(list, nextTask, cur_index, |
387 __scheduler->get_curReadBuf(), | 387 scheduler->get_curReadBuf(), |
388 __scheduler->get_curWriteBuf(), | 388 scheduler->get_curWriteBuf(), |
389 __scheduler); | 389 scheduler); |
390 | 390 |
391 /** | 391 /** |
392 * この理由は SchedTask:~SchedTask() で | 392 * この理由は SchedTask:~SchedTask() で |
393 */ | 393 */ |
394 __list = NULL; | 394 list = NULL; |
395 return nextSched; | 395 return nextSched; |
396 } else { | 396 } else { |
397 SchedTaskBase *nextList; | 397 SchedTaskBase *nextList; |
398 | 398 |
399 nextList = __scheduler->get_nextRenewTaskList(); | 399 nextList = scheduler->get_nextRenewTaskList(); |
400 | 400 |
401 if (nextList) { | 401 if (nextList) { |
402 return nextList; | 402 return nextList; |
403 } else { | 403 } else { |
404 TaskListPtr nextList = __scheduler->get_backupTaskList(); | 404 TaskListPtr nextList = scheduler->get_backupTaskList(); |
405 | 405 |
406 // 中断した TaskList がある | 406 // 中断した TaskList がある |
407 if (nextList) { | 407 if (nextList) { |
408 __cur_index = __scheduler->get_backupTaskListIndex(); | 408 cur_index = scheduler->get_backupTaskListIndex(); |
409 | 409 |
410 nextTask = &nextList->tasks[__cur_index++]; | 410 nextTask = &nextList->tasks[cur_index++]; |
411 if (__cur_index < __list->length) { | 411 if (cur_index < list->length) { |
412 // load next task | 412 // load next task |
413 loadSchedTask(__scheduler, &__list->tasks[__cur_index]); | 413 loadSchedTask(scheduler, &list->tasks[cur_index]); |
414 } | 414 } |
415 nextSched = createSchedTask(__scheduler, nextTask); | 415 nextSched = createSchedTask(scheduler, nextTask); |
416 | 416 |
417 nextSched->__init__(nextList, nextTask, __cur_index, | 417 nextSched->init(nextList, nextTask, cur_index, |
418 __scheduler->get_curReadBuf(), | 418 scheduler->get_curReadBuf(), |
419 __scheduler->get_curWriteBuf(), | 419 scheduler->get_curWriteBuf(), |
420 __scheduler); | 420 scheduler); |
421 return nextSched; | 421 return nextSched; |
422 } else { | 422 } else { |
423 return new SchedNop2Ready(__scheduler); | 423 return new SchedNop2Ready(scheduler); |
424 } | 424 } |
425 } | 425 } |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 int | 429 int |
430 SchedTask::get_cpuid() | 430 SchedTask::get_cpuid() |
431 { | 431 { |
432 return __scheduler->id; | 432 return scheduler->id; |
433 } | 433 } |
434 | 434 |
435 /** | 435 /** |
436 * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 | 436 * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 |
437 * buffer から対応するデータを返す。 | 437 * buffer から対応するデータを返す。 |
438 */ | 438 */ |
439 void* | 439 void* |
440 SchedTask::get_input(void *buff, int index) | 440 SchedTask::get_input(void *buff, int index) |
441 { | 441 { |
442 if (buff != NULL) { | 442 if (buff != NULL) { |
443 return (void*)((int)buff + __inListData->bound[index]); | 443 return (void*)((int)buff + inListData->bound[index]); |
444 } else { | 444 } else { |
445 return NULL; | 445 return NULL; |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
450 * get_input(index) のアドレスを返す | 450 * get_input(index) のアドレスを返す |
451 */ | 451 */ |
452 uint32 | 452 uint32 |
453 SchedTask::get_inputAddr(int index) | 453 SchedTask::get_inputAddr(int index) |
454 { | 454 { |
455 return __inListData->element[index].addr; | 455 return inListData->element[index].addr; |
456 } | 456 } |
457 | 457 |
458 /** | 458 /** |
459 * get_input(index) のサイズを返す | 459 * get_input(index) のサイズを返す |
460 */ | 460 */ |
461 int | 461 int |
462 SchedTask::get_inputSize(int index) | 462 SchedTask::get_inputSize(int index) |
463 { | 463 { |
464 return __inListData->element[index].size; | 464 return inListData->element[index].size; |
465 } | 465 } |
466 | 466 |
467 /** | 467 /** |
468 * write buffer の領域を返す。 | 468 * write buffer の領域を返す。 |
469 */ | 469 */ |
470 void* | 470 void* |
471 SchedTask::get_output(void *buff, int index) | 471 SchedTask::get_output(void *buff, int index) |
472 { | 472 { |
473 if (buff != NULL) { | 473 if (buff != NULL) { |
474 return (void*)((int)buff + __outListData->bound[index]); | 474 return (void*)((int)buff + outListData->bound[index]); |
475 } else { | 475 } else { |
476 return NULL; | 476 return NULL; |
477 } | 477 } |
478 } | 478 } |
479 | 479 |
481 * get_output(index) のアドレスを返す | 481 * get_output(index) のアドレスを返す |
482 */ | 482 */ |
483 uint32 | 483 uint32 |
484 SchedTask::get_outputAddr(int index) | 484 SchedTask::get_outputAddr(int index) |
485 { | 485 { |
486 return __outListData->element[index].addr; | 486 return outListData->element[index].addr; |
487 } | 487 } |
488 | 488 |
489 /** | 489 /** |
490 * get_output(index) のサイズを返す | 490 * get_output(index) のサイズを返す |
491 */ | 491 */ |
492 int | 492 int |
493 SchedTask::get_outputSize(int index) | 493 SchedTask::get_outputSize(int index) |
494 { | 494 { |
495 return __outListData->element[index].size; | 495 return outListData->element[index].size; |
496 } | 496 } |
497 | 497 |
498 int | 498 int |
499 SchedTask::get_param(int index) | 499 SchedTask::get_param(int index) |
500 { | 500 { |
501 return __task->param[index]; | 501 return task->param[index]; |
502 } | 502 } |
503 | 503 |
504 TaskPtr | 504 TaskPtr |
505 SchedTask::create_task(int cmd) | 505 SchedTask::create_task(int cmd) |
506 { | 506 { |
507 TaskListPtr taskList = __scheduler->get_renewListBuf(); | 507 TaskListPtr taskList = scheduler->get_renewListBuf(); |
508 TaskPtr p = &taskList->tasks[taskList->length++]; | 508 TaskPtr p = &taskList->tasks[taskList->length++]; |
509 p->command = cmd; | 509 p->command = cmd; |
510 | 510 |
511 p->inData = (ListData*)__scheduler->allocate(sizeof(ListData)); | 511 p->inData = (ListData*)scheduler->allocate(sizeof(ListData)); |
512 p->outData = (ListData*)__scheduler->allocate(sizeof(ListData)); | 512 p->outData = (ListData*)scheduler->allocate(sizeof(ListData)); |
513 | 513 |
514 p->inData->clear(); | 514 p->inData->clear(); |
515 p->outData->clear(); | 515 p->outData->clear(); |
516 | 516 |
517 p->self = MY_SPE_NOP; | 517 p->self = MY_SPE_NOP; |
519 | 519 |
520 return p; | 520 return p; |
521 } | 521 } |
522 | 522 |
523 /** | 523 /** |
524 * 生成したタスクが終了してから、メインスケジューラ(PPE) に | |
525 * タスクが終了した旨を知らせる。 | |
526 * | 524 * |
527 * @param[in] waitTask タスク内で生成したタスク | 525 * @param[in] waitTask タスク内で生成したタスクの登録(spawn()に相当) |
528 */ | 526 */ |
529 void | 527 void |
530 SchedTask::wait_task(TaskPtr waitTask) | 528 SchedTask::wait_task(TaskPtr waitTask) |
531 { | 529 { |
532 waitTask->self = (uint32)__taskGroup; | 530 waitTask->self = (uint32)taskGroup; |
533 | 531 |
534 __scheduler->add_groupTask(__taskGroup, waitTask); | 532 scheduler->add_groupTask(taskGroup, waitTask); |
535 | 533 |
536 __renew_flag++; | 534 renew_flag++; |
537 } | 535 } |
538 | 536 |
539 void* | 537 void* |
540 SchedTask::global_alloc(int id, int size) { | 538 SchedTask::global_alloc(int id, int size) { |
541 return __scheduler->global_alloc(id, size); | 539 return scheduler->global_alloc(id, size); |
542 } | 540 } |
543 | 541 |
544 void* | 542 void* |
545 SchedTask::global_get(int id) { | 543 SchedTask::global_get(int id) { |
546 return __scheduler->global_get(id); | 544 return scheduler->global_get(id); |
547 } | 545 } |
548 | 546 |
549 void | 547 void |
550 SchedTask::global_set(int id, void *addr) { | 548 SchedTask::global_set(int id, void *addr) { |
551 __scheduler->global_set(id, addr); | 549 scheduler->global_set(id, addr); |
552 } | 550 } |
553 | 551 |
554 void | 552 void |
555 SchedTask::global_free(int id) { | 553 SchedTask::global_free(int id) { |
556 __scheduler->global_free(id); | 554 scheduler->global_free(id); |
557 } | 555 } |
558 | 556 |
559 MemList* | 557 MemList* |
560 SchedTask::createMemList(int size, int count) { | 558 SchedTask::createMemList(int size, int count) { |
561 return __scheduler->createMemList(size, count); | 559 return scheduler->createMemList(size, count); |
562 } | 560 } |
563 | 561 |
564 void | 562 void |
565 SchedTask::mainMem_alloc(int id, int size) { | 563 SchedTask::mainMem_alloc(int id, int size) { |
566 __scheduler->mainMem_alloc(id, size); | 564 scheduler->mainMem_alloc(id, size); |
567 } | 565 } |
568 | 566 |
569 void | 567 void |
570 SchedTask::mainMem_wait() { | 568 SchedTask::mainMem_wait() { |
571 __scheduler->mainMem_wait(); | 569 scheduler->mainMem_wait(); |
572 } | 570 } |
573 | 571 |
574 void* | 572 void* |
575 SchedTask::mainMem_get(int id) { | 573 SchedTask::mainMem_get(int id) { |
576 return __scheduler->mainMem_get(id); | 574 return scheduler->mainMem_get(id); |
577 } | 575 } |
578 | 576 |
579 void* | 577 void* |
580 SchedTask::allocate(int size) { | 578 SchedTask::allocate(int size) { |
581 return __scheduler->allocate(size); | 579 return scheduler->allocate(size); |
582 } | 580 } |
583 | 581 |
584 | 582 |
585 void | 583 void |
586 SchedTask::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) { | 584 SchedTask::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) { |
587 __scheduler->dma_load(buf, addr, size, mask); | 585 scheduler->dma_load(buf, addr, size, mask); |
588 } | 586 } |
589 | 587 |
590 void | 588 void |
591 SchedTask::dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) { | 589 SchedTask::dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) { |
592 __scheduler->dma_store(buf, addr, size, mask); | 590 scheduler->dma_store(buf, addr, size, mask); |
593 } | 591 } |
594 | 592 |
595 void | 593 void |
596 SchedTask::dma_wait(uint32 mask) { | 594 SchedTask::dma_wait(uint32 mask) { |
597 __scheduler->dma_wait(mask); | 595 scheduler->dma_wait(mask); |
598 } | 596 } |
599 | 597 |
600 void | 598 void |
601 SchedTask::show_dma_wait() { | 599 SchedTask::show_dma_wait() { |
602 __scheduler->show_dma_wait(); | 600 scheduler->show_dma_wait(); |
603 } | 601 } |
604 | 602 |
605 MemorySegment * SchedTask::get_segment(memaddr addr, MemList *m) { | 603 MemorySegment * SchedTask::get_segment(memaddr addr, MemList *m) { |
606 return __scheduler->get_segment(addr,m); | 604 return scheduler->get_segment(addr,m); |
607 } | 605 } |
608 | 606 |
609 void SchedTask::put_segment(MemorySegment *s) { | 607 void SchedTask::put_segment(MemorySegment *s) { |
610 __scheduler->put_segment(s); | 608 scheduler->put_segment(s); |
611 } | 609 } |
612 | 610 |
613 void SchedTask::wait_segment(MemorySegment *s) { | 611 void SchedTask::wait_segment(MemorySegment *s) { |
614 __scheduler->wait_segment(s); | 612 scheduler->wait_segment(s); |
615 } | 613 } |
616 | 614 |
617 /* system call */ | 615 /* system call */ |
618 | 616 |
619 int | 617 int |