Mercurial > hg > Members > kono > Cerium
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 |
rev | line source |
---|---|
109 | 1 #include <stdlib.h> |
273 | 2 #include <string.h> |
109 | 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; | |
253
1d8b8a4ac453
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
14 const char *help_str = "\n\ |
109 | 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 | 17 -cpu Number of CPU (default 1) \n"; |
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 | 21 int |
22 main(int argc, char *argv[]) | |
23 { | |
253
1d8b8a4ac453
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
24 int machineNum = 1; |
109 | 25 |
26 for (int i = 1; argv[i]; ++i) { | |
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 | 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 | 35 return EXIT_SUCCESS; |
36 } | |
37 } | |
38 | |
253
1d8b8a4ac453
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
39 manager = new TaskManager(machineNum); |
109 | 40 manager->init(); |
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 | 45 goto FINISH; |
46 } | |
47 | |
48 manager->run(); | |
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 | 52 FINISH: |
53 delete manager; | |
54 | |
55 return EXIT_SUCCESS; | |
56 } |