Mercurial > hg > Members > kono > Cerium
comparison example/hello_array/main.cc @ 733:71a58131b2c0
add array sample helloworld
author | yutaka@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 24 Dec 2009 05:01:12 +0900 |
parents | |
children | 08d201fb1d66 |
comparison
equal
deleted
inserted
replaced
732:74aa6649dcb6 | 733:71a58131b2c0 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include "TaskManager.h" | |
5 #include "Task.h" | |
6 #include "ListData.h" | |
7 #include "Func.h" | |
8 | |
9 extern void task_init(void); | |
10 | |
11 static int task_num = 1; | |
12 /*0 だと task_num が4つ以上の時に止まる。*/ | |
13 static int data_count = 1; | |
14 | |
15 const char *usr_help_str = "Usage: ./hello [-task task_num]\n\ | |
16 -task Number of task (default 1)\n"; | |
17 | |
18 static int | |
19 init(int argc, char **argv) | |
20 { | |
21 for (int i = 1; argv[i]; ++i) { | |
22 | |
23 if (strcmp(argv[i], "-task") == 0) { | |
24 task_num = atoi(argv[++i]); | |
25 } | |
26 } | |
27 | |
28 return 0; | |
29 } | |
30 | |
31 | |
32 void | |
33 twice_init(TaskManager *manager) | |
34 { | |
35 | |
36 | |
37 /** | |
38 * Create Task | |
39 * create_task(Task ID); | |
40 */ | |
41 | |
42 /*うしろ3つ param/inData/outData の数を指定する*/ | |
43 HTask *twice_main = manager->create_task_array(Hello,task_num,data_count,data_count,data_count); | |
44 Task *t = 0; | |
45 | |
46 for(int i = 0;i<task_num;i++) { | |
47 t = twice_main->next_task_array(Hello, t); | |
48 } | |
49 | |
50 twice_main->spawn_task_array(t->next()); | |
51 twice_main->set_cpu(SPE_ANY); | |
52 twice_main->spawn(); | |
53 } | |
54 | |
55 int | |
56 TMmain(TaskManager *manager,int argc, char *argv[]) | |
57 { | |
58 | |
59 if (init(argc, argv) < 0) { | |
60 return -1; | |
61 } | |
62 | |
63 // Task Register | |
64 // ppe/task_init.cc | |
65 task_init(); | |
66 twice_init(manager); | |
67 | |
68 | |
69 return 0; | |
70 } |