annotate TaskManager/kernel/main.cc @ 275:237a75ab7a9b draft

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Jun 2009 00:12:47 +0900
parents ec6729fab209
children 4871fc824525
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
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
6 /* User main function */
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
7 extern int TMmain(int argc, char *argv[]);
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
8
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
9 /* Default TMend function */
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
10 static void
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
11 defaultTMend(void) {}
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 TaskManager *manager;
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
14 const char *help_str = "\n\
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 * Cerium program option *\n\
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
16 -help Print this message \n\
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 -cpu Number of CPU (default 1) \n";
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
19 extern const char *usr_help_str;
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
20
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 main(int argc, char *argv[])
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 {
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
24 int machineNum = 1;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 for (int i = 1; argv[i]; ++i) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 if (strcmp(argv[i], "-cpu") == 0) {
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
28 machineNum = atoi(argv[++i]);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 }
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
30 if (strcmp(argv[i], "-help") == 0) {
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
31 if (usr_help_str) {
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
32 printf("%s", usr_help_str);
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
33 }
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
34 printf("%s", help_str);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 return EXIT_SUCCESS;
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
253
0c9c9906d777 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
39 manager = new TaskManager(machineNum);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 manager->init();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
42 manager->set_TMend(defaultTMend);
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
43
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
44 if (TMmain(argc, argv) < 0) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 goto FINISH;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 manager->run();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49
216
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
50 (manager->tm_end)();
e9a52d68db42 rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
51
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 FINISH:
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 delete manager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 return EXIT_SUCCESS;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 }