Mercurial > hg > Gears > GearsAgda
comparison src/parallel_execution/main.c @ 248:1ede5390cda2
Fix segmentation fault but not multi thread running
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 25 Jan 2017 16:55:53 +0900 |
parents | ce262b2c1daf |
children | cd3486e4ba70 |
comparison
equal
deleted
inserted
replaced
247:ce262b2c1daf | 248:1ede5390cda2 |
---|---|
31 | 31 |
32 __code initDataGears(struct Context* context, struct LoopCounter* loopCounter, struct TaskManager* taskManager) { | 32 __code initDataGears(struct Context* context, struct LoopCounter* loopCounter, struct TaskManager* taskManager) { |
33 loopCounter->tree = &createRedBlackTree(context)->Tree; | 33 loopCounter->tree = &createRedBlackTree(context)->Tree; |
34 loopCounter->i = 0; | 34 loopCounter->i = 0; |
35 taskManager->taskManager = (union Data*)&createTaskManager(context, cpu_num, 0, 0)->TaskManager; | 35 taskManager->taskManager = (union Data*)&createTaskManager(context, cpu_num, 0, 0)->TaskManager; |
36 goto meta(context, C_createData1); | 36 goto meta(context, C_createTask1); |
37 } | 37 } |
38 | 38 |
39 __code initDataGears_stub(struct Context* context) { | 39 __code initDataGears_stub(struct Context* context) { |
40 goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager)); | 40 goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager)); |
41 } | 41 } |
49 /* puts("tree"); */ | 49 /* puts("tree"); */ |
50 /* print_tree(context->data[Tree]->tree.root); */ | 50 /* print_tree(context->data[Tree]->tree.root); */ |
51 /* puts("result"); */ | 51 /* puts("result"); */ |
52 | 52 |
53 time->next = C_code2; | 53 time->next = C_code2; |
54 goto meta(context, C_start_time); | 54 goto meta(context, C_exit_code); |
55 //goto meta(context, C_start_time); | |
55 } | 56 } |
56 | 57 |
57 __code code1_stub(struct Context* context) { | 58 __code code1_stub(struct Context* context) { |
58 goto code1(context, Gearef(context, Time)); | 59 goto code1(context, Gearef(context, Time)); |
59 } | 60 } |
151 taskManager->next = C_createTask1; | 152 taskManager->next = C_createTask1; |
152 loopCounter->i++; | 153 loopCounter->i++; |
153 | 154 |
154 goto meta(context, taskManager->taskManager->TaskManager.spawn); | 155 goto meta(context, taskManager->taskManager->TaskManager.spawn); |
155 } | 156 } |
156 | |
157 loopCounter->i = 0; | 157 loopCounter->i = 0; |
158 goto meta(context, C_code1); | 158 taskManager->next = C_code1; |
159 goto meta(context, taskManager->taskManager->TaskManager.shutdown); | |
159 } | 160 } |
160 | 161 |
161 __code createTask2_stub(struct Context* context) { | 162 __code createTask2_stub(struct Context* context) { |
162 Array* array = &ALLOCATE(context, Array)->Array; | 163 Array* array = &ALLOCATE(context, Array)->Array; |
163 goto createTask2(context, | 164 goto createTask2(context, |
164 Gearef(context, LoopCounter), | 165 Gearef(context, LoopCounter), |
165 Gearef(context, TaskManager), | 166 Gearef(context, TaskManager), |
166 Gearef(context, TaskManager)->context, | 167 Gearef(context, TaskManager)->context, |
167 array); | 168 array); |
168 } | |
169 | |
170 __code taskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { | |
171 loopCounter->i = 0; | |
172 | |
173 Time *t = &context->data[D_Time]->Time; | |
174 t->next = C_code2; | |
175 goto meta(context, C_end_time); | |
176 } | |
177 | |
178 __code taskManager_stub(struct Context* context) { | |
179 goto taskManager(context, &context->data[D_LoopCounter]->LoopCounter, &context->data[D_Worker]->Worker); | |
180 } | 169 } |
181 | 170 |
182 void init(int argc, char** argv) { | 171 void init(int argc, char** argv) { |
183 for (int i = 1; argv[i]; ++i) { | 172 for (int i = 1; argv[i]; ++i) { |
184 if (strcmp(argv[i], "-cpu") == 0) | 173 if (strcmp(argv[i], "-cpu") == 0) |