annotate TaskManager/kernel/ppe/HTask.cc @ 713:97adb3fe85c6 draft

remove SIMPLE_TASK conditional
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 16 Dec 2009 15:27:46 +0900
parents ec6c897448ca
children 1b225972ae88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include "HTask.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include "ListData.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include "TaskManagerImpl.h"
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
4 #include "strings.h"
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
7 /*!
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
8 manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
9
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
10 ってやるより
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
11
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
12 task2->set_depend(task1);
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
13
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
14 ってやったほうがわかりやすいよねー的な話し合いで
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
15 下のようなAPIを作りました
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
16 */
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
17
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 HTask::spawn(void)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 mimpl->spawn_task(this);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
24 /*!
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
25 @brief この Task が待ち合わせする Task を指定する
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
26 @param[in] master この Task が終了待ち合わせをする相手の Task
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
27
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
28 繰り返し使用する事で複数の Task を待ち合わせする事ができる。
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
29
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
30 wait_for している Task の入力バッファにこの Task から書き込みできる機能があると良い
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
31 */
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
32
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 void
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
34 HTask::wait_for(HTaskPtr master)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 mimpl->set_task_depend(master, this);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
39 void
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
40 HTask::set_cpu(CPU_TYPE type)
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
41 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 mimpl->set_task_cpu(this, type);
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
43 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
44
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
45 void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
46 HTask::set_post(PostFunction func,void *arg1, void *arg2)
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
47 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 this->post_func = func;
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
49 this->post_arg1 = arg1;
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
50 this->post_arg2 = arg2;
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
51 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
52
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
53
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
54 Task *
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
55 HTask::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData)
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
56 {
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
57 r_size = Task::calc_size(num_param, num_inData, num_outData)*num_task;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
58 rbuf = (memaddr) mimpl->allocate(r_size);
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
59 bzero(rbuf,r_size);
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
60 Task *task = (Task*)rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
61 task->init(id, num_param,num_inData,num_outData);
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
62 // task->print();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
63 return task; // first task
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
64 }
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
65
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
66 Task *
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
67 HTask::next_task_array(int id, Task *t)
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
68 {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
69 Task *first = (Task*)rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
70 if (t==0) {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
71 // first->print();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
72 return first;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
73 }
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
74
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
75 Task *next = t->next();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
76 next->init(id, first->param_count, first->inData_count, first->outData_count);
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
77 if ((memaddr)next - (memaddr)rbuf > r_size)
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
78 printf("too many task array used.\n");
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
79 return next;
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
80 }
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
81
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
82 void
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
83 HTask::spawn_task_array(Task * last)
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
84 {
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
85 int size = (memaddr)last - rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
86 if (size!= r_size) {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
87 printf("spawn task array size differ size 0x%x r_size 0x%x\n",
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
88 size, r_size);
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
89 }
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
90 }
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
91
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
92
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
93
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
94 /* end */