# HG changeset patch # User Tatsuki IHA # Date 1442298110 -32400 # Node ID a870c84acd0ec162d219d7655b7b21fb8c2a2162 # Parent 025fd6e905971cec2eb6be002555016fdbbc8bdb Change synchronizedQueue allocator from __code to Function call diff -r 025fd6e90597 -r a870c84acd0e src/synchronizedQueue/CMakeLists.txt --- a/src/synchronizedQueue/CMakeLists.txt Tue Jul 14 15:59:41 2015 +0900 +++ b/src/synchronizedQueue/CMakeLists.txt Tue Sep 15 15:21:50 2015 +0900 @@ -6,11 +6,11 @@ ) #add_executable(synchronizedQueue -# synchronizedQueue.c -# synchronizedQueueContext.c -#) +# synchronizedQueue.c +# synchronizedQueueContext.c +# -add_executable(synchronizedQueueForSem - synchronizedQueueForSem.c - synchronizedQueueForSemContext.c -) +#add_executable(synchronizedQueueForSem +# synchronizedQueueForSem.c +# synchronizedQueueForSemContext.c +#) diff -r 025fd6e90597 -r a870c84acd0e src/synchronizedQueue/allocate.h --- a/src/synchronizedQueue/allocate.h Tue Jul 14 15:59:41 2015 +0900 +++ b/src/synchronizedQueue/allocate.h Tue Sep 15 15:21:50 2015 +0900 @@ -1,15 +1,5 @@ -__code allocate(); -__code meta_allocate(); -extern __code meta(); - -__code allocate(struct Context* context) { - goto meta_allocate(context); -} - - - -__code meta_allocate(struct Context* context) { +void allocator(struct Context* context) { context->data[++context->dataNum] = context->heap; context->heap += context->data[0]->allocate.size; - goto (context->code[context->data[0]->allocate.next])(context); + return; } diff -r 025fd6e90597 -r a870c84acd0e src/synchronizedQueue/synchronizedQueue.c --- a/src/synchronizedQueue/synchronizedQueue.c Tue Jul 14 15:59:41 2015 +0900 +++ b/src/synchronizedQueue/synchronizedQueue.c Tue Sep 15 15:21:50 2015 +0900 @@ -14,27 +14,21 @@ #define NUM 100 extern __code initSynchronizedQueueContext(struct Context* context); - -//__code code1(struct Context* context) { -// context->data[Allocate]->allocate.size = sizeof(struct Element); -// context->data[Allocate]->allocate.next = Code2; -// goto meta(context, Allocator); -//} +extern void allocator(struct Context* context); __code meta(struct Context* context, enum Code next) { goto (context->code[next])(context); } -//__code code2(struct Context* context) { -// context->data[Allocate]->allocate.after_put = Code3; -// context->data[context->dataNum] -> element.value = 1024; -// goto meta(context, Sender); +//__code code1(struct Context* context) { +// context->data[Allocate]->allocate.size = sizeof(struct Element); +// goto code2(context); //} __code code1(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(long); - allocate->next = Code2; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code2); } __code code1_stub(struct Context* context) { @@ -56,8 +50,8 @@ goto meta(context, ThreadExit); } allocate->size = sizeof(struct Element); - allocate->next = Code4; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code4); } __code code3_stub(struct Context* context) { @@ -115,8 +109,8 @@ __code code5(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(long); - allocate->next = Code6; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code6); } __code code5_stub(struct Context* context) { diff -r 025fd6e90597 -r a870c84acd0e src/synchronizedQueue/synchronizedQueueContext.c --- a/src/synchronizedQueue/synchronizedQueueContext.c Tue Jul 14 15:59:41 2015 +0900 +++ b/src/synchronizedQueue/synchronizedQueueContext.c Tue Sep 15 15:21:50 2015 +0900 @@ -14,7 +14,6 @@ extern __code code10_stub(struct Context*); extern __code code11_stub(struct Context*); extern __code meta(struct Context*); -extern __code allocate(struct Context*); extern __code sender_stub(struct Context*); extern __code put_stub(struct Context*); extern __code continue_put_stub(struct Context*); @@ -31,7 +30,6 @@ context->heapStart = malloc(context->dataSize); context->codeNum = Exit; - context->code[Allocator] = allocate; context->code[Code1] = code1_stub; context->code[Code2] = code2_stub; context->code[Code3] = code3_stub; diff -r 025fd6e90597 -r a870c84acd0e src/synchronizedQueue/synchronizedQueueContext.h --- a/src/synchronizedQueue/synchronizedQueueContext.h Tue Jul 14 15:59:41 2015 +0900 +++ b/src/synchronizedQueue/synchronizedQueueContext.h Tue Sep 15 15:21:50 2015 +0900 @@ -15,7 +15,6 @@ Code9, Code10, Code11, - Allocator, Sender, Put, ContinuePut, @@ -60,7 +59,6 @@ } element; struct Allocate { long size; - enum Code next; enum Code after_put; enum Code after_get; enum Code after_fail; diff -r 025fd6e90597 -r a870c84acd0e src/synchronizedQueue/synchronizedQueueForCas.c --- a/src/synchronizedQueue/synchronizedQueueForCas.c Tue Jul 14 15:59:41 2015 +0900 +++ b/src/synchronizedQueue/synchronizedQueueForCas.c Tue Sep 15 15:21:50 2015 +0900 @@ -14,27 +14,22 @@ #define NUM 100 extern __code initSynchronizedQueueContext(struct Context* context); +extern void allocator(struct Context* context); -//__code code1(struct Context* context) { -// context->data[Allocate]->allocate.size = sizeof(struct Element); -// context->data[Allocate]->allocate.next = Code2; -// goto meta(context, Allocator); -//} __code meta(struct Context* context, enum Code next) { goto (context->code[next])(context); } -//__code code2(struct Context* context) { -// context->data[Allocate]->allocate.after_put = Code3; -// context->data[context->dataNum] -> element.value = 1024; -// goto meta(context, Sender); +//__code code1(struct Context* context) { +// context->data[Allocate]->allocate.size = sizeof(struct Element); +// goto code2(context); //} __code code1(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(long); - allocate->next = Code2; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code2); } __code code1_stub(struct Context* context) { @@ -52,8 +47,8 @@ __code code3(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(long); - allocate->next = Code4; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code4); } __code code3_stub(struct Context* context) { @@ -75,8 +70,8 @@ goto meta(context, ThreadExit); } allocate->size = sizeof(struct Element); - allocate->next = Code6; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code6); } __code code5_stub(struct Context* context) { @@ -151,8 +146,8 @@ __code code7(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(long); - allocate->next = Code8; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code8); } __code code7_stub(struct Context* context) { @@ -170,8 +165,8 @@ __code code9(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(long); - allocate->next = Code10; - goto meta(context, Allocator); + allocator(context); + goto meta(context, Code10); } __code code9_stub(struct Context* context) {