Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/SchedTask.h @ 705:55159a5bf2c4
Redering on SIMPLE_TASK
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2009 20:00:42 +0900 |
parents | 61b59376aec5 |
children | 56487849ea2d |
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" | |
619 | 10 #include "HTask.h" |
373 | 11 #include "MemList.h" |
109 | 12 |
634 | 13 |
308 | 14 class SchedTask : public SchedTaskBase { |
15 public: | |
109 | 16 /* constructor */ |
308 | 17 SchedTask(); |
18 virtual ~SchedTask(); | |
88 | 19 |
109 | 20 BASE_NEW_DELETE(SchedTask); |
42 | 21 |
695 | 22 // Task を実行するスケジューラ自身 |
23 Scheduler *scheduler; | |
24 | |
697 | 25 #ifndef SIMPLE_TASK |
26 TaskPtr task; | |
27 memaddr *param; | |
28 // read/write 用の ListData | |
29 ListDataPtr inListData; | |
30 ListDataPtr outListData; | |
31 #else | |
32 SimpleTaskPtr task; | |
33 ListData inListData; | |
34 ListData outListData; | |
35 #endif | |
36 | |
308 | 37 /* variables */ |
395 | 38 |
308 | 39 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
40 TaskListPtr list; |
703 | 41 // Task の、Tasklist での位置。(task = &list[cur_index-1]) |
42 int cur_index; | |
43 private: | |
308 | 44 |
45 /** | |
46 * read データ、write 用のバッファ | |
47 * readbuf には タスク登録時に設定した入力データが入っている。 | |
48 * writebuf にデータを描き込んでおくと、 | |
49 * タスク登録時に設定した出力先に書き込む | |
50 */ | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
51 void *readbuf; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
52 void *writebuf; |
308 | 53 |
54 | |
55 /* functions */ | |
56 | |
57 // override | |
58 void read(); | |
59 void exec(); | |
60 void write(); | |
61 SchedTaskBase* next(Scheduler *, SchedTaskBase *); | |
62 | |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
463
diff
changeset
|
63 // タスクの処理は、task_list に登録された C の関数によっておこなう |
308 | 64 |
65 //--- System API --- | |
66 SchedTask* get_nextTask(TaskListPtr list); | |
373 | 67 |
308 | 68 |
69 public: | |
70 /* functions */ | |
71 | |
683 | 72 #ifdef SIMPLE_TASK |
73 void init(TaskListPtr _list, SimpleTaskPtr _task, int index, | |
74 Scheduler* sc); | |
75 #else | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
76 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
|
77 Scheduler* sc); |
683 | 78 #endif |
308 | 79 |
80 //--- User API --- | |
634 | 81 #ifdef SIMPLE_TASK |
82 int read_size() { return task->r_size; } | |
83 int write_size() { return task->w_size; } | |
84 void set_write_size(int w) { task->w_size = w; } | |
696 | 85 #endif |
698
dcaa40ec963d
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
697
diff
changeset
|
86 virtual void* get_input(void *buff, int index); |
dcaa40ec963d
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
697
diff
changeset
|
87 virtual void* get_output(void *buff, int index); |
dcaa40ec963d
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
697
diff
changeset
|
88 virtual memaddr get_param(int index); |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
89 memaddr get_inputAddr(int index); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
90 memaddr get_outputAddr(int index); |
506 | 91 // 書き出しを追加する API がない... |
308 | 92 int get_inputSize(int index); |
93 int get_outputSize(int index); | |
641
0692b08f1cd6
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
635
diff
changeset
|
94 |
0692b08f1cd6
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
635
diff
changeset
|
95 int get_cpuid(); |
308 | 96 |
97 void* global_alloc(int id, int size); | |
98 void* global_get(int id); | |
373 | 99 void global_set(int id, void *addr); |
308 | 100 void global_free(int id); |
373 | 101 MemList* createMemList(int size, int count); |
308 | 102 |
103 void mainMem_alloc(int id, int size); | |
104 void mainMem_wait(); | |
629
8843edf37c0e
Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
105 memaddr mainMem_get(int id); |
308 | 106 |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
107 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
|
108 uint32 get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
109 void put_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
110 void wait_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
111 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
112 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
113 |
308 | 114 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
|
115 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
|
116 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
|
117 } |
308 | 118 |
506 | 119 /* これは禁止するべき */ |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
120 void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
121 void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask); |
308 | 122 void dma_wait(uint32 mask); |
674
bde5f13adf10
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
123 |
334
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
316
diff
changeset
|
124 void show_dma_wait(); |
672 | 125 void start_profile(); |
373 | 126 |
674
bde5f13adf10
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
127 |
310 | 128 /*! |
129 SPU用の get_input, get_output | |
130 */ | |
131 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
|
132 return get_input(readbuf, index); |
310 | 133 } |
373 | 134 |
310 | 135 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
|
136 return get_output(writebuf, index); |
373 | 137 } |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
138 |
619 | 139 // user |
140 HTaskPtr create_task(int cmd); | |
634 | 141 HTaskPtr create_task(int cmd, memaddr r, long rs, memaddr w, long ws); |
142 | |
619 | 143 void set_task_depend(HTaskPtr master, HTaskPtr slave); |
144 void spawn_task(HTaskPtr); | |
145 void set_task_cpu(HTaskPtr, CPU_TYPE); | |
146 void* allocate(int size,int align); | |
147 Scheduler* get_scheduler(); | |
674
bde5f13adf10
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
148 long get_random(); |
619 | 149 |
672 | 150 |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
151 /* system call */ |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
152 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
153 FILE *stdout_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
154 FILE *stderr_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
155 FILE *stdin_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
156 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
|
157 int printf(const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
158 |
302 | 159 }; |
109 | 160 |
308 | 161 |
683 | 162 #ifdef SIMPLE_TASK |
163 extern SchedTask* createSchedTask(Scheduler *,SimpleTaskPtr); | |
164 #else | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
165 extern SchedTask* createSchedTask(Scheduler *,TaskPtr); |
683 | 166 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
167 |
695 | 168 extern void loadSchedTask(Scheduler *scheduler,TaskPtr task); |
302 | 169 |
170 #endif | |
308 | 171 |