Mercurial > hg > Members > Moririn
diff src/parallel_execution/dependency.c @ 112:e3cba827d489
Add spawnTask CS
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 03 May 2016 17:29:21 +0900 |
parents | 556e203de999 |
children | d05b9937aa95 |
line wrap: on
line diff
--- a/src/parallel_execution/dependency.c Mon May 02 20:39:02 2016 +0900 +++ b/src/parallel_execution/dependency.c Tue May 03 17:29:21 2016 +0900 @@ -1,61 +1,73 @@ +#include <stdio.h> #include "context.h" #include "origin_cs.h" __code meta_waitFor(struct Context* context, struct Queue* queue, enum Code next) { - context->data[Queue] = (Data *)queue; + context->data[Queue] = (union 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); + goto meta_waitFor(context, master->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(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 waitFor2_stub(struct Context* context) { - // next think +__code meta_spawnTask(struct Context* context, struct Queue* queue, enum Code next) { + context->data[Queue] = (union Data *)queue; + goto (context->code[next])(context); } -__code spawnTask(struct Context* context, struct Task* task, struct Queue* activeQueue, struct Queue* waitQueue) { - if (task->wait_i->count == task->wait_task_count) { +__code spawnTask(struct Context* context, struct Task* task, struct Element* element, struct Queue* activeQueue, struct Queue* waitQueue) { + //printf("spawn Task\n"); + if (task->waitI->count == task->idsCount) { + //printf("put ActiveQueue\n"); element->task = task; // enqueue activeQueue - goto meta(context, PutQueue1); + goto meta_spawnTask(context, activeQueue, PutQueue1); } else { + //printf("put WaitQueue\n"); element->task = task; // enqueue waitQueue - goto meta(context, PutQueue1); + goto meta_spawnTask(context, waitQueue, PutQueue1); } } __code spawnTask_stub(struct Context* context) { - // next think + goto spawnTask(context, + &context->data[context->dataNum-2]->task, + &context->data[Element]->element, + &context->data[ActiveQueue]->queue, + &context->data[WaitQueue]->queue); } -__code taskA(struct Context*) { +__code taskA(struct Context* context) { printf("TaskA\n"); goto meta(context, context->next); } -__code taskB(struct Context*) { +__code taskB(struct Context* context) { printf("TaskB\n"); goto meta(context, context->next); } -__code taskC(struct Context*) { +__code taskC(struct Context* context) { printf("TaskC\n"); goto meta(context, context->next); }