312
|
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)
|
312
|
30 {
|
|
31 HTask *hello;
|
|
32
|
|
33 for (int i = 0; i < count; i++) {
|
|
34 /**
|
|
35 * Create Task
|
|
36 * create_task(Task ID);
|
|
37 */
|
|
38 hello = manager->create_task(HELLO_TASK);
|
|
39
|
|
40 /**
|
|
41 * Select CPU
|
|
42 * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY
|
|
43 * if you do not call this, execute PPE.
|
|
44 */
|
|
45 hello->set_cpu(SPE_ANY);
|
|
46
|
|
47 /**
|
|
48 * Set 32bits parameter
|
|
49 * add_param(32bit parameter);
|
|
50 */
|
|
51 hello->add_param(i);
|
|
52
|
|
53 hello->spawn();
|
|
54 }
|
|
55 }
|
|
56
|
|
57 int
|
400
|
58 TMmain(TaskManager *manager, int argc, char *argv[])
|
312
|
59 {
|
|
60 if (init(argc, argv) < 0) {
|
|
61 return -1;
|
|
62 }
|
|
63
|
|
64 // Task Register
|
|
65 // ppe/task_init.cc
|
|
66 task_init();
|
|
67
|
400
|
68 hello_init(manager);
|
312
|
69
|
|
70 return 0;
|
|
71 }
|