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