annotate TaskManager/Fifo/FifoTaskManagerImpl.cc @ 475:e083c4ff91c1

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