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