Mercurial > hg > Game > Cerium
annotate example/HelloWorld/main.cc @ 1001:ca59327dccab draft
error fix.
author | root@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 21 Oct 2010 21:39:47 +0900 |
parents | 043c98537bc5 |
children | 0e6c59377ef4 |
rev | line source |
---|---|
109 | 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 extern TaskManager *manager; | |
12 | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
109
diff
changeset
|
13 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\ |
109 | 14 -cpu Number of SPE (default 1) \n\ |
15 -count Number of task is print \"Hello, World!!\""; | |
16 | |
17 int | |
18 init(int argc, char **argv) | |
19 { | |
20 for (int i = 1; argv[i]; ++i) { | |
21 if (strcmp(argv[i], "-count") == 0) { | |
22 count = atoi(argv[++i]); | |
23 } | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
109
diff
changeset
|
24 |
109 | 25 } |
26 | |
27 return 0; | |
28 } | |
29 | |
30 void | |
400 | 31 hello_init(TaskManager *manager) |
109 | 32 { |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
625
diff
changeset
|
33 |
109 | 34 |
35 for (int i = 0; i < count; i++) { | |
36 /** | |
37 * Create Task | |
38 * create_task(Task ID); | |
39 */ | |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
625
diff
changeset
|
40 |
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
625
diff
changeset
|
41 HTask *hello = manager->create_task(HELLO_TASK); |
109 | 42 |
43 /** | |
44 * Select CPU | |
45 * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY | |
46 * if you do not call this, execute PPE. | |
47 */ | |
48 hello->set_cpu(SPE_ANY); | |
49 | |
50 /** | |
51 * Set 32bits parameter | |
52 * add_param(32bit parameter); | |
53 */ | |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
625
diff
changeset
|
54 hello->set_param(0,(memaddr)i); |
109 | 55 |
56 hello->spawn(); | |
57 } | |
58 } | |
59 | |
60 int | |
400 | 61 TMmain(TaskManager *manager, int argc, char *argv[]) |
109 | 62 { |
63 if (init(argc, argv) < 0) { | |
64 return -1; | |
65 } | |
66 | |
67 // Task Register | |
68 // ppe/task_init.cc | |
69 task_init(); | |
70 | |
400 | 71 hello_init(manager); |
109 | 72 |
73 return 0; | |
74 } |