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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
1 #ifndef INCLUDED_SCHED_TASK_BASE
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
2 #define INCLUDED_SCHED_TASK_BASE
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
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
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
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
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
12
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
13 class SchedTaskBase {
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
14 public:
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
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
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
21
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 42
diff changeset
22 BASE_NEW_DELETE(SchedTaskBase);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 42
diff changeset
23
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
24 // noaction in default
798
2d919c3201f2 virtual clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
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
4a0022cd23fc add forgotten virutal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 798
diff changeset
29 virtual SchedTaskBase* next(Scheduler *, SchedTaskBase*) {return 0;}
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
30
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
31 /* functions */
799
4a0022cd23fc add forgotten virutal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 798
diff changeset
32 virtual void* get_output(void *buff, int index) { return 0; }
798
2d919c3201f2 virtual clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
33 virtual void* get_input(void *buff, int index) { return 0;}
2d919c3201f2 virtual clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
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
2d919c3201f2 virtual clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
74
708
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
75 /* variables */
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
76
797
1db779ac0268 SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 776
diff changeset
77 // SchedTask は、すべて同じ大きさであるべきなので、継承するクラスには、
798
2d919c3201f2 virtual clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
78 // 変数を置かない。ここに、すべて置く。virtual も含めて。
797
1db779ac0268 SchedTask instance variable clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 776
diff changeset
79
708
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
80 // Task を実行するスケジューラ自身
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
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
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
84
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
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
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
88
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
89 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
90 TaskListPtr list;
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
91 // Task の、Tasklist での位置。(task = &list[cur_index-1])
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
92 int cur_index;
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
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
d41c62201b1e cleean up SchedTasks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 403
diff changeset
116
899
1b9418af3127 minor fix..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 895
diff changeset
117 } ;
42
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
118
aa11038dbdc1 *** empty log message ***
gongo
parents:
diff changeset
119 #endif