Mercurial > hg > Members > e085722 > Cerium
comparison example/get_segment/main.cc @ 0:04e28d8d3c6f
first commit
author | Daiki KINJYO <e085722@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Nov 2010 01:23:25 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:04e28d8d3c6f |
---|---|
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 | |
29 hello_init(TaskManager *manager) | |
30 { | |
31 HTask *hello; | |
32 HTask *hello1; | |
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); | |
40 hello1 = manager->create_task(HELLO_TASK1); | |
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); | |
48 hello1->set_cpu(SPE_ANY); | |
49 | |
50 /** | |
51 * Set 32bits parameter | |
52 * add_param(32bit parameter); | |
53 */ | |
54 hello->set_param(0,(memaddr)i); | |
55 hello1->set_param(0,(memaddr)i); | |
56 | |
57 hello->spawn(); | |
58 hello1->spawn(); | |
59 } | |
60 } | |
61 | |
62 int | |
63 TMmain(TaskManager *manager, int argc, char *argv[]) | |
64 { | |
65 if (init(argc, argv) < 0) { | |
66 return -1; | |
67 } | |
68 | |
69 // Task Register | |
70 // ppe/task_init.cc | |
71 task_init(); | |
72 | |
73 hello_init(manager); | |
74 | |
75 return 0; | |
76 } |