Mercurial > hg > Members > Moririn
annotate src/parallel_execution/dependency.c @ 169:ea7b11f3e717
Using Queue Interface
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Nov 2016 09:48:37 +0900 |
parents | 473b7d990a1f |
children | 747067fe46bd |
rev | line source |
---|---|
112 | 1 #include <stdio.h> |
111 | 2 #include "context.h" |
3 #include "origin_cs.h" | |
4 | |
5 __code meta_waitFor(struct Context* context, struct Queue* queue, enum Code next) { | |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
114
diff
changeset
|
6 context->data[D_Queue] = (union Data *)queue; |
111 | 7 goto (context->code[next])(context); |
8 } | |
9 | |
10 __code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { | |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
11 element->data = (union Data *)slave; |
111 | 12 // enqueue waitMe |
112 | 13 goto meta_waitFor(context, master->waitMe, PutQueue1); |
111 | 14 } |
15 | |
16 __code waitFor1_stub(struct Context* context) { | |
17 // next think | |
18 } | |
19 | |
112 | 20 //__code waitFor2(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { |
21 // element->task = master; | |
22 // task->next = context->next; | |
23 // // enqueue waitI | |
24 // goto meta_waitFor(context, task->waitI, PutQueue1); | |
25 //} | |
26 // | |
27 //__code waitFor2_stub(struct Context* context) { | |
28 // // next think | |
29 //} | |
111 | 30 |
112 | 31 __code meta_spawnTask(struct Context* context, struct Queue* queue, enum Code next) { |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
114
diff
changeset
|
32 context->data[D_Queue] = (union Data *)queue; |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
33 goto meta(context, context->next); |
111 | 34 } |
35 | |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
36 __code spawnTask(struct Context* context, struct Element* element, struct Queue* activeQueue, struct Queue* waitQueue) { |
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
37 struct Queue *queue; |
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
38 if (task->idsCount == 0) { |
111 | 39 // enqueue activeQueue |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
40 queue = activeQueue; |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
41 } else { |
111 | 42 // enqueue waitQueue |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
43 queue = waitQueue; |
111 | 44 } |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
45 queue->data = element->data; |
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
46 queue->next = context->next; |
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
148
diff
changeset
|
47 goto meta_spawnTask(context, queue, queue->put); |
111 | 48 } |
49 | |
50 __code spawnTask_stub(struct Context* context) { | |
112 | 51 goto spawnTask(context, |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
114
diff
changeset
|
52 &context->data[D_Element]->element, |
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
114
diff
changeset
|
53 &context->data[D_ActiveQueue]->queue, |
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
114
diff
changeset
|
54 &context->data[D_WaitQueue]->queue); |
111 | 55 } |
56 | |
112 | 57 __code taskA(struct Context* context) { |
111 | 58 printf("TaskA\n"); |
59 goto meta(context, context->next); | |
60 } | |
61 | |
112 | 62 __code taskB(struct Context* context) { |
111 | 63 printf("TaskB\n"); |
64 goto meta(context, context->next); | |
65 } | |
66 | |
112 | 67 __code taskC(struct Context* context) { |
111 | 68 printf("TaskC\n"); |
69 goto meta(context, context->next); | |
70 } |