annotate TaskManager/kernel/main.cc @ 1060:b4b35255a99c draft

spuidle fix.
author tkaito@henri
date Wed, 15 Dec 2010 18:00:05 +0900
parents 8cd123d2f3ca
children ca73615ab585
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 #include <stdlib.h>
275
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 273
diff changeset
2 #include <string.h>
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include <SDL.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "TaskManager.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
6 /*!
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
7 User が書いた TMmain() (*名前は固定) を実行する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
8 */
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
21
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
22 /*!
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
23 const char *usr_help_str を User 側で指定する必要がある
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
24 -help で出力される文字列
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
25 */
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
26 const char *help_str = "\n\
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 -cpu Number of CPU (default 1) \n";
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 main(int argc, char *argv[])
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 {
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
36 int machineNum = 1;
1057
8cd123d2f3ca debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents: 736
diff changeset
37 int spuIdle = 6;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 for (int i = 1; argv[i]; ++i) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 if (strcmp(argv[i], "-cpu") == 0) {
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
40 machineNum = atoi(argv[++i]);
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
41 } else if (strcmp(argv[i], "-p") == 0) {
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
42 profile = 1;
1057
8cd123d2f3ca debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents: 736
diff changeset
43 } else if (strcmp(argv[i], "-spuidle") == 0) {
1060
b4b35255a99c spuidle fix.
tkaito@henri
parents: 1057
diff changeset
44 spuIdle = atoi(argv[++i]);
1057
8cd123d2f3ca debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents: 736
diff changeset
45 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
48 TaskManager *manager = new TaskManager(machineNum);
1057
8cd123d2f3ca debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents: 736
diff changeset
49 manager->init(spuIdle);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
51 manager->set_TMend(defaultTMend);
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
52
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
53 for (int i = 1; argv[i]; ++i) {
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
54 if (strcmp(argv[i], "-help") == 0) {
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
55 if (usr_help_str) {
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
56 manager->get_scheduler()->printf("%s", usr_help_str);
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
57 }
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
58 manager->get_scheduler()->printf("%s", help_str);
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
59 return EXIT_SUCCESS;
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
60 }
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 674
diff changeset
61 }
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
62 if (profile)
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
63 manager->start_profile();
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
64 if (TMmain(manager, argc, argv) < 0) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 goto FINISH;
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 manager->run();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69
397
ce86b0186a4a delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
70 (manager->tm_end)(manager);
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
71 if (profile)
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
72 manager->show_profile();
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
73 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
74
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 FINISH:
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 delete manager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 return EXIT_SUCCESS;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79 }
674
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
80
07351a5a51c9 fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 673
diff changeset
81 /* end */