Mercurial > hg > Members > kono > Cerium
annotate example/renew_task/main.cc @ 641:0692b08f1cd6
Regression on Mac OS X
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 21 Nov 2009 10:06:34 +0900 |
parents | 60aa3f241b10 |
children |
rev | line source |
---|---|
192 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include "TaskManager.h" | |
619 | 5 #include "SchedTask.h" |
192 | 6 #include "Func.h" |
7 | |
400 | 8 extern void task_init(); |
192 | 9 |
260 | 10 const char *usr_help_str = "Usage: ./renew_task"; |
192 | 11 |
487 | 12 SchedDefineTask(RenewRepeat); |
13 | |
14 static int count = 1; | |
15 static int task_count = 1; | |
16 | |
17 static void | |
619 | 18 renewRepeat1(SchedTask *s, void *arg, void *d) |
487 | 19 { |
567 | 20 TaskManager *manager = (TaskManager *)arg; |
21 | |
487 | 22 if (count-->0) { |
23 HTask *repeat = manager->create_task(RENEW_REPEAT); | |
619 | 24 repeat->set_post(renewRepeat1, (void*)manager, 0); |
487 | 25 repeat->spawn(); |
26 | |
567 | 27 HTask *renew; |
28 | |
487 | 29 printf("[PPE] Create Task : RenewStart\n\n"); |
30 | |
31 for(int i=0;i<task_count;i++) { | |
567 | 32 renew = manager->create_task(RENEW_START); |
487 | 33 renew->set_cpu(SPE_ANY); |
34 renew->add_param(i); | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
35 renew->add_param(&task_count); |
487 | 36 |
37 // add Active Queue | |
38 renew->spawn(); | |
39 } | |
40 } | |
41 } | |
42 | |
567 | 43 static int |
44 run(SchedTask *s, void *rbuf, void *wbuf) | |
45 { | |
46 // RewnewRepeat Task | |
47 return 0; | |
48 } | |
487 | 49 |
192 | 50 static int |
51 init(int argc, char **argv) | |
52 { | |
487 | 53 for (int i = 1; argv[i]; ++i) { |
54 if (strcmp(argv[i], "-count") == 0) { | |
55 count = atoi(argv[++i]); | |
56 } else if (strcmp(argv[i], "-task") == 0) { | |
57 task_count = atoi(argv[++i]); | |
58 } | |
59 | |
60 | |
61 } | |
192 | 62 return 0; |
63 } | |
64 | |
65 static void | |
400 | 66 renew_init(TaskManager *manager) |
192 | 67 { |
487 | 68 HTask *repeat; |
192 | 69 |
487 | 70 printf("[PPE] Create Task : RenewRepeat\n\n"); |
192 | 71 |
487 | 72 repeat = manager->create_task(RENEW_REPEAT); |
619 | 73 repeat->set_post(renewRepeat1, (void*)manager, 0); |
192 | 74 |
75 // add Active Queue | |
487 | 76 repeat->spawn(); |
192 | 77 } |
78 | |
79 int | |
400 | 80 TMmain(TaskManager *manager, int argc, char *argv[]) |
192 | 81 { |
82 if (init(argc, argv) < 0) { | |
83 return -1; | |
84 } | |
85 | |
86 // Task Register | |
87 // ppe/task_init.cc | |
88 task_init(); | |
89 | |
90 printf("[PPE] Program Start\n\n"); | |
91 | |
400 | 92 renew_init(manager); |
192 | 93 |
94 return 0; | |
95 } |