annotate TaskManager/kernel/main.cc @ 247:0098b5ff0d11

change example
author aaa
date Mon, 01 Jun 2009 19:33:09 +0900
parents 894675539cbf
children 8382f0f8c0b4 f0e800bb9dcc
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>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
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;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14 static char *help_str = "\n\
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 * Cerium program option *\n\
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 -chelp Print this message \n\
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
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 main(int argc, char *argv[])
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 int cpuNum = 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 for (int i = 1; argv[i]; ++i) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 if (strcmp(argv[i], "-cpu") == 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 cpuNum = atoi(argv[++i]);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 if (strcmp(argv[i], "-chelp") == 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 printf("%s\n", help_str);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 return EXIT_SUCCESS;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 manager = new TaskManager(cpuNum);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 manager->init();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36
216
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
37 manager->set_TMend(defaultTMend);
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
38
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
39 if (TMmain(argc, argv) < 0) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 goto FINISH;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 manager->run();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44
216
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
45 (manager->tm_end)();
894675539cbf rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents: 109
diff changeset
46
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 FINISH:
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 delete manager;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 return EXIT_SUCCESS;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51 }