Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/schedule/SchedTaskBase.h @ 916:deed1449a5f4 draft
make SchedTask API virtual (for relocation)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 24 Jul 2010 18:41:24 +0900 |
parents | 1b9418af3127 |
children | e66a08b5cd83 |
rev | line source |
---|---|
42 | 1 #ifndef INCLUDED_SCHED_TASK_BASE |
2 #define INCLUDED_SCHED_TASK_BASE | |
3 | |
301
7f991471d43f
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
109
diff
changeset
|
4 #include "base.h" |
797
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
5 #include <stdio.h> |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
6 #include <stdlib.h> |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
7 |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
799
diff
changeset
|
8 class TaskManagerImpl; |
42 | 9 class Scheduler; |
916
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
10 class MemorySegment; |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
11 class MemList; |
42 | 12 |
13 class SchedTaskBase { | |
14 public: | |
15 /* constructor */ | |
776
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
16 // void *called ; // for debug |
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
17 SchedTaskBase() { |
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
18 // called = __builtin_return_address(1); |
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
19 } |
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
20 virtual ~SchedTaskBase() {} |
42 | 21 |
109 | 22 BASE_NEW_DELETE(SchedTaskBase); |
23 | |
42 | 24 // noaction in default |
798 | 25 // virtual void load() {} |
776
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
26 virtual void read() {} |
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
27 virtual void exec() {} |
922c0133c61c
heap corruption in TaskArray1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
28 virtual void write() {} |
799 | 29 virtual SchedTaskBase* next(Scheduler *, SchedTaskBase*) {return 0;} |
42 | 30 |
31 /* functions */ | |
799 | 32 virtual void* get_output(void *buff, int index) { return 0; } |
798 | 33 virtual void* get_input(void *buff, int index) { return 0;} |
34 virtual memaddr get_param(int index) { return 0;} | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
799
diff
changeset
|
35 virtual int read_size() { return 0;} |
916
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
36 virtual int printf(const char * format, ...) {return 0;}; |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
37 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
38 virtual memaddr get_inputAddr(int index) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
39 virtual memaddr get_outputAddr(int index) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
40 virtual int get_inputSize(int index) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
41 virtual int get_outputSize(int index) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
42 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
43 virtual int get_cpuid() {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
44 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
45 virtual void* global_alloc(int id, int size) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
46 virtual void* global_get(int id) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
47 virtual void global_set(int id, void *addr) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
48 virtual void global_free(int id) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
49 // virtual MemList* createMemList(int size, int count); |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
50 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
51 virtual void mainMem_alloc(int id, int size) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
52 virtual void mainMem_wait() {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
53 virtual memaddr mainMem_get(int id) {return 0; } |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
54 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
55 virtual MemorySegment * get_segment(memaddr addr, MemList *m) {return 0; } |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
56 virtual uint32 get_tag() {return 0; } |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
57 virtual void put_segment(MemorySegment *s) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
58 virtual void wait_segment(MemorySegment *s) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
59 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
60 virtual void *allocate(int size) {return 0; } |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
61 virtual void free_(void *p) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
62 // virtual void polling(); |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
63 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
64 /* これは禁止するべき */ |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
65 virtual void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
66 virtual void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
67 virtual void dma_wait(uint32 mask) {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
68 |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
69 virtual void show_dma_wait() {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
70 virtual void start_profile() {} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
71 virtual void* allocate(int size,int align) {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
72 virtual Scheduler* get_scheduler() {return 0;} |
deed1449a5f4
make SchedTask API virtual (for relocation)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
73 virtual long get_random() {return 0;} |
798 | 74 |
708 | 75 /* variables */ |
76 | |
797
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
77 // SchedTask は、すべて同じ大きさであるべきなので、継承するクラスには、 |
798 | 78 // 変数を置かない。ここに、すべて置く。virtual も含めて。 |
797
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
79 |
708 | 80 // Task を実行するスケジューラ自身 |
81 Scheduler *scheduler; | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
799
diff
changeset
|
82 // Task を作成管理するマネージャー |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
799
diff
changeset
|
83 TaskManagerImpl *manager; |
708 | 84 |
85 SimpleTaskPtr task; | |
797
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
86 TaskPtr atask; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
87 SchedTaskBase *savedTask; |
708 | 88 |
89 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task | |
90 TaskListPtr list; | |
91 // Task の、Tasklist での位置。(task = &list[cur_index-1]) | |
92 int cur_index; | |
93 | |
797
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
94 memaddr params_addr; |
888
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
800
diff
changeset
|
95 memaddr waiter; |
890
a5ccf763fc3f
minor fix. possible schedTaskArray overrun
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
889
diff
changeset
|
96 Task *array; |
797
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
97 |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
98 /** |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
99 * read データ、write 用のバッファ |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
100 * readbuf には タスク登録時に設定した入力データが入っている。 |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
101 * writebuf にデータを描き込んでおくと、 |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
102 * タスク登録時に設定した出力先に書き込む |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
103 */ |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
104 void *readbuf; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
105 void *writebuf; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
106 |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
107 /* system call */ |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
108 |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
109 FILE *stdout_; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
110 FILE *stderr_; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
111 FILE *stdin_; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
112 |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
113 // Task Array しか使わないが、たいした大きさではないのでいいか... |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
114 ListData inListData; |
1db779ac0268
SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
776
diff
changeset
|
115 ListData outListData; |
708 | 116 |
899 | 117 } ; |
42 | 118 |
119 #endif |