annotate TaskManager/Fifo/FifoTaskManagerImpl.cc @ 373:eab18aa0c7f6

MemList not working
author kazz@kazzone.cr.ie.u-ryukyu.ac.jp
date Fri, 31 Jul 2009 17:52:27 +0900
parents f64d75473f95
children e083c4ff91c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
1 #include <stdio.h>
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
2 #include <stdlib.h>
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
3 #include <string.h>
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
4 #include "FifoTaskManagerImpl.h"
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
5 #include "Scheduler.h"
47
8266445bdac2 *** empty log message ***
gongo
parents: 42
diff changeset
6 #include "types.h"
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
7 #include "error.h"
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
8
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
9 FifoTaskManagerImpl::~FifoTaskManagerImpl(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
10 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
11 delete mailManager;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
12 delete scheduler;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
13 delete bufferManager;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
14 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
15
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
16 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
17 * MailManager は PPE スケジューラとのメール交換、
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
18 * FifoScheduler は PPE 側のスケジューラ
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
19 * BufferManager は Task、TaskList などのメモリ管理(大層なことしてないが
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
20 */
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
21 void
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
22 FifoTaskManagerImpl::init(void)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
23 {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
24 mailManager = new MailManager();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
25 mailManager->init(20);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
26
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
27 scheduler = new MainScheduler();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
28 scheduler->init();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
29 scheduler->set_mailManager(mailManager);
194
gongo@localhost.localdomain
parents: 109
diff changeset
30 scheduler->id = 0;
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 22
diff changeset
31
58
7492eb28b577 *** empty log message ***
gongo
parents: 47
diff changeset
32 bufferManager = new BufferManager;
7492eb28b577 *** empty log message ***
gongo
parents: 47
diff changeset
33 bufferManager->init();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
34
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
35 mainTaskList = bufferManager->create_taskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
36 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
37
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
38 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
39 * これは CellTaskManagerImpl から呼ばれる。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
40 * BufferManager は共用で使うので引数に。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
41 * CellTaskManagerImpl と FifoTaskManagerImpl が同時に
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
42 * 上のデータにアクセスする事は(今は)ないのでこれでおk
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
43 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
44 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
45 FifoTaskManagerImpl::init(MainScheduler *_sched, BufferManager *buff)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
46 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
47 mailManager = new MailManager();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
48 mailManager->init(20);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
49
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
50 //scheduler = new MainScheduler();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
51 scheduler = _sched;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
52 scheduler->init();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
53 scheduler->set_mailManager(mailManager);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
54
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
55 bufferManager = buff;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
56
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
57 mainTaskList = bufferManager->create_taskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
58 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
59
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
60 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
61 * スケジューラに渡す TaskList を取得する。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
62 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
63 * @return 実行タスクリスト
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
64 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
65 * ActiveTaskQueue (依存条件は満たし済み) のタスクを
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
66 * 実行タスクリストに入れる
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
67 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
68 TaskListPtr
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
69 FifoTaskManagerImpl::get_runTaskList(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
70 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
71 TaskListPtr list, list_top;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
72 TaskQueuePtr queue;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
73 TaskQueuePtr d;
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
74 HTaskPtr htask; // HTask (PPE にある)
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
75 TaskPtr task; // Task (SPE に送る Task)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
76
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
77 queue = activeTaskQueue;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
78 if (queue == NULL) {
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
79 return NULL;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
80 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
81
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
82 // PPE 側で実行される TaskList
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
83 list_top = mainTaskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
84
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
85 // list_top->clear() とかの方がいいかもしれん。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
86 list_top = bufferManager->clear_taskList(list_top);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
87 list = list_top;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
88
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
89 while (queue) {
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
90 htask = (HTaskPtr)queue->task;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
91 d = queue;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
92 queue = queue->next;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
93
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
94 task = &list->tasks[list->length++];
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
95
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
96 #if 0
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
97 task->command = htask->command;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
98 task->inData = htask->inData;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
99 task->outData = htask->outData;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
100 task->self = (unsigned int)htask;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
101 #else
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
102 memcpy(task, htask, sizeof(Task));
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
103 #endif
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
104
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
105 if (list->length >= TASK_MAX_SIZE) {
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
106 TaskListPtr newList = bufferManager->create_taskList();
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
107 list_top = TaskListInfo::append(list_top, newList);
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
108 list = newList;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
109 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
110
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
111 bufferManager->free_taskQueue(d);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
112 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
113
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
114 activeTaskQueue = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
115 mainTaskList = list_top;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
116
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
117 return list_top;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
118 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
119
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
120
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
121 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
122 FifoTaskManagerImpl::run(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
123 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
124 TaskListPtr list;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
125 MailQueuePtr mail;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
126
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
127 list = get_runTaskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
128
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
129 do {
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
130 // list を実行する
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
131 mail = schedule(list);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
132
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
133 // mail には、ppe scheduler からの mail がある
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
134 mail_check(mail);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
135
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
136 // 依存関係を満たしたものは実行可能キューへ
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
137 wakeup_waitTask();
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
138 list = get_runTaskList();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
139 } while (list);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
140 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
141
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
142 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
143 * @param [list] 実行タスクリスト
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
144 * @return FifoScheduler からのメール
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
145 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
146 * [Tasklist] -> [番兵] -> scheduler->run を抜ける
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
147 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
148 MailQueuePtr
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
149 FifoTaskManagerImpl::schedule(TaskListPtr list)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
150 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
151 MailQueuePtr list_mail; // task list
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
152 MailQueuePtr sentinel; // 番兵
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
153 MailQueuePtr in_mail_list = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
154 MailQueuePtr out_mail_list = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
155
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
156 // TaskList のアドレス
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
157 list_mail = mailManager->create((unsigned int)list);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
158 in_mail_list = MailManager::append_mailQueue(in_mail_list, list_mail);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
159
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
160 // EXIT_COMMAND (番兵的な意味で)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
161 sentinel = mailManager->create(MY_SPE_COMMAND_EXIT);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
162 in_mail_list = MailManager::append_mailQueue(in_mail_list, sentinel);
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
163
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
164 // scheduler は受け取ったメールを元に実行する
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
165 scheduler->send_mailList(in_mail_list);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
166 scheduler->run();
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
167 out_mail_list = scheduler->recv_mailList();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
168
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
169 return out_mail_list;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
170 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
171
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
172 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
173 * PPE Scheduler からのメールをチェックする
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
174 *
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
175 * @param [mail_list]
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
176 * PPE 側で動く Scheduler からのメールリスト
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
177 * 終了した Task や、その他(今はまだ実装してないけど)の情報が入ってる
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
178 *
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
179 * @return Scheduler が次に実行する Task List
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
180 * NULL なら全てのタスクが実行終了したということ
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
181 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
182 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
183 FifoTaskManagerImpl::mail_check(MailQueuePtr mail_list)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
184 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
185 MailQueuePtr q = mail_list;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
186 MailQueuePtr d;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
187 unsigned int data;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
188
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
189 while (q) {
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
190 data = q->data;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
191
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
192 /**
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
193 * MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
194 * MY_SPE_NOP: 特に意味のないコマンド
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
195 * それ以外:終了したタスク(PPEにあるのでアドレス
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
196 *
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
197 * MY_SPE_NOP が 0 なので、
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
198 * 下のように data > MY_SPE_NOP とかしています。
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
199 * 一目でよくわからない書き方なんで、直したいところですが。。。
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
200 */
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
201 if (data == MY_SPE_STATUS_READY) {
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
202 __debug_ppe("mail_check(): Task List finish\n");
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
203 } else if (data > MY_SPE_NOP) {
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
204 __debug_ppe("mail_check(): recv from 0x%x\n", data);
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
205 check_task_finish((HTaskPtr)data);
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
206 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
207
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
208 d = q;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
209 q = q->next;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
210
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
211 mailManager->free(d);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
212 }
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
213 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
214
14
41ccd4b38184 *** empty log message ***
gongo
parents: 10
diff changeset
215 void
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
216 FifoTaskManagerImpl::mail_check(MailQueuePtr mail_list, TaskQueuePtr *wait)
14
41ccd4b38184 *** empty log message ***
gongo
parents: 10
diff changeset
217 {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
218 waitTaskQueue = *wait;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
219 mail_check(mail_list);
14
41ccd4b38184 *** empty log message ***
gongo
parents: 10
diff changeset
220 }
41ccd4b38184 *** empty log message ***
gongo
parents: 10
diff changeset
221
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
222 void*
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
223 FifoTaskManagerImpl::allocate(int size)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
224 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
225 return malloc(size);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
226 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
227
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
228 Scheduler*
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
229 FifoTaskManagerImpl::get_scheduler() {
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
230 return scheduler;
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
231 }
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
232
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
233 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
234 * こういう使い方を
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
235 * Abstract Factory Pattern
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
236 * というらしい。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
237 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
238 #ifdef __CERIUM_FIFO__
373
eab18aa0c7f6 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
239 TaskManagerImpl*
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
240 create_impl(int num)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
241 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
242 return new FifoTaskManagerImpl();
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
243 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
244 #endif // __CERIUM_FIFO__