Mercurial > hg > GearsTemplate
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/dependency.c Mon May 02 20:39:02 2016 +0900 @@ -0,0 +1,61 @@ +#include "context.h" +#include "origin_cs.h" + +__code meta_waitFor(struct Context* context, struct Queue* queue, enum Code next) { + context->data[Queue] = (Data *)queue; + goto (context->code[next])(context); +} + +__code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { + element->task = slave; + task->next = WaitFor2; + // enqueue waitMe + goto meta_waitFor(context, task->waitMe, PutQueue1); +} + +__code waitFor1_stub(struct Context* context) { + // next think +} + +__code waitFor2(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { + element->task = master; + task->next = context->next; + // enqueue waitI + goto meta_waitFor(context, task->waitI, PutQueue1); +} + +__code waitFor2_stub(struct Context* context) { + // next think +} + +__code spawnTask(struct Context* context, struct Task* task, struct Queue* activeQueue, struct Queue* waitQueue) { + if (task->wait_i->count == task->wait_task_count) { + element->task = task; + // enqueue activeQueue + goto meta(context, PutQueue1); + } + else { + element->task = task; + // enqueue waitQueue + goto meta(context, PutQueue1); + } +} + +__code spawnTask_stub(struct Context* context) { + // next think +} + +__code taskA(struct Context*) { + printf("TaskA\n"); + goto meta(context, context->next); +} + +__code taskB(struct Context*) { + printf("TaskB\n"); + goto meta(context, context->next); +} + +__code taskC(struct Context*) { + printf("TaskC\n"); + goto meta(context, context->next); +}