comparison TaskManager/kernel/schedule/SchedTask.cc @ 634:0558abba673c

SimpleTask start
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 18 Nov 2009 17:29:14 +0900
parents 8843edf37c0e
children 8cc609285bbe
comparison
equal deleted inserted replaced
633:328ab8ac468d 634:0558abba673c
25 /** 25 /**
26 code load を始める。既に get_segment hash に入っていれば何もしない。 26 code load を始める。既に get_segment hash に入っていれば何もしない。
27 最初の一回は SchedTaskList:: next から呼ばれる。 27 最初の一回は SchedTaskList:: next から呼ばれる。
28 この段階では、SchedTask object は、まだ作られてない。 28 この段階では、SchedTask object は、まだ作られてない。
29 */ 29 */
30 void 30 static void
31 loadSchedTask(Scheduler *scheduler,TaskPtr task) 31 loadSchedTask(Scheduler *scheduler,TaskPtr task)
32 { 32 {
33 // fprintf(stderr,"loadSchedTask %d\n",task->command); 33 // fprintf(stderr,"loadSchedTask %d\n",task->command);
34 task_list[task->command].load(scheduler,task->command); 34 task_list[task->command].load(scheduler,task->command);
35 } 35 }
37 37
38 SchedTask::SchedTask() 38 SchedTask::SchedTask()
39 { 39 {
40 list = NULL; 40 list = NULL;
41 task = NULL; 41 task = NULL;
42 #ifndef SIMPLE_TASK
42 inListData = NULL; 43 inListData = NULL;
43 outListData = NULL; 44 outListData = NULL;
45 #endif
44 readbuf = NULL; 46 readbuf = NULL;
45 writebuf = NULL; 47 writebuf = NULL;
46 scheduler = NULL; 48 scheduler = NULL;
47 cur_index = 0; 49 cur_index = 0;
48 this->stdout_ = stdout; 50 this->stdout_ = stdout;
65 // ListDataPtr rbuf, ListDataPtr wbuf, 67 // ListDataPtr rbuf, ListDataPtr wbuf,
66 Scheduler* sc) 68 Scheduler* sc)
67 { 69 {
68 list = _list; 70 list = _list;
69 task = _task; 71 task = _task;
72 #ifndef SIMPLE_TASK
70 inListData = &_task->inData; 73 inListData = &_task->inData;
71 outListData = &_task->outData; 74 outListData = &_task->outData;
75 #endif
72 scheduler = sc; 76 scheduler = sc;
73 cur_index = index; 77 cur_index = index;
74 78
75 scheduler->mainMem_wait(); 79 scheduler->mainMem_wait();
76 80
86 // exec の直前のread で十分に間に合う 90 // exec の直前のread で十分に間に合う
87 if (cur_index < list->length) { 91 if (cur_index < list->length) {
88 // load next task 92 // load next task
89 loadSchedTask(scheduler, &list->tasks[cur_index]); 93 loadSchedTask(scheduler, &list->tasks[cur_index]);
90 } 94 }
91 95 #ifdef SIMPLE_TASK
96 writebuf = scheduler->allocate(task->w_size);
97 // 読むデータが一つもなければ無視
98 if (task->r_size == 0) return;
99 // load Input Data
100 readbuf = scheduler->allocate(task->r_size);
101 scheduler->dma_load(readbuf, task->rbuf,task->r_size, DMA_READ);
102 #else
92 writebuf = scheduler->allocate(outListData->size); 103 writebuf = scheduler->allocate(outListData->size);
93 104
94 // 読むデータが一つもなければ無視 105 // 読むデータが一つもなければ無視
95 if (inListData->length == 0) return; 106 if (inListData->length == 0) return;
96 107
97 // load Input Data 108 // load Input Data
98 readbuf = scheduler->allocate(inListData->size); 109 readbuf = scheduler->allocate(inListData->size);
99 scheduler->dma_loadList(inListData, readbuf, DMA_READ); 110 scheduler->dma_loadList(inListData, readbuf, DMA_READ);
111 #endif
100 112
101 113
102 } 114 }
103 115
104 116
111 task_list[task->command].wait(scheduler,task->command); 123 task_list[task->command].wait(scheduler,task->command);
112 task_list[task->command].run(this, readbuf, writebuf); 124 task_list[task->command].run(this, readbuf, writebuf);
113 free(readbuf); 125 free(readbuf);
114 126
115 // 書き込む領域がなければ無視 127 // 書き込む領域がなければ無視
128 #ifdef SIMPLE_TASK
116 if (outListData->length > 0) { 129 if (outListData->length > 0) {
117 scheduler->dma_storeList(outListData, writebuf, DMA_WRITE); 130 scheduler->dma_storeList(outListData, writebuf, DMA_WRITE);
118 } 131 }
132 #else
133 if (task->w_size > 0) {
134 scheduler->dma_store(writebuf, task->wbuf,task->w_size, DMA_READ);
135 }
136 #endif
119 } 137 }
120 138
121 void 139 void
122 SchedTask::write() 140 SchedTask::write()
123 { 141 {
149 if (nextList == 0) { 167 if (nextList == 0) {
150 // もう何もする必要がない 168 // もう何もする必要がない
151 return new SchedNop2Ready(scheduler); 169 return new SchedNop2Ready(scheduler);
152 } else { 170 } else {
153 // 新しいリストに取り掛かる 171 // 新しいリストに取り掛かる
154 return createSchedTaskList(nextList, scheduler, 172 return createSchedTaskList(nextList, scheduler, 0);
155 0);
156 } 173 }
157 } 174 }
158 } 175 }
159 176
160 177
236 } 253 }
237 254
238 memaddr 255 memaddr
239 SchedTask::get_param(int index) 256 SchedTask::get_param(int index)
240 { 257 {
258 #ifdef SIMPLE_TASK
259 return param[index];
260 #else
241 return task->param[index]; 261 return task->param[index];
262 #endif
242 } 263 }
243 264
244 265
245 void* 266 void*
246 SchedTask::global_alloc(int id, int size) { 267 SchedTask::global_alloc(int id, int size) {
314 void SchedTask::wait_segment(MemorySegment *s) { 335 void SchedTask::wait_segment(MemorySegment *s) {
315 scheduler->wait_segment(s); 336 scheduler->wait_segment(s);
316 } 337 }
317 338
318 339
319 HTaskPtr SchedTask::create_task(int cmd) 340 HTaskPtr
341 SchedTask::create_task(int cmd)
320 { 342 {
321 return scheduler->create_task(cmd); 343 return scheduler->create_task(cmd);
322 } 344 }
345
346 HTaskPtr
347 SchedTask::create_task(int cmd, memaddr r, long rs, memaddr w, long ws)
348 {
349 return scheduler->create_task(cmd,r,rs,w,ws);
350 }
351
323 352
324 void SchedTask::set_task_depend(HTaskPtr master, HTaskPtr slave) 353 void SchedTask::set_task_depend(HTaskPtr master, HTaskPtr slave)
325 { 354 {
326 scheduler->set_task_depend(master, slave); 355 scheduler->set_task_depend(master, slave);
327 } 356 }