Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/HTask.h @ 1089:c0dc96c6f209 draft
htask->init fix.
author | tkaito |
---|---|
date | Wed, 22 Dec 2010 04:21:11 +0900 |
parents | 338523ff6986 |
children | 3c2c445be6ba |
rev | line source |
---|---|
109 | 1 #ifndef INCLUDED_HTASK |
2 #define INCLUDED_HTASK | |
3 | |
307 | 4 #include "base.h" |
5 #include "types.h" | |
6 #include "Task.h" | |
955 | 7 #include "TaskQueue.h" |
8 #include "QueueInfo.h" | |
787 | 9 #include <stdio.h> |
109 | 10 |
11 class TaskManagerImpl; | |
539 | 12 class SchedTask; |
13 | |
547 | 14 typedef void (*PostFunction)(SchedTask *s, void *read, void *write); |
109 | 15 |
956
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
16 extern QueueInfo<TaskQueue>* taskQueuePool; |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
17 |
293 | 18 /*! |
19 @class | |
20 | |
21 @brief | |
22 | |
23 Cerium の Task で、spawn() でキューに格納されて順次実行される。 | |
24 cpu の指定があれば並列に実行される。 | |
25 特定の Task を待ち合わせる事が可能。 | |
26 Task の入出力は dma などで copy される。 | |
27 */ | |
688 | 28 |
29 #include "SimpleTask.h" | |
30 | |
641
0605f27ba7d9
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
634
diff
changeset
|
31 class HTask : public SimpleTask { |
109 | 32 public: |
33 BASE_NEW_DELETE(HTask); | |
34 | |
955 | 35 QueueInfo<TaskQueue> *wait_me; // List of task waiting for me |
36 QueueInfo<TaskQueue> *wait_i; // List of task for which I am waiting | |
546 | 37 PostFunction post_func; |
539 | 38 void *post_arg1; |
39 void *post_arg2; | |
109 | 40 CPU_TYPE cpu_type; |
41 TaskManagerImpl *mimpl; | |
42 | |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
43 HTask *waiter; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
44 HTask *next; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
45 HTask *prev; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
46 |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
47 struct { |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
48 unsigned no_auto_free:1; // bit 0 auto free flag (0 .. auto, 1 manual) |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
49 } flag; |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
50 |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
51 void spawn(); |
293 | 52 void wait_for(HTask *); |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
366
diff
changeset
|
53 void set_cpu(CPU_TYPE type); |
539 | 54 void set_post(PostFunction func, void *read, void *write); |
700 | 55 Task *create_task_array(int task_id, int num_task, int num_param, int num_inData, int num_outData); |
56 Task *next_task_array(int task_id, Task *t); | |
57 void spawn_task_array(Task *t); | |
703 | 58 |
955 | 59 HTask *init(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) { |
60 init(cmd); | |
61 set_input(rbuf, rs); | |
62 set_output(wbuf, ws); | |
63 return this; | |
64 } | |
714 | 65 |
956
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
66 void initOnce() { |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
67 wait_me = new QueueInfo<TaskQueue>(taskQueuePool); |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
68 wait_i = new QueueInfo<TaskQueue>(taskQueuePool); |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
69 } |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
70 |
958 | 71 void freeOnce() { |
72 delete wait_me; | |
73 delete wait_i; | |
74 } | |
75 | |
713
97adb3fe85c6
remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
703
diff
changeset
|
76 private: |
703 | 77 |
78 int param_index; | |
79 int in_index; | |
80 int out_index; | |
81 | |
82 // compatibility | |
83 public: // functions | |
84 void add_inData_t(memaddr addr, int size) { | |
85 Task *t = (Task*)rbuf; | |
86 t->set_inData_t(in_index++, addr,size); | |
87 } | |
88 void add_outData_t(memaddr addr, int size) { | |
89 Task *t = (Task*)rbuf; | |
90 t->set_outData_t(out_index++, addr,size); | |
91 } | |
92 void set_inData_t(int index, memaddr addr, int size) { | |
949 | 93 #ifdef EARLY_TOUCH |
94 if ((unsigned long)addr&0xf) { | |
787 | 95 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", |
96 command, index, (unsigned long)addr, size); | |
97 } | |
949 | 98 char *p = (char *)addr; char b = *p; |
99 p = (char *)(addr+size-1); b += *p; | |
100 #endif | |
703 | 101 Task *t = (Task*)rbuf; |
102 t->set_inData_t(index, addr,size); | |
103 } | |
104 void set_outData_t(int index, memaddr addr, int size) { | |
949 | 105 #ifdef EARLY_TOUCH |
106 if ((unsigned long)addr&0xf) { | |
787 | 107 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", |
108 command, index, (unsigned long)addr, size); | |
109 } | |
949 | 110 char *p = (char *)addr; char b = *p; |
111 p = (char *)(addr+size-1); b += *p; | |
112 #endif | |
703 | 113 Task *t = (Task*)rbuf; |
788 | 114 t->set_outData_t(index, addr,size); |
703 | 115 } |
116 void add_param_t(memaddr param) { | |
117 Task *t = (Task*)rbuf; | |
118 t->set_param_t(param_index++, param); | |
119 } | |
120 void set_param_t(int index, memaddr param) { | |
945
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
121 if (command==TaskArray1) { |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
122 Task *t = (Task*)rbuf; |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
123 t->set_param_t(index, param); |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
124 } else { |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
125 this->param = param; |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
126 } |
703 | 127 } |
128 | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
129 void no_auto_free() { |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
130 flag.no_auto_free = 1; |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
131 } |
954 | 132 void auto_free() { |
133 flag.no_auto_free = 0; | |
134 } | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
135 |
955 | 136 void init() { |
714 | 137 next = prev = NULL; |
138 waiter = NULL; | |
955 | 139 } |
714 | 140 |
955 | 141 void init(int cmd) { |
714 | 142 command = cmd; |
143 param_index = 0; | |
144 in_index = 0; | |
145 out_index = 0; | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
146 flag.no_auto_free = 0; |
714 | 147 self = (memaddr) this; |
148 | |
149 post_func = NULL; | |
150 mimpl = NULL; | |
151 cpu_type = CPU_PPE; | |
1089 | 152 |
153 post_arg1 = NULL; | |
154 post_arg2 = NULL; | |
155 from = NULL; | |
156 param = NULL; | |
714 | 157 } |
703 | 158 #define add_param(param) add_param_t((memaddr)(param)) |
159 #define set_param(index,param) set_param_t(index, (memaddr) (param)) | |
160 | |
161 #define add_inData(addr, size) \ | |
162 add_inData_t((memaddr)(addr), (size)); | |
163 #define add_outData(addr, size) \ | |
164 add_outData_t((memaddr)(addr), (size)); | |
165 | |
166 | |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
788
diff
changeset
|
167 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))); |
109 | 168 |
169 typedef HTask* HTaskPtr; | |
170 | |
171 #endif |