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