Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/SchedTask.h @ 567:47b61865ea8c
merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 22 Oct 2009 23:54:58 +0900 |
parents | 5c76db2a07fa |
children | 0decff4e867b |
rev | line source |
---|---|
42 | 1 #ifndef INCLUDED_SCHED_TASK |
2 #define INCLUDED_SCHED_TASK | |
3 | |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
4 #include <stdio.h> |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
5 #include <stdlib.h> |
308 | 6 #include "base.h" |
7 #include "Scheduler.h" | |
8 #include "SchedTaskBase.h" | |
9 #include "ListData.h" | |
10 #include "TaskGroup.h" | |
373 | 11 #include "MemList.h" |
109 | 12 |
308 | 13 class SchedTask : public SchedTaskBase { |
14 public: | |
109 | 15 /* constructor */ |
308 | 16 SchedTask(); |
17 virtual ~SchedTask(); | |
88 | 18 |
109 | 19 BASE_NEW_DELETE(SchedTask); |
42 | 20 |
308 | 21 private: |
22 /* variables */ | |
23 | |
24 // Task を実行するスケジューラ自身 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
25 Scheduler *scheduler; |
395 | 26 |
308 | 27 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
28 TaskListPtr list; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
29 TaskPtr task; |
308 | 30 |
567 | 31 // read/write 用の ListData |
32 ListDataPtr inListData; | |
33 ListDataPtr outListData; | |
34 | |
308 | 35 /** |
36 * read データ、write 用のバッファ | |
37 * readbuf には タスク登録時に設定した入力データが入っている。 | |
38 * writebuf にデータを描き込んでおくと、 | |
39 * タスク登録時に設定した出力先に書き込む | |
40 */ | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
41 void *readbuf; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
42 void *writebuf; |
308 | 43 |
44 // Task の、Tasklist での位置。(task = &list[cur_index-1]) | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
45 int cur_index; |
308 | 46 |
567 | 47 // タスク内で生成されたタスクのグループ |
48 TaskGroup *taskGroup; | |
49 | |
50 // このタスク内で生成されたタスクの数 | |
51 int renew_flag; | |
52 | |
53 // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No | |
54 int flag_renewTask; | |
55 | |
56 // タスクがメインメモリ側で生成されたものか、 | |
57 // SPE で生成されたものかによって、データの扱いが変わってくる。 | |
58 // そのために if (flag_renewTask) を連発するのはよくないので | |
59 // 関数ポインタで持っておく | |
60 void (SchedTask::*ex_init)(); | |
61 void (SchedTask::*ex_read)(); | |
62 void (SchedTask::*ex_exec)(); | |
63 void (SchedTask::*ex_write)(); | |
64 SchedTaskBase* (SchedTask::*ex_next)(); | |
65 | |
308 | 66 /* functions */ |
67 | |
68 // override | |
69 void read(); | |
70 void exec(); | |
71 void write(); | |
72 SchedTaskBase* next(Scheduler *, SchedTaskBase *); | |
73 | |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
463
diff
changeset
|
74 // タスクの処理は、task_list に登録された C の関数によっておこなう |
308 | 75 |
76 //--- System API --- | |
77 SchedTask* get_nextTask(TaskListPtr list); | |
373 | 78 |
567 | 79 /** |
80 * PPE で生成されたタスクに対する | |
81 * init, read,exec,write,next の付属(?)処理 | |
82 */ | |
83 void ex_init_normal(); | |
84 void ex_read_normal(); | |
85 void ex_exec_normal(); | |
86 void ex_write_normal(); | |
87 SchedTaskBase* ex_next_normal(); | |
88 | |
89 /** | |
90 * SPE で生成されたタスクに対する | |
91 * inti, ead,exec,write,next の付属(?)処理 | |
92 */ | |
93 void ex_init_renew(); | |
94 void ex_read_renew(); | |
95 void ex_exec_renew(); | |
96 void ex_write_renew(); | |
97 SchedTaskBase* ex_next_renew(); | |
308 | 98 |
99 public: | |
100 /* functions */ | |
101 | |
567 | 102 void setRenew(); |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
103 void init(TaskListPtr _list, TaskPtr _task, int index, |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
104 // ListDataPtr rbuf, ListDataPtr wbuf, |
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
105 Scheduler* sc); |
308 | 106 |
107 //--- User API --- | |
108 int get_cpuid(); | |
109 | |
110 void* get_input(void *buff, int index); | |
111 void* get_output(void *buff, int index); | |
112 uint32 get_inputAddr(int index); | |
113 uint32 get_outputAddr(int index); | |
506 | 114 // 書き出しを追加する API がない... |
308 | 115 int get_inputSize(int index); |
116 int get_outputSize(int index); | |
117 int get_param(int index); | |
118 | |
506 | 119 |
567 | 120 TaskPtr create_task(int cmd); |
121 void wait_task(TaskPtr waitTask); | |
308 | 122 |
123 void* global_alloc(int id, int size); | |
124 void* global_get(int id); | |
373 | 125 void global_set(int id, void *addr); |
308 | 126 void global_free(int id); |
373 | 127 MemList* createMemList(int size, int count); |
308 | 128 |
129 void mainMem_alloc(int id, int size); | |
130 void mainMem_wait(); | |
131 void* mainMem_get(int id); | |
132 | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
133 MemorySegment * get_segment(memaddr addr, MemList *m); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
134 uint32 get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
135 void put_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
136 void wait_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
137 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
138 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
139 |
308 | 140 void *allocate(int size); |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
141 void free_(void *p) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
142 scheduler->free_(p); |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
143 } |
308 | 144 |
506 | 145 /* これは禁止するべき */ |
308 | 146 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask); |
147 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask); | |
148 void dma_wait(uint32 mask); | |
334
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
316
diff
changeset
|
149 void show_dma_wait(); |
373 | 150 |
310 | 151 /*! |
152 SPU用の get_input, get_output | |
153 */ | |
308 | 154 |
310 | 155 void* get_input(int index) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
156 return get_input(readbuf, index); |
310 | 157 } |
373 | 158 |
310 | 159 void* get_output(int index) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
160 return get_output(writebuf, index); |
373 | 161 } |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
162 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
163 /* system call */ |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
164 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
165 FILE *stdout_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
166 FILE *stderr_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
167 FILE *stdin_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
168 int fprintf(FILE * stream, const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
169 int printf(const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
170 |
302 | 171 }; |
109 | 172 |
567 | 173 const int SCHED_TASK_NORMAL = 0; |
174 const int SCHED_TASK_RENEW = 1; | |
308 | 175 |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
176 extern SchedTask* createSchedTask(Scheduler *,TaskPtr); |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
177 extern void loadSchedTask(Scheduler *scheduler,TaskPtr task); |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
178 |
302 | 179 |
180 #endif | |
308 | 181 |