Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/SchedTask.h @ 672:3b6290c05f9f
add profiling code
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 05 Dec 2009 20:20:08 +0900 |
parents | bffdede05f1e |
children | bde5f13adf10 |
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 #ifdef SIMPLE_TASK |
14 #define Task SimpleTask | |
15 #define TaskPtr SimpleTaskPtr | |
16 #endif | |
17 | |
308 | 18 class SchedTask : public SchedTaskBase { |
19 public: | |
109 | 20 /* constructor */ |
308 | 21 SchedTask(); |
22 virtual ~SchedTask(); | |
88 | 23 |
109 | 24 BASE_NEW_DELETE(SchedTask); |
42 | 25 |
308 | 26 private: |
27 /* variables */ | |
28 | |
29 // Task を実行するスケジューラ自身 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
30 Scheduler *scheduler; |
395 | 31 |
308 | 32 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
33 TaskListPtr list; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
34 TaskPtr task; |
308 | 35 |
567 | 36 // read/write 用の ListData |
37 ListDataPtr inListData; | |
38 ListDataPtr outListData; | |
641
0692b08f1cd6
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
635
diff
changeset
|
39 #ifndef SIMPLE_TASK |
634 | 40 memaddr *param; |
41 #endif | |
567 | 42 |
308 | 43 /** |
44 * read データ、write 用のバッファ | |
45 * readbuf には タスク登録時に設定した入力データが入っている。 | |
46 * writebuf にデータを描き込んでおくと、 | |
47 * タスク登録時に設定した出力先に書き込む | |
48 */ | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
49 void *readbuf; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
50 void *writebuf; |
308 | 51 |
52 // 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
|
53 int cur_index; |
308 | 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 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
72 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
|
73 // ListDataPtr rbuf, ListDataPtr wbuf, |
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
74 Scheduler* sc); |
308 | 75 |
76 //--- User API --- | |
634 | 77 #ifdef SIMPLE_TASK |
78 int read_size() { return task->r_size; } | |
79 int write_size() { return task->w_size; } | |
80 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
|
81 #else |
308 | 82 void* get_input(void *buff, int index); |
83 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
|
84 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
|
85 memaddr get_outputAddr(int index); |
506 | 86 // 書き出しを追加する API がない... |
308 | 87 int get_inputSize(int index); |
88 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
|
89 memaddr get_param(int index); |
641
0692b08f1cd6
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
635
diff
changeset
|
90 #endif |
0692b08f1cd6
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
635
diff
changeset
|
91 |
0692b08f1cd6
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
635
diff
changeset
|
92 int get_cpuid(); |
308 | 93 |
94 void* global_alloc(int id, int size); | |
95 void* global_get(int id); | |
373 | 96 void global_set(int id, void *addr); |
308 | 97 void global_free(int id); |
373 | 98 MemList* createMemList(int size, int count); |
308 | 99 |
100 void mainMem_alloc(int id, int size); | |
101 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
|
102 memaddr mainMem_get(int id); |
308 | 103 |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
104 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
|
105 uint32 get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
106 void put_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
107 void wait_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
108 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
109 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
110 |
308 | 111 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
|
112 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
|
113 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
|
114 } |
308 | 115 |
506 | 116 /* これは禁止するべき */ |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
117 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
|
118 void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask); |
308 | 119 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
|
120 void show_dma_wait(); |
672 | 121 void start_profile(); |
373 | 122 |
310 | 123 /*! |
124 SPU用の get_input, get_output | |
125 */ | |
643 | 126 #ifndef SIMPLE_TASK |
310 | 127 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
|
128 return get_input(readbuf, index); |
310 | 129 } |
373 | 130 |
310 | 131 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
|
132 return get_output(writebuf, index); |
373 | 133 } |
643 | 134 #endif |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
135 |
619 | 136 // user |
137 HTaskPtr create_task(int cmd); | |
634 | 138 HTaskPtr create_task(int cmd, memaddr r, long rs, memaddr w, long ws); |
139 | |
619 | 140 void set_task_depend(HTaskPtr master, HTaskPtr slave); |
141 void spawn_task(HTaskPtr); | |
142 void set_task_cpu(HTaskPtr, CPU_TYPE); | |
143 void* allocate(int size,int align); | |
144 Scheduler* get_scheduler(); | |
145 | |
672 | 146 |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
147 /* system call */ |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
148 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
149 FILE *stdout_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
150 FILE *stderr_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
151 FILE *stdin_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
152 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
|
153 int printf(const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
154 |
302 | 155 }; |
109 | 156 |
308 | 157 |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
158 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
|
159 |
302 | 160 |
161 #endif | |
308 | 162 |