Mercurial > hg > Game > Cerium
comparison TaskManager/kernel/schedule/SchedTaskArray.cc @ 708:d41c62201b1e draft
cleean up SchedTasks.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Dec 2009 10:49:30 +0900 |
parents | b2b4a1243961 |
children | 97adb3fe85c6 |
comparison
equal
deleted
inserted
replaced
707:9dc7969daf79 | 708:d41c62201b1e |
---|---|
4 #ifdef SIMPLE_TASK | 4 #ifdef SIMPLE_TASK |
5 | 5 |
6 SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_, Task *curTask_, Task *_array) | 6 SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_, Task *curTask_, Task *_array) |
7 { | 7 { |
8 savedTask = savedTask_; | 8 savedTask = savedTask_; |
9 task = curTask_; | 9 atask = curTask_; |
10 array = _array; | 10 array = _array; |
11 scheduler = s; | 11 scheduler = s; |
12 | 12 |
13 inListData.bound = 0; | 13 inListData.bound = 0; |
14 inListData.size = 0; | 14 inListData.size = 0; |
27 */ | 27 */ |
28 | 28 |
29 SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_) | 29 SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_) |
30 { | 30 { |
31 savedTask = savedTask_; | 31 savedTask = savedTask_; |
32 SchedTask *sv = (SchedTask*)savedTask_; | |
33 scheduler = s; | 32 scheduler = s; |
34 | 33 |
35 inListData.bound = 0; | 34 inListData.bound = 0; |
36 inListData.size = 0; | 35 inListData.size = 0; |
37 inListData.length = 0; | 36 inListData.length = 0; |
39 outListData.bound = 0; | 38 outListData.bound = 0; |
40 outListData.size = 0; | 39 outListData.size = 0; |
41 outListData.length = 0; | 40 outListData.length = 0; |
42 outListData.element = 0; | 41 outListData.element = 0; |
43 | 42 |
44 task = (TaskPtr)&sv->list->tasks[sv->cur_index]; | 43 atask = (TaskPtr)&savedTask->list->tasks[savedTask->cur_index]; |
45 array = 0; | 44 array = 0; |
46 sv->cur_index += (task->size()+sizeof(SimpleTask))/sizeof(SimpleTask); | 45 savedTask->cur_index += (atask->size()+sizeof(SimpleTask))/sizeof(SimpleTask); |
47 | 46 |
48 } | 47 } |
49 | 48 |
50 /** | 49 /** |
51 */ | 50 */ |
52 SchedTaskArray::~SchedTaskArray() | 51 SchedTaskArray::~SchedTaskArray() |
53 { | 52 { |
54 } | 53 } |
55 | 54 |
55 /** | |
56 * DMA buffer offset in rbuf | |
57 */ | |
56 static void | 58 static void |
57 bound(ListData *list) | 59 bound(ListData *list) |
58 { | 60 { |
59 ListElement *elm = list->element; | 61 ListElement *elm = list->element; |
60 int *bound = list->bound; | 62 int *bound = list->bound; |
63 bound[i] = offset; | 65 bound[i] = offset; |
64 offset += elm[i].size; | 66 offset += elm[i].size; |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
70 /** | |
71 * Task data / code read | |
72 */ | |
68 void | 73 void |
69 SchedTaskArray::read() | 74 SchedTaskArray::read() |
70 { | 75 { |
71 __debug("[SchedTaskArrayArray:%s]\n", __FUNCTION__); | |
72 | 76 |
73 // object creation をSchedTaskArray生成時にやらないので、 | 77 // object creation をSchedTaskArray生成時にやらないので、 |
74 // exec の直前のread で十分に間に合う | 78 // exec の直前のread で十分に間に合う |
75 loadSchedTask(scheduler, task->command); | 79 loadSchedTask(scheduler, atask->command); |
76 | 80 |
77 // 読むデータが一つもなければ無視 | 81 // 読むデータが一つもなければ無視 |
78 if (task->inData_count == 0) return; | 82 if (atask->inData_count == 0) return; |
79 | 83 |
80 inListData.length = task->inData_count; | 84 inListData.length = atask->inData_count; |
81 inListData.size = task->inData_total_size(); | 85 inListData.size = atask->inData_total_size(); |
82 inListData.element = task->inData(0); | 86 inListData.element = atask->inData(0); |
83 inListData.bound = (int*)scheduler->allocate(inListData.length*sizeof(int)); | 87 inListData.bound = (int*)scheduler->allocate(inListData.length*sizeof(int)); |
84 | 88 |
85 // load Input Data | 89 // load Input Data |
86 readbuf = scheduler->allocate(inListData.size); | 90 readbuf = scheduler->allocate(inListData.size); |
87 // inListData.print(); | 91 // inListData.print(); |
88 scheduler->dma_loadList(&inListData, readbuf, DMA_READ); | 92 scheduler->dma_loadList(&inListData, readbuf, DMA_READ); |
89 bound(&inListData); | 93 bound(&inListData); |
90 | 94 |
91 } | 95 } |
92 | 96 |
93 | 97 /** |
98 * Wait read data and execute task | |
99 * Start write DMA | |
100 */ | |
94 void | 101 void |
95 SchedTaskArray::exec() | 102 SchedTaskArray::exec() |
96 { | 103 { |
97 __debug("[SchedTaskArrayArray:%s]\n", __FUNCTION__); | 104 |
98 | 105 if (atask->outData_count > 0) { |
99 if (task->outData_count > 0) { | 106 outListData.length = atask->outData_count; |
100 outListData.length = task->outData_count; | 107 outListData.size = atask->outData_total_size(); |
101 outListData.size = task->outData_total_size(); | 108 outListData.element = atask->outData(0); |
102 outListData.element = task->outData(0); | |
103 outListData.bound = (int*)scheduler->allocate(outListData.length*sizeof(int)); | 109 outListData.bound = (int*)scheduler->allocate(outListData.length*sizeof(int)); |
104 bound(&outListData); | 110 bound(&outListData); |
105 | 111 |
106 writebuf = scheduler->allocate(outListData.size); | 112 writebuf = scheduler->allocate(outListData.size); |
107 } | 113 } |
108 | 114 |
109 scheduler->dma_wait(DMA_READ); | 115 scheduler->dma_wait(DMA_READ); |
110 task_list[task->command].wait(scheduler,task->command); | 116 task_list[atask->command].wait(scheduler,atask->command); |
111 task_list[task->command].run(this, readbuf, writebuf); | 117 task_list[atask->command].run(this, readbuf, writebuf); |
112 free(readbuf); | 118 free(readbuf); |
113 // 書き込む領域がなければ無視 | 119 // 書き込む領域がなければ無視 |
114 | 120 |
115 // User 側で作る方法が必要... | 121 // User 側で作る方法が必要... |
116 | 122 |
117 if (task->outData_count > 0) { | 123 if (atask->outData_count > 0) { |
118 // outListData.print(); | 124 // outListData.print(); |
119 scheduler->dma_storeList(&outListData, writebuf, DMA_WRITE); | 125 scheduler->dma_storeList(&outListData, writebuf, DMA_WRITE); |
120 } | 126 } |
121 } | 127 } |
122 | 128 |
129 /** | |
130 * Wait write DMA | |
131 * send finish mail | |
132 */ | |
123 void | 133 void |
124 SchedTaskArray::write() | 134 SchedTaskArray::write() |
125 { | 135 { |
126 __debug("[SchedTaskArrayArray:%s]\n", __FUNCTION__); | |
127 | 136 |
128 scheduler->dma_wait(DMA_WRITE); | 137 scheduler->dma_wait(DMA_WRITE); |
129 free(writebuf); | 138 free(writebuf); |
130 free(inListData.bound); | 139 free(inListData.bound); |
131 free(outListData.bound); | 140 free(outListData.bound); |
132 | 141 |
133 // このTaskArrayは終り。終了を知らせる。 | 142 // このTaskArrayは終り。終了を知らせる。 |
134 if (!array || task->next() >= last()) { | 143 if (!array || atask->next() >= last()) { |
135 SchedTask *s = (SchedTask *)savedTask; | 144 SchedTask *s = (SchedTask *)savedTask; |
136 scheduler->mail_write((memaddr)s->task->self); | 145 scheduler->mail_write((memaddr)s->task->self); |
137 free(array); | 146 free(array); |
138 } | 147 } |
139 | 148 |
146 } | 155 } |
147 | 156 |
148 SchedTaskBase* | 157 SchedTaskBase* |
149 SchedTaskArray::next(Scheduler *scheduler, SchedTaskBase *p) | 158 SchedTaskArray::next(Scheduler *scheduler, SchedTaskBase *p) |
150 { | 159 { |
151 __debug("[SchedTaskArray:%s]\n", __FUNCTION__); | 160 |
152 | 161 Task *next = atask->next(); |
153 Task *next = task->next(); | |
154 if (next < last()) { | 162 if (next < last()) { |
155 // Task List が残っているので、次を準備 | 163 // Task List が残っているので、次を準備 |
156 return (SchedTaskBase*)new SchedTaskArray(scheduler, savedTask, next, array); | 164 return new SchedTaskArray(scheduler, savedTask, next, array); |
157 } else { | 165 } else { |
158 // このTaskArrayは終り。save していた Task の次を返す。 | 166 // このTaskArrayは終り。save していた Task の次を返す。 |
159 // savedTask の read/exec は実行されない (command = TaskArray) | 167 // savedTask の read/exec は実行されない (command = TaskArray) |
160 return savedTask->next(scheduler, savedTask); | 168 return savedTask->next(scheduler, savedTask); |
161 } | 169 } |
227 } | 235 } |
228 | 236 |
229 memaddr | 237 memaddr |
230 SchedTaskArray::get_param(int index) | 238 SchedTaskArray::get_param(int index) |
231 { | 239 { |
232 return *task->param(index); | 240 return *atask->param(index); |
233 } | 241 } |
234 | 242 |
235 #endif | 243 #endif |
236 | 244 |
237 /* end */ | 245 /* end */ |