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