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