changeset 66:a870c84acd0e

Change synchronizedQueue allocator from __code to Function call
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 15 Sep 2015 15:21:50 +0900
parents 025fd6e90597
children 9653f09ea8eb 368306e1bfed
files src/synchronizedQueue/CMakeLists.txt src/synchronizedQueue/allocate.h src/synchronizedQueue/synchronizedQueue.c src/synchronizedQueue/synchronizedQueueContext.c src/synchronizedQueue/synchronizedQueueContext.h src/synchronizedQueue/synchronizedQueueForCas.c
diffstat 6 files changed, 33 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- 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
+#)
--- 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;
 }
--- 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) {
--- 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;
--- 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;
--- 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) {