comparison example/mainMem/main.cc @ 312:57530cb7f7d1

memMain tester
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 08 Jun 2009 23:19:11 +0900
parents
children 00fe05184a02
comparison
equal deleted inserted replaced
311:b09784a9cb09 312:57530cb7f7d1
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
13 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
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 }
24
25 }
26
27 return 0;
28 }
29
30 void
31 hello_init(void)
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
60 TMmain(int argc, char *argv[])
61 {
62 if (init(argc, argv) < 0) {
63 return -1;
64 }
65
66 // Task Register
67 // ppe/task_init.cc
68 task_init();
69
70 hello_init();
71
72 return 0;
73 }