comparison TaskManager/kernel/schedule/SchedTask.h @ 366:09f33c51a204

rename include/TaskManager/* and add memory
author aaa
date Mon, 27 Jul 2009 15:51:18 +0900
parents include/TaskManager/SchedTask.h@b89ba1d96fff
children eab18aa0c7f6
comparison
equal deleted inserted replaced
365:f8769040a5df 366:09f33c51a204
1 #ifndef INCLUDED_SCHED_TASK
2 #define INCLUDED_SCHED_TASK
3
4 #include "base.h"
5 #include "Scheduler.h"
6 #include "SchedTaskBase.h"
7 #include "ListData.h"
8 #include "TaskGroup.h"
9
10 class SchedTask : public SchedTaskBase {
11 public:
12 /* constructor */
13 SchedTask();
14 virtual ~SchedTask();
15
16 BASE_NEW_DELETE(SchedTask);
17
18 SchedTask *smanager;
19
20 private:
21 /* variables */
22
23 // Task を実行するスケジューラ自身
24 Scheduler *__scheduler;
25
26 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task
27 TaskListPtr __list;
28 TaskPtr __task;
29
30 // read/write 用の ListData
31 ListDataPtr __inListData;
32 ListDataPtr __outListData;
33
34 /**
35 * read データ、write 用のバッファ
36 * readbuf には タスク登録時に設定した入力データが入っている。
37 * writebuf にデータを描き込んでおくと、
38 * タスク登録時に設定した出力先に書き込む
39 */
40 void *__readbuf;
41 void *__writebuf;
42
43 // Task の、Tasklist での位置。(task = &list[cur_index-1])
44 int __cur_index;
45
46 // タスク内で生成されたタスクのグループ
47 TaskGroup *__taskGroup;
48
49 // このタスク内で生成されたタスクの数
50 int __renew_flag;
51
52 // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No
53 int __flag_renewTask;
54
55 // タスクがメインメモリ側で生成されたものか、
56 // SPE で生成されたものかによって、データの扱いが変わってくる。
57 // そのために if (__flag_renewTask) を連発するのはよくないので
58 // 関数ポインタで持っておく
59 void (SchedTask::*ex_init)();
60 void (SchedTask::*ex_read)();
61 void (SchedTask::*ex_exec)();
62 void (SchedTask::*ex_write)();
63 SchedTaskBase* (SchedTask::*ex_next)();
64
65 /* functions */
66
67 // override
68 void read();
69 void exec();
70 void write();
71 SchedTaskBase* next(Scheduler *, SchedTaskBase *);
72
73 // ここをユーザが継承して
74 // それぞれのタスクに対応した処理を記述する
75 virtual int run(SchedTask* smanager, void* r, void *w) { return 0; }
76 virtual int run(void* r, void *w) { return 0; }
77
78 int (SchedTask::*run_func)(void* r, void *w);
79 int (SchedTask::*run_func1)(SchedTask* smanager, void* r, void *w);
80
81 //--- System API ---
82 SchedTask* get_nextTask(TaskListPtr list);
83
84 /**
85 * PPE で生成されたタスクに対する
86 * __init__, read,exec,write,next の付属(?)処理
87 */
88 void ex_init_normal();
89 void ex_read_normal();
90 void ex_exec_normal();
91 void ex_write_normal();
92 SchedTaskBase* ex_next_normal();
93
94 /**
95 * SPE で生成されたタスクに対する
96 * __inti__, ead,exec,write,next の付属(?)処理
97 */
98 void ex_init_renew();
99 void ex_read_renew();
100 void ex_exec_renew();
101 void ex_write_renew();
102 SchedTaskBase* ex_next_renew();
103
104 public:
105 /* functions */
106
107 void __setRenew();
108 void __init__(TaskListPtr _list, TaskPtr _task, int index,
109 ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc);
110
111 //--- User API ---
112 int get_cpuid();
113
114 void* get_input(void *buff, int index);
115 void* get_output(void *buff, int index);
116 uint32 get_inputAddr(int index);
117 uint32 get_outputAddr(int index);
118 int get_inputSize(int index);
119 int get_outputSize(int index);
120 int get_param(int index);
121
122 TaskPtr create_task(int cmd);
123 void wait_task(TaskPtr waitTask);
124
125 void* global_alloc(int id, int size);
126 void* global_get(int id);
127 void global_free(int id);
128
129 void mainMem_alloc(int id, int size);
130 void mainMem_wait();
131 void* mainMem_get(int id);
132
133 void *allocate(int size);
134
135 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
136 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
137 void dma_wait(uint32 mask);
138 void show_dma_wait();
139
140 /*!
141 SPU用の get_input, get_output
142 */
143
144 void* get_input(int index) {
145 return get_input(__readbuf, index);
146 }
147
148 void* get_output(int index) {
149 return get_output(__writebuf, index);
150 }
151 };
152
153 const int SCHED_TASK_NORMAL = 0;
154 const int SCHED_TASK_RENEW = 1;
155
156 extern SchedTask* createSchedTask(TaskPtr);
157
158 #endif
159