annotate TaskManager/Fifo/FifoTaskManagerImpl.cc @ 538:5641d121818e draft

code_load in read()
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 02:50:01 +0900
parents 981aa2f89a80
children 92b0d490e839
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
205e4a4af635 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
028ffc9c0375 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
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
9 FifoTaskManagerImpl::~FifoTaskManagerImpl()
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
10 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
11 delete mailManager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
12 delete scheduler;
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
13
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
14 delete taskListImpl ;
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
15 delete taskQueueImpl ;
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
16 delete htaskImpl ;
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
17
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
18 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
19
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
20 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
21 * MailManager は PPE スケジューラとのメール交換、
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
22 * FifoScheduler は PPE 側のスケジューラ
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
23 * BufferManager は Task、TaskList などのメモリ管理(大層なことしてないが
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
24 */
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
25 void
475
4e0308d2ba73 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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
28 mailManager = new MailManager();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
29 mailManager->init(20);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
30
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
31 scheduler = new MainScheduler();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
32 scheduler->init();
028ffc9c0375 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
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
36 taskListImpl = new TaskListInfo;
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
37 taskQueueImpl = new TaskQueueInfo;
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 494
diff changeset
38 htaskImpl = new HTaskInfo();
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
39
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
40 mainTaskList = taskListImpl->create();
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
41
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
42 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
43
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
44 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
45 * これは CellTaskManagerImpl から呼ばれる。
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
46 * TaskList等 は共用で使うので引数に。
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
47 * CellTaskManagerImpl と FifoTaskManagerImpl が同時に
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
48 * 上のデータにアクセスする事は(今は)ないのでこれでおk
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
49 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
50 void
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
51 FifoTaskManagerImpl::init(MainScheduler *_sched, TaskManagerImpl *tm)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
52 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
53 mailManager = new MailManager();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
54 mailManager->init(20);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
55
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
56 //scheduler = new MainScheduler();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
57 scheduler = _sched;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
58 scheduler->init();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
59 scheduler->set_mailManager(mailManager);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
60
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
61 taskListImpl = tm-> taskListImpl ;
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
62 taskQueueImpl = tm-> taskQueueImpl ;
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
63 htaskImpl = tm-> htaskImpl ;
485
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
64 waitTaskQueue = NULL; // mail_check で外から設定される
486
58b7ac6588b9 activeTaskQueue on Fifo is necessary on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 485
diff changeset
65 // waitTaskQueue = tm->waitTaskQueue;
58b7ac6588b9 activeTaskQueue on Fifo is necessary on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 485
diff changeset
66 // activeTaskQueue = NULL; // CellTaskManagerImple 側を使う
485
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
67
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
68 // waitTaskQueue = tm->waitTaskQueue;
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
69 // activeQueue は?
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
70
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
71 mainTaskList = taskListImpl->create();
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
72
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
73
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
74 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
75
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
76 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
77 * スケジューラに渡す TaskList を取得する。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
78 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
79 * @return 実行タスクリスト
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
80 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
81 * ActiveTaskQueue (依存条件は満たし済み) のタスクを
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
82 * 実行タスクリストに入れる
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
83 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
84 TaskListPtr
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
85 FifoTaskManagerImpl::get_runTaskList()
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
86 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
87 TaskListPtr list, list_top;
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
88 TaskPtr task; // Task (SPE に送る Task)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
89
480
75e4afa40da2 TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
90 if (activeTaskQueue->empty()) {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
91 return NULL;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
92 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
93
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
94 // PPE 側で実行される TaskList
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
95 list_top = mainTaskList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
96
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
97 // list_top->clear() とかの方がいいかもしれん。
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
98 list_top = taskListImpl->clear_taskList(list_top);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
99 list = list_top;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
100
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
101 // printf("active task queue length = %d\n",activeTaskQueue->length());
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 494
diff changeset
102 while (HTaskPtr htask = activeTaskQueue->poll()) {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
103 task = &list->tasks[list->length++];
492
6b2dda81ea9d memcpy for param
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
104 #if 0
491
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
105 task->command = htask->command;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
106 task->inData = htask->inData;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
107 task->outData = htask->outData;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
108 task->self = (unsigned int)htask;
492
6b2dda81ea9d memcpy for param
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
109 // param は?
491
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
110 #else
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
111 // inData, outData を内蔵にしたので実は、結構でかくない?
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
112 // 268 byte 程度だが... 不要な分(設定してない inData, outData, param
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
113 // とかもコピーしてるね。rbuf/wbuf の意味を変えてしまったわけか。
491
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
114 memcpy(task, (Task*)htask, sizeof(Task));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 486
diff changeset
115 #endif
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
116
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
117
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
118 if (list->length >= TASK_MAX_SIZE) {
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
119 TaskListPtr newList = taskListImpl->create();
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
120 list_top = TaskListInfo::append(list_top, newList);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
121 list = newList;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
122 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
123
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
124 // activeTaskQueue->free_(htask); ここで free しないで、
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
125 // mail を待つ
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
126 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
127
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
128 mainTaskList = list_top;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
129
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
130 return list_top;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
131 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
132
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
133
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
134 void
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
135 FifoTaskManagerImpl::run()
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
136 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
137 TaskListPtr list;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
138 MailQueuePtr mail;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
139
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
140 list = get_runTaskList();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
141
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
142 do {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
143 // list を実行する
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
144 mail = schedule(list);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
145
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
146 // mail には、ppe scheduler からの mail がある
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
147 mail_check(mail);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
148
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
149 // 依存関係を満たしたものは実行可能キューへ
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
150 wakeup_waitTask();
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
151 list = get_runTaskList();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
152 } while (list);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
153 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
154
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
155 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
156 * @param [list] 実行タスクリスト
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
157 * @return FifoScheduler からのメール
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
158 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
159 * [Tasklist] -> [番兵] -> scheduler->run を抜ける
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
160 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
161 MailQueuePtr
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
162 FifoTaskManagerImpl::schedule(TaskListPtr list)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
163 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
164 MailQueuePtr list_mail; // task list
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
165 MailQueuePtr sentinel; // 番兵
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
166 MailQueuePtr in_mail_list = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
167 MailQueuePtr out_mail_list = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
168
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
169 // TaskList のアドレス
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
170 list_mail = mailManager->create((unsigned int)list);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
171 in_mail_list = MailManager::append_mailQueue(in_mail_list, list_mail);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
172
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
173 // EXIT_COMMAND (番兵的な意味で)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
174 sentinel = mailManager->create(MY_SPE_COMMAND_EXIT);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
175 in_mail_list = MailManager::append_mailQueue(in_mail_list, sentinel);
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
176
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
177 // scheduler は受け取ったメールを元に実行する
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
178 scheduler->send_mailList(in_mail_list);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
179 scheduler->run();
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
180 out_mail_list = scheduler->recv_mailList();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
181
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
182 return out_mail_list;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
183 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
184
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
185 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
186 * PPE Scheduler からのメールをチェックする
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
187 *
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
188 * @param [mail_list]
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
189 * PPE 側で動く Scheduler からのメールリスト
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
190 * 終了した Task や、その他(今はまだ実装してないけど)の情報が入ってる
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
191 *
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
192 * @return Scheduler が次に実行する Task List
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
193 * NULL なら全てのタスクが実行終了したということ
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
194 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
195 void
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 494
diff changeset
196 FifoTaskManagerImpl::mail_check(MailQueuePtr mail_list, HTaskInfo *waitQueue)
485
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
197 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
198 waitTaskQueue = waitQueue;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
199 mail_check(mail_list);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
200 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
201
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
202 void
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
203 FifoTaskManagerImpl::mail_check(MailQueuePtr mail_list)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
204 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
205 MailQueuePtr q = mail_list;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
206 MailQueuePtr d;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
207 unsigned int data;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
208
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
209 while (q) {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
210 data = q->data;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
211
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
212 /**
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
213 * MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
214 * MY_SPE_NOP: 特に意味のないコマンド
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
215 * それ以外:終了したタスク(PPEにあるのでアドレス
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
216 *
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
217 * MY_SPE_NOP が 0 なので、
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
218 * 下のように data > MY_SPE_NOP とかしています。
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
219 * 一目でよくわからない書き方なんで、直したいところですが。。。
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
220 */
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
221 if (data == MY_SPE_STATUS_READY) {
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
222 __debug_ppe("mail_check(): Task List finish\n");
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
223 } else if (data > MY_SPE_NOP) {
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
224 __debug_ppe("mail_check(): recv from 0x%x\n", data);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
225 check_task_finish((HTaskPtr)data);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
226 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
227
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
228 d = q;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
229 q = q->next;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
230
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
231 mailManager->free(d);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
232 }
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
233 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
234
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
235 void*
538
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
236 FifoTaskManagerImpl::allocate(int size, int alignment)
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
237 {
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
238 #ifdef __APPLE__
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
239 return malloc(size);
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
240 #else
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
241 void *buff;
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
242 posix_memalign(&buff, alignment, size);
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
243 return buff;
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
244 #endif
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
245 }
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
246
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
247 void*
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
248 FifoTaskManagerImpl::allocate(int size)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
249 {
538
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
250 #ifdef __APPLE__
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
251 return malloc(size);
538
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
252 #else
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
253 void *buff;
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
254 posix_memalign(&buff, DEFAULT_ALIGNMENT, size);
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
255 return buff;
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 499
diff changeset
256 #endif
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
257 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
258
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
259 Scheduler*
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
260 FifoTaskManagerImpl::get_scheduler() {
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
261 return scheduler;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
262 }
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
263
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
264 /**
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
265 * # # # # # # # #
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
266 * Abstract Factory Pattern
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
267 * # # # # # # #
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
268 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
269 #ifdef __CERIUM_FIFO__
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
270 TaskManagerImpl*
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
271 create_impl(int num)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
272 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
273 return new FifoTaskManagerImpl();
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
274 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 58
diff changeset
275 #endif // __CERIUM_FIFO__
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
276