Mercurial > hg > Game > Cerium
comparison TaskManager/kernel/schedule/SchedTaskArray.cc @ 697:4b6242d03512 draft
TaskArray on going...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 13 Dec 2009 18:45:09 +0900 |
parents | 715bbf0955b5 |
children | 72b2da99e875 |
comparison
equal
deleted
inserted
replaced
696:715bbf0955b5 | 697:4b6242d03512 |
---|---|
6 SchedTaskArray::SchedTaskArray(SchedTaskBase *savedTask_, Task *curTask_, Task *_array) | 6 SchedTaskArray::SchedTaskArray(SchedTaskBase *savedTask_, Task *curTask_, Task *_array) |
7 { | 7 { |
8 savedTask = savedTask_; | 8 savedTask = savedTask_; |
9 task = curTask_; | 9 task = curTask_; |
10 array = _array; | 10 array = _array; |
11 } | |
12 | 11 |
13 /** | |
14 * dma_store の wait を行う | |
15 */ | |
16 SchedTaskArray::~SchedTaskArray() | |
17 { | |
18 inListData.bound = 0; | 12 inListData.bound = 0; |
19 inListData.size = 0; | 13 inListData.size = 0; |
20 inListData.length = 0; | 14 inListData.length = 0; |
21 inListData.element = 0; | 15 inListData.element = 0; |
22 outListData.bound = 0; | 16 outListData.bound = 0; |
23 outListData.size = 0; | 17 outListData.size = 0; |
24 outListData.length = 0; | 18 outListData.length = 0; |
25 outListData.element = 0; | 19 outListData.element = 0; |
26 } | 20 } |
27 | 21 |
22 /** | |
23 */ | |
24 SchedTaskArray::~SchedTaskArray() | |
25 { | |
26 } | |
27 | |
28 static void | 28 static void |
29 bound(ListData *list, void *data) | 29 bound(ListData *list) |
30 { | 30 { |
31 ListEelement elm = list->element; | 31 ListElement *elm = list->element; |
32 void *bound = list->bound; | 32 int *bound = list->bound; |
33 int offset=0; | |
33 for(int i=0;i<list->length;i++) { | 34 for(int i=0;i<list->length;i++) { |
34 // we assume all data is properly aligned | 35 bound[i] = offset; |
35 bound[i] = data; | 36 offset += elm[i].size; |
36 data = (void*)(((char*)data)+elm[i].size); | |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 void | 40 void |
41 SchedTaskArray::read() | 41 SchedTaskArray::read() |
49 // 読むデータが一つもなければ無視 | 49 // 読むデータが一つもなければ無視 |
50 if (task->inData_count == 0) return; | 50 if (task->inData_count == 0) return; |
51 | 51 |
52 inListData.length = task->inData_count; | 52 inListData.length = task->inData_count; |
53 inListData.size = task->inData_total_size(); | 53 inListData.size = task->inData_total_size(); |
54 inListData.element = task->inData(); | 54 inListData.element = task->inListData(); |
55 inListData.bound = scheduler->allocate(inListData.count*sizeof(void*)); | 55 inListData.bound = (int*)scheduler->allocate(inListData.length*sizeof(int)); |
56 | 56 |
57 // load Input Data | 57 // load Input Data |
58 readbuf = scheduler->allocate(inListData.size); | 58 readbuf = scheduler->allocate(inListData.size); |
59 scheduler->dma_loadList(&inListData, readbuf, DMA_READ); | 59 scheduler->dma_loadList(&inListData, readbuf, DMA_READ); |
60 bound(&inListData, readbuf); | 60 bound(&inListData); |
61 | 61 |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 void | 65 void |
70 scheduler->dma_wait(DMA_READ); | 70 scheduler->dma_wait(DMA_READ); |
71 task_list[task->command].wait(scheduler,task->command); | 71 task_list[task->command].wait(scheduler,task->command); |
72 task_list[task->command].run(this, readbuf, writebuf); | 72 task_list[task->command].run(this, readbuf, writebuf); |
73 free(readbuf); | 73 free(readbuf); |
74 // 書き込む領域がなければ無視 | 74 // 書き込む領域がなければ無視 |
75 | |
76 // User 側で作る方法が必要... | |
77 | |
75 if (task->outData_count > 0) { | 78 if (task->outData_count > 0) { |
76 outListData.length = task->outData_count; | 79 outListData.length = task->outData_count; |
77 outListData.size = task->outData_total_size(); | 80 outListData.size = task->outData_total_size(); |
78 outListData.element = task->outData(); | 81 outListData.element = task->outListData(); |
82 outListData.bound = (int*)scheduler->allocate(outListData.length*sizeof(int)); | |
79 | 83 |
80 writebuf = scheduler->allocate(outListData.size); | 84 writebuf = scheduler->allocate(outListData.size); |
81 scheduler->dma_storeList(&outListData, writebuf, DMA_WRITE); | 85 scheduler->dma_storeList(&outListData, writebuf, DMA_WRITE); |
82 bound(&outListData, writebuf); | 86 bound(&outListData); |
83 } | 87 } |
84 } | 88 } |
85 | 89 |
86 void | 90 void |
87 SchedTaskArray::write() | 91 SchedTaskArray::write() |
91 scheduler->dma_wait(DMA_WRITE); | 95 scheduler->dma_wait(DMA_WRITE); |
92 free(writebuf); | 96 free(writebuf); |
93 | 97 |
94 // このTaskArrayは終り。終了を知らせる。 | 98 // このTaskArrayは終り。終了を知らせる。 |
95 if (task->next() >= last()) { | 99 if (task->next() >= last()) { |
96 scheduler->mail_write((memaddr)savedTask->task->self); | 100 SchedTask *s = (SchedTask *)savedTask; |
101 scheduler->mail_write((memaddr)s->task->self); | |
97 free(array); | 102 free(array); |
98 } | 103 } |
99 | 104 |
100 } | 105 } |
101 | 106 |
102 Task *SchedTaskArray::last() | 107 Task *SchedTaskArray::last() |
103 { | 108 { |
104 return (Task*)(((char*)array)+ savedTask->read_size()); | 109 SchedTask *s = (SchedTask *)savedTask; |
110 return (Task*)(((char*)array)+ s->read_size()); | |
105 } | 111 } |
106 | 112 |
107 SchedTaskBase* | 113 SchedTaskBase* |
108 SchedTaskArray::next(Scheduler *scheduler, SchedTaskArrayBase *p) | 114 SchedTaskArray::next(Scheduler *scheduler, SchedTaskBase *p) |
109 { | 115 { |
110 __debug("[SchedTaskArray:%s]\n", __FUNCTION__); | 116 __debug("[SchedTaskArray:%s]\n", __FUNCTION__); |
111 | 117 |
112 | 118 Task *next = task->next(); |
113 if (task->next() < last()) { | 119 if (next < last()) { |
114 // Task List が残っているので、次を準備 | 120 // Task List が残っているので、次を準備 |
115 return (SchedTaskBase*)new SchedTaskArray(savedTask, next, array); | 121 return (SchedTaskBase*)new SchedTaskArray(savedTask, next, array); |
116 } else { | 122 } else { |
117 // このTaskArrayは終り。save していた Task の次を返す。 | 123 // このTaskArrayは終り。save していた Task の次を返す。 |
118 // savedTask の read/exec は実行されない (command = TaskArray) | 124 // savedTask の read/exec は実行されない (command = TaskArray) |
119 return savedTask->next(); | 125 return savedTask->next(scheduler, savedTask); |
120 } | 126 } |
121 } | 127 } |
122 | 128 |
123 | 129 |
124 | 130 |