diff src/parallel_execution/main.c @ 232:123b0d277b84

worker interface
author mir3636
date Sun, 22 Jan 2017 19:02:12 +0900
parents 6c0692c9bfed
children 865179a0a56d
line wrap: on
line diff
--- a/src/parallel_execution/main.c	Sun Jan 22 18:19:23 2017 +0900
+++ b/src/parallel_execution/main.c	Sun Jan 22 19:02:12 2017 +0900
@@ -51,7 +51,7 @@
     /* print_tree(context->data[Tree]->tree.root); */
     /* puts("result"); */
 
-    time->next = C_createWorker1;
+    time->next = C_code2;
     goto meta(context, C_start_time);
 }
 
@@ -140,39 +140,7 @@
             task);
 }
 
-__code createWorker1(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) {
-    int i = loopCounter->i;
-
-    if (i < worker->id) {
-        struct Context* worker_context = &worker->contexts[i];
-        worker_context->next = C_getTask1;
-        worker_context->data[D_Tree] = context->data[D_Tree];
-        // worker_context->data[D_ActiveQueue] = context->data[D_ActiveQueue];
-        pthread_create(&worker_context->thread, NULL, (void*)&start_code, worker_context);
-        worker_context->thread_num = i;
-        loopCounter->i++;
-
-        goto meta(context, C_createWorker1);
-    }
-
-    loopCounter->i = 0;
-    goto meta(context, C_taskManager);
-}
-
-__code createWorker1_stub(struct Context* context) {
-    goto createWorker1(context, &context->data[D_LoopCounter]->LoopCounter, &context->data[D_Worker]->Worker);
-}
-
 __code taskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) {
-    int i = loopCounter->i;
-
-    if (i < worker->id) {
-        pthread_join(worker->contexts[i].thread, NULL);
-        loopCounter->i++;
-
-        goto meta(context, C_taskManager);
-    }
-
     loopCounter->i = 0;
 
     Time *t = &context->data[D_Time]->Time;
@@ -210,10 +178,6 @@
 
     struct Context* worker_contexts = NEWN(cpu_num, struct Context);
 
-    struct Worker* worker = &main_context->data[D_Worker]->Worker;
-    worker->id = cpu_num;
-    worker->contexts = worker_contexts;
-
     for (int i = 0;i<cpu_num;i++)
         initContext(&worker_contexts[i]);