Mercurial > hg > Members > kono > Cerium
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 |
rev | line source |
---|---|
109 | 1 #include <stdlib.h> |
2 #include <string.h> | |
3 #include <SDL.h> | |
4 #include "TaskManager.h" | |
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 | 12 |
13 TaskManager *manager; | |
14 static char *help_str = "\n\ | |
15 * Cerium program option *\n\ | |
16 -chelp Print this message \n\ | |
17 -cpu Number of CPU (default 1) \n"; | |
18 | |
19 int | |
20 main(int argc, char *argv[]) | |
21 { | |
22 int cpuNum = 1; | |
23 | |
24 for (int i = 1; argv[i]; ++i) { | |
25 if (strcmp(argv[i], "-cpu") == 0) { | |
26 cpuNum = atoi(argv[++i]); | |
27 } | |
28 if (strcmp(argv[i], "-chelp") == 0) { | |
29 printf("%s\n", help_str); | |
30 return EXIT_SUCCESS; | |
31 } | |
32 } | |
33 | |
34 manager = new TaskManager(cpuNum); | |
35 manager->init(); | |
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 | 40 goto FINISH; |
41 } | |
42 | |
43 manager->run(); | |
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 | 47 FINISH: |
48 delete manager; | |
49 | |
50 return EXIT_SUCCESS; | |
51 } |