Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/main.c @ 132:7c309e1aea73
Code Gears stack api
author | one |
---|---|
date | Thu, 27 Oct 2016 18:54:11 +0900 |
parents | a574ba0da60f |
children | d529c024e5a5 |
rev | line source |
---|---|
86 | 1 #include <stdio.h> |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
2 #include <string.h> |
132 | 3 #include <stdlib.h> |
86 | 4 |
5 #include "context.h" | |
6 #include "origin_cs.h" | |
7 | |
8 extern __code initContext(struct Context* context); | |
90 | 9 extern void allocator(struct Context* context); |
86 | 10 |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
11 int cpu_num = 1; |
113 | 12 int length = 102400; |
13 int split = 8; | |
90 | 14 int* array_ptr; |
15 | |
16 void print_queue(struct Element* element) { | |
17 while (element) { | |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
18 printf("%d\n", ((struct Task *)(element->data))->key); |
90 | 19 element = element->next; |
20 } | |
21 } | |
22 | |
23 void print_tree(struct Node* node) { | |
24 if (node != 0) { | |
25 printf("%d\n", node->value->array.index); | |
26 print_tree(node->left); | |
27 print_tree(node->right); | |
28 } | |
29 } | |
86 | 30 |
31 __code code1(struct Context* context) { | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
32 printf("cpus:\t\t%d\n", cpu_num); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
33 printf("length:\t\t%d\n", length); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
34 printf("length/task:\t%d\n", length/split); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
35 /* puts("queue"); */ |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
36 /* print_queue(context->data[ActiveQueue]->queue.first); */ |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
37 /* puts("tree"); */ |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
38 /* print_tree(context->data[Tree]->tree.root); */ |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
39 /* puts("result"); */ |
90 | 40 |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
41 context->next = CreateWorker; |
102 | 42 |
43 struct Time *t = &context->data[Time]->time; | |
44 t->next = CreateWorker; | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
45 goto meta(context, StartTime); |
86 | 46 } |
47 | |
48 __code code1_stub(struct Context* context) { | |
49 goto code1(context); | |
50 } | |
51 | |
92 | 52 __code code2(struct Context* context, struct Array* array, struct LoopCounter* loopCounter) { |
53 int i = loopCounter->i; | |
111 | 54 |
92 | 55 if (i < length) { |
115 | 56 //printf("%d\n", array->array[i]); |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
57 if (array->array[i] == (i*2)) { |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
58 loopCounter->i++; |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
59 goto meta(context, Code2); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
60 } else |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
61 puts("wrong result"); |
92 | 62 |
63 } | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
64 |
92 | 65 goto meta(context, Exit); |
66 } | |
67 | |
68 __code code2_stub(struct Context* context) { | |
69 goto code2(context, &context->data[Node]->node.value->array, &context->data[LoopCounter]->loopCounter); | |
70 } | |
71 | |
90 | 72 __code createData1(struct Context* context, struct Allocate* allocate, struct LoopCounter* loopCounter) { |
73 int i = loopCounter->i; | |
74 | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
75 if ((length/split*i) < length) { |
90 | 76 allocate->size = sizeof(struct Array); |
77 allocator(context); | |
78 | |
79 goto meta(context, CreateData2); | |
80 } | |
81 | |
92 | 82 loopCounter->i = 0; |
90 | 83 goto meta(context, Code1); |
84 } | |
111 | 85 |
90 | 86 __code createData1_stub(struct Context* context) { |
87 goto createData1(context, &context->data[Allocate]->allocate, &context->data[LoopCounter]->loopCounter); | |
88 } | |
89 | |
90 __code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Array* array, struct Node* node) { | |
91 int i = loopCounter->i; | |
92 | |
93 array->index = i; | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
94 array->prefix = length/split; |
90 | 95 array->array = array_ptr; |
96 | |
97 node->key = i; | |
98 node->value = (union Data*)array; | |
111 | 99 |
90 | 100 context->next = CreateTask1; |
101 | |
102 goto meta(context, PutTree); | |
103 } | |
104 | |
105 __code createData2_stub(struct Context* context) { | |
106 goto createData2(context, | |
111 | 107 &context->data[LoopCounter]->loopCounter, |
108 &context->data[context->dataNum]->array, | |
109 &context->data[Node]->node); | |
90 | 110 } |
111 | |
112 __code createTask1(struct Context* context, struct Allocate* allocate) { | |
113 allocate->size = sizeof(struct Task); | |
114 allocator(context); | |
115 goto meta(context, CreateTask2); | |
116 } | |
117 | |
118 __code createTask1_stub(struct Context* context) { | |
119 goto createTask1(context, &context->data[Allocate]->allocate); | |
120 } | |
121 | |
112 | 122 __code createTask2(struct Context* context, struct Allocate* allocate) { |
123 allocate->size = sizeof(struct Queue); | |
124 allocator(context); | |
125 goto meta(context, CreateTask3); | |
126 } | |
127 | |
128 __code createTask2_stub(struct Context* context) { | |
129 goto createTask2(context, &context->data[Allocate]->allocate); | |
130 } | |
131 | |
132 __code createTask3(struct Context* context, struct Allocate* allocate) { | |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
133 allocate->size = sizeof(struct Queue); |
112 | 134 allocator(context); |
135 goto meta(context, CreateTask4); | |
136 } | |
137 | |
138 __code createTask3_stub(struct Context* context) { | |
139 goto createTask3(context, &context->data[Allocate]->allocate); | |
140 } | |
141 | |
142 __code meta_createTask4(struct Context* context, struct Queue* activeQueue, enum Code next) { | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
143 context->data[Queue] = (union Data *)activeQueue; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
144 goto (context->code[next])(context); |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
145 } |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
146 |
115 | 147 __code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element, struct Queue* activeQueue) { |
90 | 148 int i = loopCounter->i; |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
149 |
112 | 150 waitMe->first = 0; |
151 waitMe->last = 0; | |
152 waitMe->count = 0; | |
153 | |
154 waitI->first = 0; | |
155 waitI->last = 0; | |
156 waitI->count = 0; | |
157 | |
92 | 158 task->code = Twice; |
90 | 159 task->key = i; |
112 | 160 task->waitMe = waitMe; |
161 task->waitI = waitI; | |
162 task->idsCount = 0; | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
163 |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
164 element->data = (union Data *)task; |
90 | 165 |
166 context->next = CreateData1; | |
167 loopCounter->i++; | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
168 |
112 | 169 goto meta(context, SpawnTask); |
90 | 170 } |
171 | |
112 | 172 __code createTask4_stub(struct Context* context) { |
173 goto createTask4(context, | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
174 &context->data[LoopCounter]->loopCounter, |
112 | 175 &context->data[context->dataNum-2]->task, |
176 &context->data[context->dataNum-1]->queue, | |
115 | 177 &context->data[context->dataNum]->queue, |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
178 &context->data[Element]->element, |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
179 &context->data[ActiveQueue]->queue); |
90 | 180 } |
181 | |
111 | 182 |
112 | 183 //__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct OdsQueue* waitI, struct Element* element, struct Queue* activeQueue) { |
111 | 184 // int i = loopCounter->i; |
112 | 185 // |
111 | 186 // task->code = TaskC; |
187 // task->key = i; | |
112 | 188 // task->waitMe = waitMe; |
189 // task->waitI = waitI; | |
190 // task->idsCount = 1; | |
191 // | |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
192 // element->data = (union Data *)task; |
111 | 193 // |
194 // context->next = CreateData1; | |
195 // loopCounter->i++; | |
196 // | |
112 | 197 // goto meta_createTask2(context, activeQueue, PutQueue1); |
111 | 198 //} |
199 // | |
112 | 200 //__code createTask4_stub(struct Context* context) { |
111 | 201 // goto createTask2(context, |
112 | 202 // &context->data[LoopCounter]->loopCounter, |
203 // &context->data[context->dataNum]->task, | |
204 // &context->data[context->dataNum-1]->queue, | |
205 // &context->data[context->dataNum-2]->odsQueue, | |
206 // &context->data[Element]->element, | |
207 // &context->data[ActiveQueue]->queue); | |
111 | 208 //} |
209 // | |
112 | 210 //__code createTask5(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) { |
111 | 211 // int i = loopCounter->i; |
112 | 212 // |
111 | 213 // task->code = TaskB; |
214 // task->key = i; | |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
215 // element->data = (union Data *)task; |
111 | 216 // |
217 // context->next = CreateData1; | |
218 // loopCounter->i++; | |
112 | 219 // |
111 | 220 // goto meta(context, WaitFor1); |
221 //} | |
222 // | |
112 | 223 //__code createTask5_stub(struct Context* context) { |
111 | 224 // goto createTask2(context, |
112 | 225 // &context->data[context->dataNum]->task, |
226 // &context->data[Element]->element); | |
111 | 227 //} |
228 | |
90 | 229 __code putQueue1(struct Context* context, struct Allocate* allocate) { |
230 allocate->size = sizeof(struct Element); | |
231 allocator(context); | |
232 | |
233 goto meta(context, PutQueue2); | |
234 } | |
235 | |
236 __code putQueue1_stub(struct Context* context) { | |
237 goto putQueue1(context, &context->data[Allocate]->allocate); | |
238 } | |
239 | |
240 __code putQueue2(struct Context* context, struct Element* new_element, struct Element* element, struct Queue* queue) { | |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
241 new_element->data = element->data; |
90 | 242 |
243 if (queue->first) | |
244 goto meta(context, PutQueue3); | |
245 else | |
246 goto meta(context, PutQueue4); | |
247 } | |
248 | |
249 __code putQueue2_stub(struct Context* context) { | |
250 goto putQueue2(context, | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
251 &context->data[context->dataNum]->element, |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
252 &context->data[Element]->element, |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
253 &context->data[Queue]->queue); |
90 | 254 } |
255 | |
256 __code putQueue3(struct Context* context, struct Queue* queue, struct Element* new_element) { | |
257 struct Element* last = queue->last; | |
258 | |
259 if (__sync_bool_compare_and_swap(&queue->last, last, new_element)) { | |
260 last->next = new_element; | |
261 queue->count++; | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
262 |
90 | 263 goto meta(context, context->next); |
264 } else { | |
265 goto meta(context, PutQueue3); | |
266 } | |
267 } | |
268 | |
269 __code putQueue3_stub(struct Context* context) { | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
270 goto putQueue3(context, &context->data[Queue]->queue, &context->data[context->dataNum]->element); |
90 | 271 } |
272 | |
273 __code putQueue4(struct Context* context, struct Queue* queue, struct Element* new_element) { | |
274 if (__sync_bool_compare_and_swap(&queue->first, 0, new_element)) { | |
275 queue->last = new_element; | |
276 queue->count++; | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
277 |
90 | 278 goto meta(context, context->next); |
279 } else { | |
280 goto meta(context, PutQueue3); | |
281 } | |
282 } | |
283 | |
284 __code putQueue4_stub(struct Context* context) { | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
285 goto putQueue4(context, &context->data[Queue]->queue, &context->data[context->dataNum]->element); |
90 | 286 } |
287 | |
86 | 288 __code createWorker(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { |
289 int i = loopCounter->i; | |
290 | |
291 if (i < worker->num) { | |
292 struct Context* worker_context = &worker->contexts[i]; | |
91 | 293 worker_context->next = GetQueue; |
294 worker_context->data[Tree] = context->data[Tree]; | |
295 worker_context->data[ActiveQueue] = context->data[ActiveQueue]; | |
86 | 296 pthread_create(&worker_context->thread, NULL, (void*)&start_code, worker_context); |
92 | 297 worker_context->thread_num = i; |
86 | 298 loopCounter->i++; |
299 | |
300 goto meta(context, CreateWorker); | |
301 } | |
302 | |
303 loopCounter->i = 0; | |
304 goto meta(context, TaskManager); | |
305 } | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
306 |
86 | 307 __code createWorker_stub(struct Context* context) { |
308 goto createWorker(context, &context->data[LoopCounter]->loopCounter, &context->data[Worker]->worker); | |
309 } | |
310 | |
311 __code taskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { | |
312 int i = loopCounter->i; | |
313 | |
314 if (i < worker->num) { | |
315 pthread_join(worker->contexts[i].thread, NULL); | |
316 loopCounter->i++; | |
317 | |
318 goto meta(context, TaskManager); | |
319 } | |
320 | |
321 loopCounter->i = 0; | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
322 |
102 | 323 struct Time *t = &context->data[Time]->time; |
324 t->next = Code2; | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
325 goto meta(context, EndTime); |
86 | 326 } |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
327 |
86 | 328 __code taskManager_stub(struct Context* context) { |
329 goto taskManager(context, &context->data[LoopCounter]->loopCounter, &context->data[Worker]->worker); | |
330 } | |
331 | |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
332 void init(int argc, char** argv) { |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
333 for (int i = 1; argv[i]; ++i) { |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
334 if (strcmp(argv[i], "-cpu") == 0) |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
335 cpu_num = (int)atoi(argv[i+1]); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
336 else if (strcmp(argv[i], "-l") == 0) |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
337 length = (int)atoi(argv[i+1]); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
338 else if (strcmp(argv[i], "-s") == 0) |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
339 split = (int)atoi(argv[i+1]); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
340 } |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
341 } |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
342 |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
343 |
86 | 344 int main(int argc, char** argv) { |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
345 init(argc, argv); |
90 | 346 |
101 | 347 array_ptr = NEWN(length, int); |
90 | 348 |
349 for(int i=0; i<length; i++) | |
350 array_ptr[i]=i; | |
86 | 351 |
101 | 352 struct Context* main_context = NEW(struct Context); |
86 | 353 initContext(main_context); |
90 | 354 main_context->next = CreateData1; |
86 | 355 |
101 | 356 struct Context* worker_contexts = NEWN(cpu_num, struct Context); |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
357 |
86 | 358 struct Worker* worker = &main_context->data[Worker]->worker; |
359 worker->num = cpu_num; | |
360 worker->contexts = worker_contexts; | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
361 |
86 | 362 for (int i = 0;i<cpu_num;i++) |
363 initContext(&worker_contexts[i]); | |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
102
diff
changeset
|
364 |
86 | 365 goto start_code(main_context); |
366 } |