annotate example/README @ 109:028ffc9c0375 draft

Cerium cvs version
author gongo@gendarme.local
date Wed, 12 Nov 2008 17:39:33 +0900
parents
children d9ea79aac04f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 /**
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 * 現在開発中なので、仕様やここに書いてる事も
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 * すごい頻度で変わる可能性があります。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 * なので、定期的に cvs update をしたり
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 * Game_project/Cerium/TaskManager/Changelog を見たり
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 * http://www.cr.ie.u-ryukyu.ac.jp/~game/pukiwiki/ を見てください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 Cerium の例題っぽいのを置いてあります。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 ここにある書き方を参考に他にいろいろ作ってみてください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12 例題の概要は、各ディレクトリの README に書いてあります。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 使用方法や実行例も同じです。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 -----------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 最近の更新
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 -----------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 2008/11/01
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 main 関数はライブラリに閉じました。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 というわけで、ユーザ側の main() は
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 int cerium_main(int argc, char *argv[]);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 となります。引数は通常の main と同じものが渡されます
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 cerium_main で ( < 0 ) を返す (例えば -1) と
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 プログラムが終了するようにしています。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 cerium_main を正常に抜けると、ライブラリ側で
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 main loop が回り、全タスク終了と共にプログラムが終了します。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 あと、Cerium の標準オプションとして
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 -chelp Print this message
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 -cpu Number of CPU (default 1)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 を実装しました。近々増やしていく予定です。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 TaskManager へのアクセスですが、今までは
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 TaskManager *manager = new TaskManager(CPU_NUM);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 とかやってたはずですが、現在はライブラリ側で生成しているので、
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 TaskManager.h を include すると、中で
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 extern TaskManager *manager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 とかしてるので、そのまま manager->create_task とかして使えます。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 -----------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 修正場所
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 -----------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 今のところ、configure とかそういうのは無いので、
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 ライブラリのパスは手動で書き直さないといけないです。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 各例題の Makefile.def ってところに、
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 TARGET = 例題の実行ファイル名
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 CERIUM = Cerium のパス
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 を書くところがあるので、自分の環境にあう感じで書いてください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 -----------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 コンパイル方法
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 -----------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 MacOSX
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 % make macosx
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71 Linux
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72 % make linux
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
74 PS3 (spe/ 以下もコンパイルされます)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 % make ps3
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 clean するときは普通に
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 % make clean でいいです。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 --------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
85 プログラムの書き方
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 --------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 まだちゃんと仕様書みたいなものをは書いてないので、
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89 ここで記述必須の所を書いておきます。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91 1. タスクの作り方
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
92 2. タスクの登録 (ID との対応付け)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
93 3. 最後に
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
94
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
95 -------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96 1. タスクの作り方
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 -------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
98
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
99 タスクは、一つのクラスとして扱います。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 クラスの宣言 (.h) はこんな感じです。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
102 ++++++++++++++++++++++++++++++++++
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
103 #ifndef INCLUDED_SCHED_TASK
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
104 # include "SchedTask.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105 #endif
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
106
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
107 class Hello : public SchedTask {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
108 public:
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
109 SchedConstructor(Hello);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
110
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
111 int run(void *r, void *w);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
112 };
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
113 ++++++++++++++++++++++++++++++++++
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
114
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
115 以上の記述は必須です。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
116 クラス名と、SchedConstructor() の中身は一緒にしてください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
117 run() がこのクラスの Task としての実装となります。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
118 クラス変数、関数を加えるのはOKです。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
119
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
120
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
121 次に実装 (.cc) です。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
122
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
123 ++++++++++++++++++++++++++++++++++
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
124 #include "Hello.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
125
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
126 /* これは必須 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
127 SchedDefineTask(Hello);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
128
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
129 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
130 Hello::run(void *rbuf, void *wbuf)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
131 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
132 printf("Hello, World!!\n");
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
133
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
134 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
135 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
136 ++++++++++++++++++++++++++++++++++
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
137
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
138 SchedDefineTask にもクラス名を入れてください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
139 rbuf, wbuf とかの使い方は 各例題を見ればわかります(basic とか)。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
140
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
141
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
142
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
143 -------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
144 2 タスクの登録
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
145 -------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
146
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
147 タスクは ID で管理するようにしています。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
148 ppe で動くタスクは ppe/ 以下の task_init.cc で書きます。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
149
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
150 ++++++++++++++++++++++++
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
151 #include "Func.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
152 #include "Scheduler.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
153
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
154 /* 必ずこの位置に書いて */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
155 SchedExternTask(Hello);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
156
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
157 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
158 task_init(void)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
159 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
160 SchedRegisterTask(HELLO_TASK, Hello);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
161 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
162 ++++++++++++++++++++++++
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
163
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
164 SchedExternTask と SchedRegisterTask は必須です。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
165 RegisterTask では、クラス名の他に、対応する ID を入れてください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
166 ID は 整数で、現在は 0〜31 まで設定できます。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
167 上の場合は、Func.h で HELLO_TASK を enum でやってます。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
168
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
169 SPE で動かすタスクも、spe/spe-main.cc に書いてください。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
170 書き方は ppe と同じです。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
171
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
172
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
173 -------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
174 3. 最後に
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
175 -------------------
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
176 「もう書く事ねーのかよ」って意見もあるかもしれない。すまん。
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
177 一番上にあるように、まだまだ開発の初期っつーかなんつーか、なので
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
178 これからどんどん追加していきますので。