192
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4 #include "TaskManager.h"
|
|
5 #include "Func.h"
|
|
6
|
400
|
7 extern void task_init();
|
192
|
8
|
260
|
9 const char *usr_help_str = "Usage: ./renew_task";
|
192
|
10
|
489
|
11 SchedDefineTask(RenewRepeat);
|
|
12
|
|
13 static int count = 1;
|
|
14 static int task_count = 1;
|
|
15
|
|
16 static void
|
|
17 renewRepeat(void *arg)
|
|
18 {
|
|
19 TaskManager *manager = (TaskManager *)arg;
|
|
20
|
|
21 if (count-->0) {
|
|
22 HTask *repeat = manager->create_task(RENEW_REPEAT);
|
|
23 repeat->set_post(renewRepeat, (void*)manager);
|
|
24 repeat->spawn();
|
|
25
|
|
26 HTask *renew;
|
|
27
|
|
28 printf("[PPE] Create Task : RenewStart\n\n");
|
|
29
|
|
30 for(int i=0;i<task_count;i++) {
|
|
31 renew = manager->create_task(RENEW_START);
|
|
32 renew->set_cpu(SPE_ANY);
|
|
33 renew->add_param(i);
|
|
34
|
|
35 // add Active Queue
|
|
36 renew->spawn();
|
|
37 }
|
|
38 }
|
|
39 }
|
|
40
|
|
41 static int
|
|
42 run(SchedTask *s, void *rbuf, void *wbuf)
|
|
43 {
|
|
44 // RewnewRepeat Task
|
|
45 return 0;
|
|
46 }
|
|
47
|
192
|
48 static int
|
|
49 init(int argc, char **argv)
|
|
50 {
|
489
|
51 for (int i = 1; argv[i]; ++i) {
|
|
52 if (strcmp(argv[i], "-count") == 0) {
|
|
53 count = atoi(argv[++i]);
|
|
54 } else if (strcmp(argv[i], "-task") == 0) {
|
|
55 task_count = atoi(argv[++i]);
|
|
56 }
|
|
57
|
|
58
|
|
59 }
|
192
|
60 return 0;
|
|
61 }
|
|
62
|
|
63 static void
|
400
|
64 renew_init(TaskManager *manager)
|
192
|
65 {
|
489
|
66 HTask *repeat;
|
192
|
67
|
489
|
68 printf("[PPE] Create Task : RenewRepeat\n\n");
|
192
|
69
|
489
|
70 repeat = manager->create_task(RENEW_REPEAT);
|
|
71 repeat->set_post(renewRepeat, (void*)manager);
|
192
|
72
|
|
73 // add Active Queue
|
489
|
74 repeat->spawn();
|
192
|
75 }
|
|
76
|
|
77 int
|
400
|
78 TMmain(TaskManager *manager, int argc, char *argv[])
|
192
|
79 {
|
|
80 if (init(argc, argv) < 0) {
|
|
81 return -1;
|
|
82 }
|
|
83
|
|
84 // Task Register
|
|
85 // ppe/task_init.cc
|
|
86 task_init();
|
|
87
|
|
88 printf("[PPE] Program Start\n\n");
|
|
89
|
400
|
90 renew_init(manager);
|
192
|
91
|
|
92 return 0;
|
|
93 }
|