Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Fifo/FifoTaskManagerImpl.cc @ 640:a909c50081c2
SimpeTask on Cell worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Nov 2009 23:12:34 +0900 (2009-11-20) |
parents | 671fca057ad3 |
children | bffdede05f1e |
comparison
equal
deleted
inserted
replaced
639:70c5c2d2eb24 | 640:a909c50081c2 |
---|---|
8 #include "error.h" | 8 #include "error.h" |
9 | 9 |
10 FifoTaskManagerImpl::~FifoTaskManagerImpl() | 10 FifoTaskManagerImpl::~FifoTaskManagerImpl() |
11 { | 11 { |
12 delete mailManager; | 12 delete mailManager; |
13 delete scheduler; | 13 delete mainScheduler; |
14 | 14 |
15 delete taskListImpl ; | 15 delete taskListImpl ; |
16 delete taskQueueImpl ; | 16 delete taskQueueImpl ; |
17 delete htaskImpl ; | 17 delete htaskImpl ; |
18 | 18 |
27 FifoTaskManagerImpl::init() | 27 FifoTaskManagerImpl::init() |
28 { | 28 { |
29 mailManager = new MailManager(); | 29 mailManager = new MailManager(); |
30 mailManager->init(20); | 30 mailManager->init(20); |
31 | 31 |
32 scheduler = new MainScheduler(); | 32 mainScheduler = new MainScheduler(); |
33 scheduler->init(this); | 33 mainScheduler->init(this); |
34 scheduler->set_mailManager(mailManager); | 34 mainScheduler->set_mailManager(mailManager); |
35 scheduler->id = 0; | 35 mainScheduler->id = 0; |
36 set_scheduler(scheduler); | 36 set_scheduler(mainScheduler); |
37 | 37 |
38 taskListImpl = new TaskListInfo; | 38 taskListImpl = new TaskListInfo; |
39 taskQueueImpl = new TaskQueueInfo; | 39 taskQueueImpl = new TaskQueueInfo; |
40 htaskImpl = new HTaskInfo(); | 40 htaskImpl = new HTaskInfo(); |
41 | 41 |
42 mainTaskList = taskListImpl->create(); | 42 mainTaskList = taskListImpl->create(); |
43 | 43 |
44 schedTaskManager = new SchedTask(); | 44 schedTaskManager = new SchedTask(); |
45 schedTaskManager->init(0,0,0,scheduler); | 45 schedTaskManager->init(0,0,0,mainScheduler); |
46 | 46 |
47 } | 47 } |
48 | 48 |
49 /** | 49 /** |
50 * これは CellTaskManagerImpl から呼ばれる。 | 50 * これは CellTaskManagerImpl から呼ばれる。 |
57 { | 57 { |
58 mailManager = new MailManager(); | 58 mailManager = new MailManager(); |
59 mailManager->init(20); | 59 mailManager->init(20); |
60 | 60 |
61 //scheduler = new MainScheduler(); | 61 //scheduler = new MainScheduler(); |
62 scheduler = _sched; | 62 mainScheduler = _sched; |
63 scheduler->init(this); | 63 mainScheduler->init(this); |
64 scheduler->set_mailManager(mailManager); | 64 mainScheduler->set_mailManager(mailManager); |
65 set_scheduler(scheduler); | 65 set_scheduler(mainScheduler); |
66 | 66 |
67 taskListImpl = tm-> taskListImpl ; | 67 taskListImpl = tm-> taskListImpl ; |
68 taskQueueImpl = tm-> taskQueueImpl ; | 68 taskQueueImpl = tm-> taskQueueImpl ; |
69 htaskImpl = tm-> htaskImpl ; | 69 htaskImpl = tm-> htaskImpl ; |
70 waitTaskQueue = NULL; // mail_check で外から設定される | 70 waitTaskQueue = NULL; // mail_check で外から設定される |
169 // EXIT_COMMAND (番兵的な意味で) | 169 // EXIT_COMMAND (番兵的な意味で) |
170 sentinel = mailManager->create((memaddr)MY_SPE_COMMAND_EXIT); | 170 sentinel = mailManager->create((memaddr)MY_SPE_COMMAND_EXIT); |
171 in_mail_list = MailManager::append_mailQueue(in_mail_list, sentinel); | 171 in_mail_list = MailManager::append_mailQueue(in_mail_list, sentinel); |
172 | 172 |
173 // scheduler は受け取ったメールを元に実行する | 173 // scheduler は受け取ったメールを元に実行する |
174 scheduler->send_mailList(in_mail_list); | 174 mainScheduler->send_mailList(in_mail_list); |
175 scheduler->run(); | 175 mainScheduler->run(); |
176 } | 176 } |
177 out_mail_list = scheduler->recv_mailList(); | 177 out_mail_list = mainScheduler->recv_mailList(); |
178 #if 0 | |
179 if (MailManager::length(out_mail_list )==-1) { | |
180 fprintf(stderr, "Error on mail list\n"); | |
181 exit(0); | |
182 } | |
183 #endif | |
178 | 184 |
179 return out_mail_list; | 185 return out_mail_list; |
180 } | 186 } |
181 | 187 |
182 /** | 188 /** |
206 while (q) { | 212 while (q) { |
207 data = q->data; | 213 data = q->data; |
208 | 214 |
209 if (data == (memaddr)MY_SPE_STATUS_READY) { | 215 if (data == (memaddr)MY_SPE_STATUS_READY) { |
210 __debug_ppe("mail_check(): Task List finish\n"); | 216 __debug_ppe("mail_check(): Task List finish\n"); |
217 } else if (data == (memaddr)MY_SPE_COMMAND_EXIT) { | |
218 __debug_ppe("mail_check(): Task List finish COMMAND\n"); | |
211 } else if (data != (memaddr)MY_SPE_NOP) { | 219 } else if (data != (memaddr)MY_SPE_NOP) { |
212 __debug_ppe("mail_check(): recv from 0x%x\n", data); | 220 __debug_ppe("mail_check(): recv from 0x%x\n", data); |
213 // post_func を先に実行しないと、systask_finish が active_queue | 221 // post_func を先に実行しないと、systask_finish が active_queue |
214 // 移されてから、wait_for されるという事態が起きることがある。 | 222 // 移されてから、wait_for されるという事態が起きることがある。 |
215 HTaskPtr task = (HTaskPtr)data; | 223 HTaskPtr task = (HTaskPtr)data; |
222 | 230 |
223 mailManager->free(d); | 231 mailManager->free(d); |
224 } | 232 } |
225 } | 233 } |
226 | 234 |
227 #if 0 | |
228 void* | |
229 FifoTaskManagerImpl::allocate(int size, int alignment) | |
230 { | |
231 if (size==0) return 0; | |
232 #if defined(__APPLE__) && ! defined(HAS_POSIZ_MEMALIGN) | |
233 return malloc(size); | |
234 #else | |
235 void *buff; | |
236 posix_memalign(&buff, alignment, size); | |
237 return buff; | |
238 #endif | |
239 } | |
240 | |
241 void* | |
242 FifoTaskManagerImpl::allocate(int size) | |
243 { | |
244 if (size==0) return 0; | |
245 #if defined(__APPLE__) && ! defined(HAS_POSIZ_MEMALIGN) | |
246 return malloc(size); | |
247 #else | |
248 void *buff; | |
249 posix_memalign(&buff, DEFAULT_ALIGNMENT, size); | |
250 return buff; | |
251 #endif | |
252 } | |
253 | |
254 Scheduler* | |
255 FifoTaskManagerImpl::get_scheduler() { | |
256 return scheduler; | |
257 } | |
258 #endif | |
259 | 235 |
260 /** | 236 /** |
261 * # # # # # # # # | 237 * # # # # # # # # |
262 * Abstract Factory Pattern | 238 * Abstract Factory Pattern |
263 * # # # # # # # | 239 * # # # # # # # |