annotate TaskManager/kernel/main.cc @ 242:23e76c5369b7 draft

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