Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/Scheduler.cc @ 621:5b178db5988a
Cell fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Nov 2009 03:34:18 +0900 |
parents | 0decff4e867b |
children | 60aa3f241b10 |
rev | line source |
---|---|
48 | 1 #include <stdio.h> |
50 | 2 #include <stdlib.h> |
42 | 3 #include "Scheduler.h" |
4 #include "SchedNop.h" | |
5 #include "error.h" | |
386 | 6 #include <assert.h> |
621 | 7 #include "TaskManagerImpl.h" |
42 | 8 |
313
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
9 /* |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
10 * Edit kernel/schedule/xx.cc, Cell/spe/xx.cc will be over writen by this. |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
11 * Do not edit Cell/spe/xx.cc unless there is no kernel/schedule/xx.cc files. |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
12 */ |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
13 |
109 | 14 Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; |
15 | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
16 Scheduler::~Scheduler() |
109 | 17 { |
18 delete connector; | |
19 } | |
20 | |
301
bcb81858aa62
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
21 /*! @brief speTaskの入出力のパイプラインバッファを確保する |
bcb81858aa62
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
22 */ |
bcb81858aa62
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
23 |
42 | 24 void |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
25 Scheduler::init() |
42 | 26 { |
388
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
27 hash = 0; |
42 | 28 init_impl(); |
109 | 29 |
30 for (int i = 0; i < 2; i++) { | |
373 | 31 buff_taskList[i] = (TaskListPtr)allocate(sizeof(TaskList)); |
109 | 32 } |
373 | 33 |
109 | 34 buffFlag_taskList = 0; |
35 | |
298 | 36 // bzero でもいいけど |
109 | 37 for (int i = 0; i < MAX_GLOBAL_AREA; i++) { |
373 | 38 globalList[i] = NULL; |
109 | 39 } |
40 | |
41 for (int i = 0; i < MAX_MAINMEM_AREA; i++) { | |
373 | 42 mainMemList[i] = NULL; |
109 | 43 } |
373 | 44 |
109 | 45 |
42 | 46 } |
47 | |
48 void | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
49 Scheduler::run() |
42 | 50 { |
51 task1 = new SchedNop(); | |
52 task2 = new SchedNop(); | |
53 task3 = new SchedNop(); | |
54 | |
55 // main loop | |
56 do { | |
373 | 57 __debug("----------\n"); |
58 task3->write(); | |
59 task2->exec(); | |
60 task1->read(); | |
468
bd5b93d39597
test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
61 delete task3; |
42 | 62 |
373 | 63 task3 = task2; |
64 task2 = task1; | |
468
bd5b93d39597
test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
65 task1 = task1->next(this, 0); |
42 | 66 } while (task1); |
67 | |
68 delete task3; | |
69 delete task2; | |
50 | 70 } |
48 | 71 |
50 | 72 |
73 void | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
74 Scheduler::finish() |
50 | 75 { |
109 | 76 free(buff_taskList[0]); |
77 free(buff_taskList[1]); | |
42 | 78 } |
79 | |
109 | 80 /** |
298 | 81 * あらかじめ memory allocte してある TaskList の領域を |
82 * パイプラインの各処理が交代して使う。 | |
109 | 83 */ |
42 | 84 TaskListPtr |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
85 Scheduler::get_curListBuf() |
42 | 86 { |
109 | 87 buffFlag_taskList ^= 1; |
88 | |
89 return buff_taskList[buffFlag_taskList]; | |
90 } | |
91 | |
92 | |
93 void | |
94 Scheduler::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) | |
95 { | |
96 connector->dma_load(buf, addr, size, mask); | |
97 } | |
98 | |
99 void | |
100 Scheduler::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask) | |
101 { | |
102 connector->dma_store(buf, addr, size, mask); | |
103 } | |
104 | |
105 void | |
106 Scheduler::dma_wait(uint32 mask) | |
107 { | |
108 connector->dma_wait(mask); | |
109 } | |
110 | |
111 void | |
112 Scheduler::dma_loadList(ListDataPtr list, void *buff, uint32 mask) | |
113 { | |
114 connector->dma_loadList(list, buff, mask); | |
42 | 115 } |
116 | |
117 | |
109 | 118 void |
119 Scheduler::dma_storeList(ListDataPtr list, void *buff, uint32 mask) | |
120 { | |
121 return connector->dma_storeList(list, buff, mask); | |
122 } | |
123 | |
124 void | |
125 Scheduler::mail_write(uint32 data) | |
126 { | |
127 connector->mail_write(data); | |
128 } | |
129 | |
130 uint32 | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
131 Scheduler::mail_read() |
109 | 132 { |
133 return connector->mail_read(); | |
134 } | |
135 | |
136 | |
386 | 137 /* |
138 ここから下は、memory 以下にあるべき | |
139 */ | |
140 | |
109 | 141 void* |
142 Scheduler::global_alloc(int id, int size) | |
143 { | |
144 globalList[id] = allocate(size); | |
145 return globalList[id]; | |
146 } | |
147 | |
148 void* | |
149 Scheduler::global_get(int id) | |
150 { | |
151 return globalList[id]; | |
152 } | |
153 | |
154 void | |
373 | 155 Scheduler::global_set(int id, void *addr) |
156 { | |
157 globalList[id] = addr; | |
158 } | |
159 | |
160 void | |
109 | 161 Scheduler::global_free(int id) |
162 { | |
163 free(globalList[id]); | |
164 globalList[id] = NULL; | |
165 } | |
166 | |
167 /** | |
298 | 168 * mainMem_alloc で確保したメインメモリの領域アドレスを返す。 |
169 * これは Fifo, Cell で共通 | |
109 | 170 */ |
171 void* | |
172 Scheduler::mainMem_get(int id) | |
173 { | |
174 return mainMemList[id]; | |
42 | 175 } |
176 | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
177 /** |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
178 * Task load API |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
179 */ |
425 | 180 void |
442 | 181 Scheduler::allocate_code_segment(int size, int count) |
425 | 182 { |
437 | 183 // 既に overlay 領域があるので、それを追加する必要がある... |
442 | 184 code_segment_pool = createMemList(size, count); |
425 | 185 } |
42 | 186 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
187 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
188 load_task(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
189 { |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
190 MemorySegment *s = m->get_segment( |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
191 task_list[task_id].location, |
437 | 192 m->code_segment_pool, |
193 task_list[task_id].end-task_list[task_id].location); | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
194 task_list[task_id].segment = s; |
506 | 195 #if 0 |
461 | 196 fprintf(stderr,"loadng task id %d at 0x%x entry 0x%x\n",task_id, |
197 (unsigned int)(task_list[task_id].segment->data ), | |
198 (unsigned int)( | |
199 (char*)task_list[task_id].segment->data + | |
200 task_list[task_id].entry_offset)); | |
506 | 201 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
202 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
203 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
204 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
205 null_loader(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
206 { |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
207 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
208 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
209 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
210 wait_load(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
211 { |
523 | 212 #if 0 |
442 | 213 MemorySegment *s = task_list[task_id].segment; |
214 if (s) | |
215 fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data); | |
216 else | |
217 fprintf(stderr,"wait load task id %d 000000\n",task_id); | |
506 | 218 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
219 // wait for code segment load |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
220 m->wait_segment(task_list[task_id].segment); |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
221 // calcurate call address |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
222 TaskObjectRun run = |
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
223 (TaskObjectRun)( |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
224 (char*)task_list[task_id].segment->data + |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
225 task_list[task_id].entry_offset); |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
226 task_list[task_id].run = run; |
506 | 227 #if 0 |
439 | 228 fprintf(stderr,"wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
229 (unsigned int)run, |
439 | 230 task_list[task_id].entry_offset); |
506 | 231 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
232 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
233 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
234 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
235 null_waiter(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
236 { |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
237 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
238 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
239 extern void |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
240 register_task(int cmd, TaskObjectRun run) |
42 | 241 { |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
242 task_list[cmd].run = run; |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
243 task_list[cmd].load = null_loader; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
244 task_list[cmd].wait = null_waiter; |
42 | 245 } |
373 | 246 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
247 extern void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
248 register_dynamic_task(int cmd, |
441 | 249 memaddr start, int size, |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
250 TaskObjectRun run, int entry_offset) |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
251 { |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
252 task_list[cmd].run = run; |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
253 task_list[cmd].location = start; |
442 | 254 size &= 0xfffffffe; |
441 | 255 task_list[cmd].end = start+size; |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
256 task_list[cmd].entry_offset = entry_offset; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
257 task_list[cmd].load = load_task; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
258 task_list[cmd].wait = wait_load; |
506 | 259 #if 0 |
439 | 260 fprintf(stderr,"cmd = %d\n",cmd); |
441 | 261 fprintf(stderr,"locatation = 0x%x\n",start); |
262 fprintf(stderr,"end = 0x%x\n",start+size); | |
263 fprintf(stderr,"size = 0x%x\n",size); | |
439 | 264 fprintf(stderr,"entry = 0x%x\n",entry_offset); |
506 | 265 #endif |
439 | 266 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
267 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
268 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
269 |
373 | 270 /*! |
386 | 271 |
272 size 単位のMemory Segment を count 個作る | |
273 | |
373 | 274 @param [size] リストの要素1つのサイズ |
275 @param [count] 要素数 | |
276 @return allocate した領域のポインタ | |
277 | |
278 */ | |
279 MemList* | |
280 Scheduler::createMemList(int size, int count) | |
281 { | |
282 uint32 head_size = round_up16(sizeof(MemorySegment)); | |
283 uint32 seg_size = round_up16(head_size+size); | |
284 char* mseg = (char*)allocate(seg_size*count); | |
285 MemList* mlist = new MemList((MemorySegment*)mseg); | |
286 | |
388
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
287 if (!hash) { |
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
288 hash = new MemHash(); |
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
289 } |
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
290 |
373 | 291 for(int i = 0; i < count; i++) { |
292 MemorySegment* next = (MemorySegment*)(mseg+seg_size*i); | |
293 char* data = (char*)next+head_size; | |
294 next->data = (void*)data; | |
386 | 295 next->size = size; |
395 | 296 next->address = (memaddr)next; |
373 | 297 mlist->addLast(next); |
298 } | |
299 | |
300 return mlist; | |
301 } | |
386 | 302 |
303 /*! | |
304 | |
305 Main Memory のSegmentを取得する | |
306 | |
307 @param [addr] Main Memory のアドレス | |
308 @param [m] Mem List | |
309 @return allocate した領域のポインタ | |
310 memory directory にあるべきだが... | |
311 | |
312 */ | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
313 MemorySegment * |
386 | 314 Scheduler::get_segment(memaddr addr, MemList *m) |
315 { | |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
442
diff
changeset
|
316 MemorySegment *s = m->getFirst(); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
442
diff
changeset
|
317 return get_segment(addr, m, s->size); |
437 | 318 } |
319 | |
320 MemorySegment * | |
321 Scheduler::get_segment(memaddr addr, MemList *m, int size) | |
322 { | |
323 // memory segment のsizeをoverride する場合がある | |
386 | 324 MemorySegment *s = hash->get(addr); |
325 if (s) { | |
326 /* 既に load されている */ | |
439 | 327 // fprintf(stderr,"get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); |
391 | 328 m->moveToFirst(s); |
386 | 329 return s; |
330 } | |
331 | |
332 /* LRU なので、もっとも使われてない segment を上書きする */ | |
333 s = m->getLast(); | |
334 m->moveToFirst(s); | |
335 | |
336 memaddr old_addr = s->address; | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
337 s->tag = get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
338 dma_load(s->data, addr, |
437 | 339 size, s->tag); |
386 | 340 /* 前のをhashから削除 */ |
341 hash->remove(old_addr); | |
342 /* 新しいaddress を登録 */ | |
343 s->address = addr; | |
344 hash->put(s->address, s); | |
345 | |
439 | 346 // fprintf(stderr,"get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); |
347 | |
386 | 348 return s; |
349 } | |
350 | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
351 |
386 | 352 uint32 |
353 Scheduler::get_tag() | |
354 { | |
458 | 355 static int tag = 16; |
356 tag ++; | |
357 tag &= 0x0f; | |
358 return tag+16; | |
386 | 359 } |
360 | |
361 /*! | |
362 | |
363 Main Memory のSegmentを書き出す | |
364 Segment は get_segement されていて、 | |
365 追い出されていてはいけない。 | |
366 それを保証するのは難しい? | |
367 | |
368 @param [addr] Main Memory のアドレス | |
369 @param [m] Mem List | |
370 @return allocate した領域のポインタ | |
371 | |
372 */ | |
373 void | |
374 Scheduler::put_segment(MemorySegment *s) | |
375 { | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
376 dma_store(s->data, s->address, |
386 | 377 s->size, s->tag); |
378 } | |
379 | |
380 /*! | |
381 | |
382 Main Memory のSegmentを読込、書き出しを待つ | |
383 | |
384 @param [id] MemorySegment のid | |
385 | |
386 */ | |
387 void | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
388 Scheduler::wait_segment(MemorySegment *s) |
386 | 389 { |
391 | 390 // えーと、dma してない時には、skip しないとだめなんじゃないの? |
391 | |
392 if (s->tag) dma_wait(s->tag); | |
393 s->tag = 0; | |
386 | 394 } |
395 | |
621 | 396 HTask * Scheduler::create_task(int cmd) { return manager->create_task(cmd); } |
397 void Scheduler::set_task_depend(HTask * master, HTask * slave) { | |
398 manager->set_task_depend(master, slave) ; | |
399 } | |
400 void Scheduler::spawn_task(HTask * t) { manager->spawn_task(t); } | |
401 void Scheduler::set_task_cpu(HTask * t, CPU_TYPE cpu) { manager->set_task_cpu(t,cpu); } | |
402 void* Scheduler::allocate(int size,int align) { return allocate(size); } | |
403 long Scheduler::get_random() { | |
404 #if defined(__SPU__) | |
405 return 0; | |
406 #else | |
407 return random(); | |
408 #endif | |
409 | |
410 } | |
411 | |
386 | 412 /* end */ |