Mercurial > hg > Game > Cerium
annotate example/HelloWorld/main.cc @ 491:5b28c96f48a3 draft
fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 06 Oct 2009 17:14:05 +0900 |
parents | 984e7890db0c |
children | 94d82f2c842f |
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 { |
33 HTask *hello; | |
34 | |
35 for (int i = 0; i < count; i++) { | |
36 /** | |
37 * Create Task | |
38 * create_task(Task ID); | |
39 */ | |
40 hello = manager->create_task(HELLO_TASK); | |
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 | |
49 /** | |
50 * Set 32bits parameter | |
51 * add_param(32bit parameter); | |
52 */ | |
53 hello->add_param(i); | |
54 | |
55 hello->spawn(); | |
56 } | |
57 } | |
58 | |
59 int | |
400 | 60 TMmain(TaskManager *manager, int argc, char *argv[]) |
109 | 61 { |
62 if (init(argc, argv) < 0) { | |
63 return -1; | |
64 } | |
65 | |
66 // Task Register | |
67 // ppe/task_init.cc | |
68 task_init(); | |
69 | |
400 | 70 hello_init(manager); |
109 | 71 |
72 return 0; | |
73 } |