Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/main.cc @ 1323:68373985b251 draft
minor change collada file reader.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 20 Dec 2011 13:08:51 +0900 |
parents | b194cb2d44bb |
children | 5b024efa2429 |
rev | line source |
---|---|
109 | 1 #include <stdlib.h> |
275 | 2 #include <string.h> |
1216 | 3 #include <SDL.h> |
109 | 4 #include "TaskManager.h" |
5 | |
321 | 6 /*! |
7 User が書いた TMmain() (*名前は固定) を実行する | |
8 */ | |
9 | |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
10 /* User main function */ |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
321
diff
changeset
|
11 extern int TMmain(TaskManager* manager, int argc, char *argv[]); |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
12 |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
13 static int profile = 0; |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
14 |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
15 /* Default TMend function */ |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
16 static void |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
17 defaultTMend(TaskManager *manager) { |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
18 } |
109 | 19 |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
321
diff
changeset
|
20 //TaskManager *manager; |
321 | 21 |
22 /*! | |
23 const char *usr_help_str を User 側で指定する必要がある | |
24 -help で出力される文字列 | |
25 */ | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
26 const char *help_str = "\n\ |
109 | 27 * Cerium program option *\n\ |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
28 -help Print this message \n\ |
109 | 29 -cpu Number of CPU (default 1) \n"; |
30 | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
31 extern const char *usr_help_str; |
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
32 |
109 | 33 int |
34 main(int argc, char *argv[]) | |
35 { | |
1147 | 36 int machineNum = 0; |
1066 | 37 int speIdle = 0; |
1123 | 38 int poll_pattern = 0; |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
39 int useRefDma = 0; |
1105 | 40 |
109 | 41 for (int i = 1; argv[i]; ++i) { |
42 if (strcmp(argv[i], "-cpu") == 0) { | |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
43 machineNum = atoi(argv[++i]); |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
44 } else if (strcmp(argv[i], "-p") == 0) { |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
45 profile = 1; |
1061
ca73615ab585
command option name changed (spuidle -> speidle)
tkaito@henri
parents:
1060
diff
changeset
|
46 } else if (strcmp(argv[i], "-speidle") == 0) { |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
47 speIdle = atoi(argv[++i]); |
1123 | 48 } else if (strcmp(argv[i], "-poll") == 0) { |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
49 poll_pattern = 1; |
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
50 } else if (strcmp(argv[i], "-ref") == 0) { |
1288
b194cb2d44bb
add choose function
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1229
diff
changeset
|
51 useRefDma |= 0x01; |
b194cb2d44bb
add choose function
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1229
diff
changeset
|
52 } else if (strcmp(argv[i], "-pre") == 0) { |
b194cb2d44bb
add choose function
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1229
diff
changeset
|
53 useRefDma |= 0x10; |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
54 } |
1105 | 55 } |
1104 | 56 |
1113
d2d44bc55fa1
changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.
tkaito
parents:
1105
diff
changeset
|
57 TaskManager *manager = new TaskManager(machineNum); |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1216
diff
changeset
|
58 manager->init(speIdle,useRefDma); |
109 | 59 |
1113
d2d44bc55fa1
changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.
tkaito
parents:
1105
diff
changeset
|
60 manager->set_TMend(defaultTMend); |
d2d44bc55fa1
changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.changeset 1105 fix.
tkaito
parents:
1105
diff
changeset
|
61 |
1105 | 62 for (int i = 1; argv[i]; ++i) { |
63 if (strcmp(argv[i], "-help") == 0) { | |
64 if (usr_help_str) { | |
65 manager->get_scheduler()->printf("%s", usr_help_str); | |
66 } | |
67 manager->get_scheduler()->printf("%s", help_str); | |
68 return EXIT_SUCCESS; | |
69 } | |
70 } | |
71 | |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
72 if (profile) |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
73 manager->start_profile(); |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
321
diff
changeset
|
74 if (TMmain(manager, argc, argv) < 0) { |
109 | 75 goto FINISH; |
76 } | |
77 | |
78 manager->run(); | |
79 | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
321
diff
changeset
|
80 (manager->tm_end)(manager); |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
81 if (profile) |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
82 manager->show_profile(); |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
83 manager->run(); // tm_end/show_profile may create a Task.. |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
84 |
109 | 85 FINISH: |
86 delete manager; | |
87 | |
88 return EXIT_SUCCESS; | |
89 } | |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
90 |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
673
diff
changeset
|
91 /* end */ |