Mercurial > hg > Members > kono > Cerium
comparison TaskManager/kernel/ppe/TaskManagerImpl.cc @ 955:9989dd7b9ac2
unify all QueueInfo
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 04 Aug 2010 16:46:25 +0900 |
parents | 86aea6affe6c |
children |
comparison
equal
deleted
inserted
replaced
954:6d3c954e510a | 955:9989dd7b9ac2 |
---|---|
6 #include "Scheduler.h" | 6 #include "Scheduler.h" |
7 #include "SysTask.h" | 7 #include "SysTask.h" |
8 #include "SysFunc.h" | 8 #include "SysFunc.h" |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 // singleton | |
12 QueueInfo<TaskQueue> *taskQueuePool = new QueueInfo<TaskQueue>() ; | |
13 QueueInfo<HTask> *htaskPool = new QueueInfo<HTask>() ; | |
14 QueueInfo<TaskList> *taskListPool = new QueueInfo<TaskList>() ; | |
15 | |
11 | 16 |
12 static HTaskPtr systask_start; | 17 static HTaskPtr systask_start; |
13 static HTaskPtr systask_finish; | 18 static HTaskPtr systask_finish; |
14 | 19 |
15 static void | 20 static void |
18 } | 23 } |
19 | 24 |
20 TaskManagerImpl::TaskManagerImpl(int num) | 25 TaskManagerImpl::TaskManagerImpl(int num) |
21 : machineNum(num){ | 26 : machineNum(num){ |
22 // 実行可能なHTaskのリスト | 27 // 実行可能なHTaskのリスト |
23 activeTaskQueue = new HTaskInfo(); | 28 activeTaskQueue = new QueueInfo<HTask>(htaskPool); |
24 // wait_forで止まっているHTaskのリスト。必要ないが、Dead lock detection に使う | 29 // wait_forで止まっているHTaskのリスト。必要ないが、Dead lock detection に使う |
25 waitTaskQueue = new HTaskInfo(); | 30 waitTaskQueue = new QueueInfo<HTask>(htaskPool); |
26 // HTask の factory. HTaskInfo ならなんでもいい。 | 31 // HTask の factory. QueueInfo<HTask> ならなんでもいい。 |
27 htaskImpl = waitTaskQueue ; // any HTaskInfo | 32 htaskImpl = waitTaskQueue ; // any QueueInfo<HTask> |
28 // Task の dependency を表現する double linked list. HTaskInfo とは別に必要。 | 33 // Task の dependency を表現する double linked list. QueueInfo<HTask> とは別に必要。 |
29 taskQueueImpl = new TaskQueueInfo(); | 34 taskQueueImpl = new QueueInfo<TaskQueue>(taskQueuePool); |
30 } | 35 } |
31 | 36 |
32 /** | 37 /** |
33 * 一番最初に PPE で実行される systask_start | 38 * 一番最初に PPE で実行される systask_start |
34 */ | 39 */ |
53 */ | 58 */ |
54 HTaskPtr | 59 HTaskPtr |
55 TaskManagerImpl::create_task(int cmd,memaddr rbuf, long r_size, memaddr wbuf, long w_size, void *from) { | 60 TaskManagerImpl::create_task(int cmd,memaddr rbuf, long r_size, memaddr wbuf, long w_size, void *from) { |
56 HTaskPtr new_task; | 61 HTaskPtr new_task; |
57 | 62 |
58 new_task = htaskImpl->create(cmd, rbuf, r_size, wbuf, w_size); | 63 new_task = htaskImpl->create(); |
64 new_task->init(cmd, rbuf, r_size, wbuf, w_size); | |
59 new_task->post_func = noaction; | 65 new_task->post_func = noaction; |
60 new_task->mimpl = this; | 66 new_task->mimpl = this; |
61 new_task->from = (memaddr)from; | 67 new_task->from = (memaddr)from; |
62 #ifdef EARLY_TOUCH | 68 #ifdef EARLY_TOUCH |
63 if (rbuf) { | 69 if (rbuf) { |
88 TaskManagerImpl::create_task(int cmd,void *from) | 94 TaskManagerImpl::create_task(int cmd,void *from) |
89 { | 95 { |
90 HTaskPtr new_task; | 96 HTaskPtr new_task; |
91 | 97 |
92 // for compatibility | 98 // for compatibility |
93 new_task = htaskImpl->create(TaskArray1); | 99 new_task = htaskImpl->create(); new_task->init(TaskArray1); |
94 new_task->post_func = noaction; | 100 new_task->post_func = noaction; |
95 new_task->mimpl = this; | 101 new_task->mimpl = this; |
96 new_task->create_task_array(cmd,1,8,8,8); | 102 new_task->create_task_array(cmd,1,8,8,8); |
97 // rbuf, r_size were set | 103 // rbuf, r_size were set |
98 new_task->command = TaskArray1; | 104 new_task->command = TaskArray1; |
121 TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave) | 127 TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave) |
122 { | 128 { |
123 TaskQueuePtr m, s; | 129 TaskQueuePtr m, s; |
124 if (!master->self) return; | 130 if (!master->self) return; |
125 | 131 |
126 m = taskQueueImpl->create(master); | 132 m = taskQueueImpl->create(); m->init(master); |
127 s = taskQueueImpl->create(slave); | 133 s = taskQueueImpl->create(); s->init(slave); |
128 | 134 |
129 master->wait_me->addLast(s); | 135 master->wait_me->addLast(s); |
130 slave->wait_i->addLast(m); | 136 slave->wait_i->addLast(m); |
131 s->waiter = m; | 137 s->waiter = m; |
132 } | 138 } |
173 task->cpu_type = type; | 179 task->cpu_type = type; |
174 } | 180 } |
175 | 181 |
176 #if 0 | 182 #if 0 |
177 static void | 183 static void |
178 check_wait(TaskManagerImpl *tm, TaskQueueInfo *wait_i) { | 184 check_wait(TaskManagerImpl *tm, QueueInfo<TaskQueue> *wait_i) { |
179 for(TaskQueue *t = wait_i->getFirst(); t; t = wait_i->getNext(t)) { | 185 for(TaskQueue *t = wait_i->getFirst(); t; t = wait_i->getNext(t)) { |
180 if (!tm->waitTaskQueue->find(t->task)) { | 186 if (!tm->waitTaskQueue->find(t->task)) { |
181 printf("stray waiting task%d %lx\n",t->task->command, (long)t->task); | 187 printf("stray waiting task%d %lx\n",t->task->command, (long)t->task); |
182 } else if (tm->activeTaskQueue->find(t->task)) { | 188 } else if (tm->activeTaskQueue->find(t->task)) { |
183 printf(" active task%d in waiting queue %lx\n",t->task->command, (long)t->task); | 189 printf(" active task%d in waiting queue %lx\n",t->task->command, (long)t->task); |
192 * post_func() はこのタスクが終了したら実行する関数。 | 198 * post_func() はこのタスクが終了したら実行する関数。 |
193 * | 199 * |
194 * @param [task] 終了したタスク | 200 * @param [task] 終了したタスク |
195 */ | 201 */ |
196 void | 202 void |
197 TaskManagerImpl::check_task_finish(HTaskPtr me, HTaskInfo *wait_queue) | 203 TaskManagerImpl::check_task_finish(HTaskPtr me, QueueInfo<HTask> *wait_queue) |
198 { | 204 { |
199 while(TaskQueue *p = me->wait_me->poll()) { | 205 while(TaskQueue *p = me->wait_me->poll()) { |
200 HTaskPtr you = p->task; | 206 HTaskPtr you = p->task; |
201 TaskQueueInfo *wait_i = you->wait_i; | 207 QueueInfo<TaskQueue> *wait_i = you->wait_i; |
202 // 相手の wait queue から自分(を指しているTaskQueue)を削除 | 208 // 相手の wait queue から自分(を指しているTaskQueue)を削除 |
203 wait_i->remove(p->waiter); | 209 wait_i->remove(p->waiter); |
204 // queue を free する | 210 // queue を free する |
205 wait_i->free_(p->waiter); | 211 wait_i->free_(p->waiter); |
206 | 212 |
227 /** | 233 /** |
228 * @brief 終了したタスクリストの依存の処理 | 234 * @brief 終了したタスクリストの依存の処理 |
229 * @param [task] 終了したタスク | 235 * @param [task] 終了したタスク |
230 */ | 236 */ |
231 void | 237 void |
232 TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, HTaskInfo *wait_queue) | 238 TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue) |
233 { | 239 { |
234 for(int i = 0;i<list->length;i++) { | 240 for(int i = 0;i<list->length;i++) { |
235 SimpleTaskPtr task = &list->tasks[i]; | 241 SimpleTaskPtr task = &list->tasks[i]; |
236 HTask *me = (HTask*)task->self; | 242 HTask *me = (HTask*)task->self; |
237 me->post_func(s, me->post_arg1, me->post_arg2); | 243 me->post_func(s, me->post_arg1, me->post_arg2); |
262 @param htask | 268 @param htask |
263 @param taskList | 269 @param taskList |
264 TaskList は自動的に延長される | 270 TaskList は自動的に延長される |
265 */ | 271 */ |
266 void | 272 void |
267 TaskManagerImpl::set_taskList(HTaskPtr htask, TaskListInfoPtr taskList) { | 273 TaskManagerImpl::set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList) { |
268 TaskListPtr list ; | 274 TaskListPtr list ; |
269 if ( taskList->empty() ) { | 275 if ( taskList->empty() ) { |
270 list = taskList->create(); | 276 list = taskList->create(); |
271 taskList->addLast(list); | 277 taskList->addLast(list); |
272 } else | 278 } else |