109
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4 #include "TaskManager.h"
|
|
5 #include "Func.h"
|
|
6
|
|
7 extern void task_init(void);
|
|
8
|
|
9 static int count = 1;
|
|
10
|
|
11 char *help_str = "Usage: ./post [-cpu spe_num] [-count N]\n\
|
|
12 -count Number of print \"Hello, World!!\"";
|
|
13
|
|
14 void
|
|
15 func1(void *p)
|
|
16 {
|
|
17 int i = (int)p;
|
|
18
|
|
19 printf("post function : %d\n", i--);
|
|
20
|
|
21 if (i > 0) {
|
|
22 HTaskPtr next = manager->create_task(HELLO_TASK);
|
|
23 next->add_param(i);
|
|
24 next->set_post(func1, (void*)i);
|
|
25 next->set_cpu(SPE_ANY);
|
|
26 next->spawn();
|
|
27 }
|
|
28 }
|
|
29
|
|
30
|
|
31 int
|
|
32 init(int argc, char **argv)
|
|
33 {
|
|
34 for (int i = 1; argv[i]; ++i) {
|
|
35 if (strcmp(argv[i], "-count") == 0) {
|
|
36 count = atoi(argv[++i]);
|
|
37 }
|
|
38 if (strcmp(argv[i], "--help") == 0) {
|
|
39 printf("%s\n", help_str);
|
|
40 return -1;
|
|
41 }
|
|
42 }
|
|
43
|
|
44 return 0;
|
|
45 }
|
|
46
|
|
47 void
|
|
48 run_init(void)
|
|
49 {
|
|
50 HTaskPtr task;
|
|
51
|
|
52 task = manager->create_task(HELLO_TASK);
|
|
53 task->add_param(count);
|
|
54 task->set_post(func1, (void*)count);
|
|
55 task->set_cpu(SPE_ANY);
|
|
56 task->spawn();
|
|
57 }
|
|
58
|
|
59 int
|
|
60 cerium_main(int argc, char *argv[])
|
|
61 {
|
|
62 if (init(argc, argv) < 0) {
|
|
63 return -1;
|
|
64 }
|
|
65
|
|
66 task_init();
|
|
67 run_init();
|
|
68
|
|
69 return 0;
|
|
70 }
|