diff src/parallel_execution/main.c @ 123:4ff6f093b695

Fix segmentation fault
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 13 Sep 2016 11:54:25 +0900
parents a086857e1812
children acf0453b1c7a
line wrap: on
line diff
--- a/src/parallel_execution/main.c	Thu Aug 25 03:23:29 2016 +0900
+++ b/src/parallel_execution/main.c	Tue Sep 13 11:54:25 2016 +0900
@@ -207,15 +207,15 @@
 __code createTask3(struct Context* context, struct Allocate* allocate) {
     allocate->size = sizeof(struct Task);
     allocator(context);
-    goto meta(context, CreateTask2);
+    goto meta(context, CreateTask4);
 }
 
 __code createTask3_stub(struct Context* context) {
-    goto createTask1(context, &context->data[Allocate]->allocate);
+    goto createTask3(context, &context->data[Allocate]->allocate);
 }
 
 
-__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element, struct Node* node) {
+__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element) {
     int i = loopCounter->i;
 
     task->code = Add;
@@ -224,9 +224,7 @@
     task->iKeys[1] = i-2;
     loopCounter->i -= 2;
     element->data = (union Data *)task;
-    context->next = WaitFor;
-
-    node->key = task->oKeys[0];
+    context->next = CreateTask5;
     goto meta(context, Get);
 }
 
@@ -234,8 +232,23 @@
     goto createTask4(context,
             &context->data[LoopCounter]->loopCounter,
             &context->data[context->dataNum]->task,
-            &context->data[Element]->element,
-            &context->data[Node]->node);
+            &context->data[Element]->element
+            );
+}
+
+__code createTask5(struct Context* context, struct Task* task, struct Node* node) {
+    node->key = task->oKeys[0];
+    loopCounter->i = 0;
+    context->next = Code1;
+    goto meta(context, WaitFor);
+}
+
+__code createTask5_stub(struct Context* context) {
+    goto createTask4(context,
+            &context->data[LoopCounter]->loopCounter,
+            &context->data[context->dataNum]->task,
+            &context->data[Node]->node
+            );
 }
 
 __code putQueue1(struct Context* context, struct Allocate* allocate) {
@@ -324,7 +337,7 @@
 
 __code taskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker, struct Queue* waitQueue, struct Queue* ActiveQueue) {
     if (waitQueue->first) {
-        goto meta(context, Poll1);
+       goto meta(context, Poll1);
     }
     int i = loopCounter->i;
     if (i < worker->num) {
@@ -353,6 +366,7 @@
 }
 
 __code poll1(struct Context* context, struct Queue* waitQueue) {
+    usleep(100);
     context->next = Poll2;
     goto meta_poll1(context, waitQueue, GetQueue1);
 }