354
|
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 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
|
|
12 -cpu Number of SPE (default 1) \n\
|
|
13 -count Number of task is print \"Hello, World!!\"";
|
|
14
|
|
15 int
|
|
16 init(int argc, char **argv)
|
|
17 {
|
|
18 for (int i = 1; argv[i]; ++i) {
|
|
19 if (strcmp(argv[i], "-count") == 0) {
|
|
20 count = atoi(argv[++i]);
|
|
21 }
|
|
22
|
|
23 }
|
|
24
|
|
25 return 0;
|
|
26 }
|
|
27
|
|
28 void
|
400
|
29 hello_init(TaskManager *manager)
|
354
|
30 {
|
|
31 HTask *hello;
|
433
|
32 HTask *hello1;
|
354
|
33
|
|
34 for (int i = 0; i < count; i++) {
|
|
35 /**
|
|
36 * Create Task
|
|
37 * create_task(Task ID);
|
|
38 */
|
|
39 hello = manager->create_task(HELLO_TASK);
|
433
|
40 hello1 = manager->create_task(HELLO_TASK1);
|
354
|
41
|
|
42 /**
|
|
43 * Select CPU
|
|
44 * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY
|
|
45 * if you do not call this, execute PPE.
|
|
46 */
|
|
47 hello->set_cpu(SPE_ANY);
|
433
|
48 hello1->set_cpu(SPE_ANY);
|
354
|
49
|
|
50 /**
|
|
51 * Set 32bits parameter
|
|
52 * add_param(32bit parameter);
|
|
53 */
|
|
54 hello->add_param(i);
|
433
|
55 hello1->add_param(i);
|
354
|
56
|
|
57 hello->spawn();
|
433
|
58 hello1->spawn();
|
354
|
59 }
|
|
60 }
|
|
61
|
|
62 int
|
400
|
63 TMmain(TaskManager *manager, int argc, char *argv[])
|
354
|
64 {
|
|
65 if (init(argc, argv) < 0) {
|
|
66 return -1;
|
|
67 }
|
|
68
|
|
69 // Task Register
|
|
70 // ppe/task_init.cc
|
|
71 task_init();
|
|
72
|
400
|
73 hello_init(manager);
|
354
|
74
|
|
75 return 0;
|
|
76 }
|