annotate TaskManager/kernel/schedule/SchedTaskBase.h @ 941:0c11c2fd7e63

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