annotate TaskManager/kernel/ppe/TaskManagerImpl.cc @ 897:6bd218d3f643 draft

add return address in SimpleTask for debugging.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 16 Jul 2010 19:00:22 +0900
parents 641451e6a95b
children aafa99c856a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
75f184d16fa5 *** empty log message ***
gongo
parents: 3
diff changeset
1 #include <stdio.h>
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
2 #include "TaskManagerImpl.h"
46
f154d9d07a42 *** empty log message ***
gongo
parents: 42
diff changeset
3 #include "types.h"
f154d9d07a42 *** empty log message ***
gongo
parents: 42
diff changeset
4 #include "error.h"
546
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
5 #include "SchedTask.h"
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
6 #include "Scheduler.h"
634
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
7 #include "SysTask.h"
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
8 #include "SysFunc.h"
806
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
9 #include <string.h>
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
10
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
11
220
gongo@localhost.localdomain
parents: 115
diff changeset
12 static HTaskPtr systask_start;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
13 static HTaskPtr systask_finish;
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
14
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
15 static void
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
16 noaction(SchedTask *s, void *read, void *write)
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
17 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
18 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
19
835
yutaka@localhost.localdomain
parents: 833
diff changeset
20 TaskManagerImpl::TaskManagerImpl(int num)
yutaka@localhost.localdomain
parents: 833
diff changeset
21 : machineNum(num){
853
game@zeus.cr.ie.u-ryukyu.ac.jp
parents: 835
diff changeset
22 // 実行可能なHTaskのリスト
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
23 activeTaskQueue = new HTaskInfo();
853
game@zeus.cr.ie.u-ryukyu.ac.jp
parents: 835
diff changeset
24 // wait_forで止まっているHTaskのリスト。必要ないが、Dead lock detection に使う
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
25 waitTaskQueue = new HTaskInfo();
853
game@zeus.cr.ie.u-ryukyu.ac.jp
parents: 835
diff changeset
26 // HTask の factory. HTaskInfo ならなんでもいい。
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
27 htaskImpl = waitTaskQueue ; // any HTaskInfo
853
game@zeus.cr.ie.u-ryukyu.ac.jp
parents: 835
diff changeset
28 // Task の dependency を表現する double linked list. HTaskInfo とは別に必要。
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
29 taskQueueImpl = new TaskQueueInfo();
480
75e4afa40da2 TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
30 }
50
7927e00fb8e2 *** empty log message ***
gongo
parents: 48
diff changeset
31
220
gongo@localhost.localdomain
parents: 115
diff changeset
32 /**
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
33 * 一番最初に PPE で実行される systask_start
220
gongo@localhost.localdomain
parents: 115
diff changeset
34 */
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
35 void
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
36 TaskManagerImpl::systask_init()
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
37 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
38 systask_register();
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
39 systask_start = create_task(StartTask,0,0,0,0,__builtin_return_address(0));
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
40 systask_finish = create_task(FinishTask,0,0,0,0,__builtin_return_address(0));
220
gongo@localhost.localdomain
parents: 115
diff changeset
41
gongo@localhost.localdomain
parents: 115
diff changeset
42 systask_start->spawn();
gongo@localhost.localdomain
parents: 115
diff changeset
43
634
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
44 // すべての Task が FinishTask を wait_for すると、
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
45 // あらゆる Task が FinishTask の waiting task queue を操作する
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
46 // ことになる。それは、重すぎる。PPE/SPE Task が終了した時点で、
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
47 // TaskManager が実行する方が安い。
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
48 // append_waitTask(systask_finish);
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
49 }
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
50
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
51 HTaskPtr
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
52 TaskManagerImpl::create_task(int cmd,memaddr rbuf, long r_size, memaddr wbuf, long w_size, void *from) {
634
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
53 HTaskPtr new_task;
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
54
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
55 new_task = htaskImpl->create(cmd, rbuf, r_size, wbuf, w_size);
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
56 new_task->post_func = noaction;
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
57 new_task->mimpl = this;
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
58 new_task->from = (memaddr)from;
634
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
59
62e570ac5db2 SimpleTask start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
60 return new_task;
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
61 }
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
62
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
63 HTaskPtr
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
64 TaskManagerImpl::create_task(int cmd,void *from)
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
65 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
66 HTaskPtr new_task;
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
67
703
0c8ad8d99656 compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
68 // for compatibility
0c8ad8d99656 compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
69 new_task = htaskImpl->create(TaskArray1);
0c8ad8d99656 compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
70 new_task->post_func = noaction;
0c8ad8d99656 compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
71 new_task->mimpl = this;
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 719
diff changeset
72 new_task->create_task_array(cmd,1,8,8,8);
713
97adb3fe85c6 remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
73 // rbuf, r_size were set
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 703
diff changeset
74 new_task->command = TaskArray1;
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
75 new_task->from = (memaddr)from;
63
54355e641172 *** empty log message ***
gongo
parents: 58
diff changeset
76
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
77 return new_task;
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
78 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
79
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
80 HTaskPtr
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
81 TaskManagerImpl::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData, void *from)
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
82 {
897
6bd218d3f643 add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 855
diff changeset
83 HTaskPtr ta = create_task(TaskArray,0,0,0,0, from);
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
84 ta->create_task_array(id, num_task, num_param, num_inData, num_outData) ;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
85 return ta;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
86 }
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
87
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
88 /**
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
89 * task の依存関係を設定
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
90 * master task が終わってから、slave task を実行するように
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
91 * master->wait_for(slave);
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
92 */
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
93 void
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
94 TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave)
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
95 {
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
96 TaskQueuePtr m, s;
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
97
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
98 m = taskQueueImpl->create(master);
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
99 s = taskQueueImpl->create(slave);
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
100
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
101 master->wait_me->addLast(s);
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
102 slave->wait_i->addLast(m);
481
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 480
diff changeset
103 s->waiter = m;
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
104 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
105
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
106 /**
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
107 * タスクを実行可能キューまたは待機キューへ追加する。
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
108 * 依存関係が満たされていれば active, まだだったら wait へ。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
109 * task->spawn();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
110 */
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
111 void
18
0c9341da4522 *** empty log message ***
gongo
parents: 5
diff changeset
112 TaskManagerImpl::spawn_task(HTaskPtr task)
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
113 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
114 // waiter // master
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
115 // waitee // slave
480
75e4afa40da2 TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
116 if (task->wait_i->empty()) {
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
117 append_activeTask(task);
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
118 } else {
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
119 append_waitTask(task);
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
120 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
121
635
c56f6847fb87 SimpleTask worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 634
diff changeset
122 // systask_finish->wait_for(task);
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
123 }
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
124
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
125
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
126 /**
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
127 * Task を実行可能キューに追加する
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
128 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
129 void
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
130 TaskManagerImpl::append_activeTask(HTaskPtr q)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
131 {
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
132 activeTaskQueue->addLast(q);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
133 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
134
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
135 /**
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
136 * タスクが実行する CPU を選択する
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
137 *
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
138 * 現在は CPU_PPE, CPU_SPE, SPE_ANY, SPE_0, SPE_1, ..., SPE_5
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
139 * types.h に書いてます。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
140 */
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 63
diff changeset
141 void
519d24aa7ac8 *** empty log message ***
gongo
parents: 63
diff changeset
142 TaskManagerImpl::set_task_cpu(HTaskPtr task, CPU_TYPE type)
519d24aa7ac8 *** empty log message ***
gongo
parents: 63
diff changeset
143 {
664
beb0f17c19f9 word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
144 if (machineNum==0)
beb0f17c19f9 word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
145 task->cpu_type = CPU_PPE ;
beb0f17c19f9 word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
146 else
beb0f17c19f9 word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
147 task->cpu_type = type;
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 63
diff changeset
148 }
519d24aa7ac8 *** empty log message ***
gongo
parents: 63
diff changeset
149
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
150 /**
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
151 * @brief 終了したタスクから依存の処理とか
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
152 * post_func() はこのタスクが終了したら実行する関数。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
153 *
298
768452fab95e from EUC to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 220
diff changeset
154 * @param [task] 終了したタスク
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
155 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
156 void
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 639
diff changeset
157 TaskManagerImpl::check_task_finish(HTaskPtr me, HTaskInfo *wait_queue)
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
158 {
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
159
497
3429986b8a28 no wakeup loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
160 while(TaskQueue *p = me->wait_me->poll()) {
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
161 HTaskPtr you = p->task;
497
3429986b8a28 no wakeup loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
162 TaskQueueInfo *wait_i = you->wait_i;
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
163 // 相手の wait queue から自分(を指しているTaskQueue)を削除
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
164 wait_i->remove(p->waiter);
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
165 // queue を free する
493
2a7a9f80b8e7 fix free conflict.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 483
diff changeset
166 wait_i->free_(p->waiter);
483
5f4ffff2c2aa renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
167
497
3429986b8a28 no wakeup loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
168 if (wait_i->empty()) {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 639
diff changeset
169 wait_queue->remove(you);
499
981aa2f89a80 still fixing...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 498
diff changeset
170 append_activeTask(you);
497
3429986b8a28 no wakeup loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
171 }
3429986b8a28 no wakeup loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
172
493
2a7a9f80b8e7 fix free conflict.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 483
diff changeset
173 wait_i->free_(p);
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
174 }
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
175
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
176 htaskImpl->free_(me);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
177 }
42
aa11038dbdc1 *** empty log message ***
gongo
parents: 18
diff changeset
178
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
179 /**
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
180 * @brief 終了したタスクリストの依存の処理
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
181 * @param [task] 終了したタスク
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
182 */
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
183 void
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
184 TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, HTaskInfo *wait_queue)
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
185 {
855
641451e6a95b light fix--
Yutaka_Kinjyo
parents: 853
diff changeset
186 for(int i = 0;i<list->length;i++) {
831
b3c004fe6bc3 CheckTaskList Mail working
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
187 SimpleTaskPtr task = &list->tasks[i];
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
188 HTask *me = (HTask*)task->self;
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
189 me->post_func(s, me->post_arg1, me->post_arg2);
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
190 if (task->command==TaskArray1) {
831
b3c004fe6bc3 CheckTaskList Mail working
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
191 int next = ((task->r_size)/sizeof(SimpleTask))+1;
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
192 // assert(next<list->length);
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
193 i+=next;
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
194 }
833
577bde5d0cec poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 831
diff changeset
195 s->polling();
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
196 check_task_finish(me, wait_queue);
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
197 }
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
198 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
199
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
200 /**
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
201 * @brief waitTaskqueue への挿入 。必須ではない。
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
202 * 現状では、dead lock 検出にしか使ってない
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
203 *
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
204 * @param [task] 終了したタスク
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
205 */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
206 void
498
bce667ff20b9 double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 497
diff changeset
207 TaskManagerImpl::append_waitTask(HTaskPtr q)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
208 {
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
209 waitTaskQueue ->addLast(q);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
210 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 94
diff changeset
211
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
212 /**
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
213 @brief htask を DMA でCPUに渡すための TaskList に入れる (copy)
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
214 @param htask
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
215 @param taskList
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
216 TaskList は自動的に延長される
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
217 */
806
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
218 void
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
219 TaskManagerImpl::set_taskList(HTaskPtr htask, TaskListInfoPtr taskList) {
809
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
220 TaskListPtr list ;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
221 if ( taskList->empty() ) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
222 list = taskList->create();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
223 taskList->addLast(list);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
224 } else
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
225 list = taskList->getLast();
806
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
226 SimpleTaskPtr task = &list->tasks[list->length++];
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
227 if (htask->command==TaskArray1) {
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
228 // compatibility
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
229 int next = ((htask->r_size)/sizeof(SimpleTask))+1;
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
230 if (list->length+next>=TASK_MAX_SIZE) {
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
231 list->length--;
809
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
232 TaskListPtr newList = taskList->create();
806
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
233 taskList->addLast(newList);
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
234 list = newList;
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
235 task = &list->tasks[list->length++];
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
236 }
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
237 Task *array = (Task*)&list->tasks[list->length];
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
238 list->length += next;
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
239 if (list->length>=TASK_MAX_SIZE) {
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
240 perror("task array1 overflow\n");
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
241 }
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
242 memcpy(array, htask->rbuf, htask->r_size);
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
243 free(htask->rbuf);
831
b3c004fe6bc3 CheckTaskList Mail working
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
244 // htask->rbuf = 0; htask->r_size = 0; we need this...
806
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
245 *task = *(SimpleTask*)htask;
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
246 } else {
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
247 *task = *(SimpleTask*)htask;
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
248 }
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
249 if (list->length >= TASK_MAX_SIZE) {
809
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 807
diff changeset
250 TaskListPtr newList = taskList->create();
806
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
251 taskList->addLast(newList);
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
252 list = newList;
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
253 }
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
254 }
fb49e881f2ed TaslListInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
255
54
90523ccc4dff *** empty log message ***
gongo
parents: 50
diff changeset
256
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
257
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 475
diff changeset
258 /* end */