annotate TaskManager/kernel/main.cc @ 273:3e9c0039e15c

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Jun 2009 00:12:47 +0900
parents f872cc000fe0
children 181f693be3d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
273
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 271
diff changeset
2 #include <string.h>
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include <SDL.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "TaskManager.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5
216
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
6 /* User main function */
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
7 extern int TMmain(int argc, char *argv[]);
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
8
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
9 /* Default TMend function */
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
10 static void
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
11 defaultTMend(void) {}
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 TaskManager *manager;
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
14 const char *help_str = "\n\
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 * Cerium program option *\n\
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
16 -help Print this message \n\
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 -cpu Number of CPU (default 1) \n";
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
19 extern const char *usr_help_str;
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
20
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 main(int argc, char *argv[])
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 {
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
24 int machineNum = 1;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 for (int i = 1; argv[i]; ++i) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 if (strcmp(argv[i], "-cpu") == 0) {
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
28 machineNum = atoi(argv[++i]);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 }
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
30 if (strcmp(argv[i], "-help") == 0) {
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
31 if (usr_help_str) {
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
32 printf("%s", usr_help_str);
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
33 }
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
34 printf("%s", help_str);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 return EXIT_SUCCESS;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 242
diff changeset
39 manager = new TaskManager(machineNum);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 manager->init();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41
216
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
42 manager->set_TMend(defaultTMend);
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
43
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
44 if (TMmain(argc, argv) < 0) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 goto FINISH;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 manager->run();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49
216
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
50 (manager->tm_end)();
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
51
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 FINISH:
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 delete manager;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 return EXIT_SUCCESS;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 }