comparison src/parallel_execution/dependency.c @ 111:556e203de999

Add dependency.c
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Mon, 02 May 2016 20:39:02 +0900
parents
children e3cba827d489
comparison
equal deleted inserted replaced
110:fbcdbe8db53c 111:556e203de999
1 #include "context.h"
2 #include "origin_cs.h"
3
4 __code meta_waitFor(struct Context* context, struct Queue* queue, enum Code next) {
5 context->data[Queue] = (Data *)queue;
6 goto (context->code[next])(context);
7 }
8
9 __code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) {
10 element->task = slave;
11 task->next = WaitFor2;
12 // enqueue waitMe
13 goto meta_waitFor(context, task->waitMe, PutQueue1);
14 }
15
16 __code waitFor1_stub(struct Context* context) {
17 // next think
18 }
19
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 }
30
31 __code spawnTask(struct Context* context, struct Task* task, struct Queue* activeQueue, struct Queue* waitQueue) {
32 if (task->wait_i->count == task->wait_task_count) {
33 element->task = task;
34 // enqueue activeQueue
35 goto meta(context, PutQueue1);
36 }
37 else {
38 element->task = task;
39 // enqueue waitQueue
40 goto meta(context, PutQueue1);
41 }
42 }
43
44 __code spawnTask_stub(struct Context* context) {
45 // next think
46 }
47
48 __code taskA(struct Context*) {
49 printf("TaskA\n");
50 goto meta(context, context->next);
51 }
52
53 __code taskB(struct Context*) {
54 printf("TaskB\n");
55 goto meta(context, context->next);
56 }
57
58 __code taskC(struct Context*) {
59 printf("TaskC\n");
60 goto meta(context, context->next);
61 }