changeset 71:6e5b0e4245cc

merge
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 27 Oct 2015 01:15:29 +0900
parents 302793faeb78 (current diff) 5c3db1bef268 (diff)
children 5c4b9d116eda
files
diffstat 3 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/synchronizedQueue/CMakeLists.txt	Tue Oct 20 16:23:23 2015 +0900
+++ b/src/synchronizedQueue/CMakeLists.txt	Tue Oct 27 01:15:29 2015 +0900
@@ -8,7 +8,7 @@
 #add_executable(synchronizedQueue
 #              synchronizedQueue.c
 #              synchronizedQueueContext.c
-#
+#)
 
 #add_executable(synchronizedQueueForSem
 #               synchronizedQueueForSem.c
--- a/src/synchronizedQueue/synchronizedQueue.c	Tue Oct 20 16:23:23 2015 +0900
+++ b/src/synchronizedQueue/synchronizedQueue.c	Tue Oct 27 01:15:29 2015 +0900
@@ -153,8 +153,9 @@
 __code receiver_stub(struct Context* context) {
     goto receiver(context, &context->data[Queue]->queue);
 }
-__code meta_get(struct Context* context, enum Code next) {
-    pthread_mutex_unlock(&context->data[Queue]->queue.mutex);
+
+__code meta_get(struct Context* context, struct Queue* queue, enum Code next) {
+    pthread_mutex_unlock(&queue->mutex);
     goto (context->code[next])(context);
 }
 
@@ -166,7 +167,7 @@
     printf("      Get %d\n\n", queue->first->value);
     queue->first = (queue->first->next) ? queue->first->next : 0;
     queue->count--;
-    goto meta_get(context, allocate->after_get);
+    goto meta_get(context, queue, allocate->after_get);
 }
 
 __code get_stub(struct Context* context) {
--- a/src/synchronizedQueue/synchronizedQueueIdeal.c	Tue Oct 20 16:23:23 2015 +0900
+++ b/src/synchronizedQueue/synchronizedQueueIdeal.c	Tue Oct 27 01:15:29 2015 +0900
@@ -27,14 +27,12 @@
 
 __code code1(struct Context* context, struct Allocate* allocate) {
     allocate->size = sizeof(long);
-    allocator(context);
-    long* count = &context->data[Counter]->count
+    allocator();
     goto code2(count)
 }
 
 __code code2(struct Context* context, long* count) {
     *count = 0;
-    struct Allocate* allocate = &context->data[Allocate]->allocate;
     goto code3(count, allocate);
 }
 
@@ -45,7 +43,6 @@
     }
     allocate->size = sizeof(struct Element);
     allocator(context);
-    struct Element* element = &context->data[context->dataNum]->element)
     got code4(count, allocate, element);
 }
 
@@ -63,7 +60,7 @@
 }
 
 __code sender(struct Context* context, struct Queue* queue) {
-    goto meta_sender(context, queue, Put);
+    goto put(queue);
 }
 
 __code meta_put(struct Context* context, struct Queue* queue, enum Code next) {
@@ -89,7 +86,7 @@
 
 __code code5(struct Context* context, struct Allocate* allocate) {
     allocate->size = sizeof(long);
-    allocator(context);
+    allocator();
     long* count = &context->data[Counter]->count
     goto code6(count);
 }
@@ -107,11 +104,10 @@
 __code code7(struct Context* context, long* count, struct Allocate* allocate) {
     long loop = *count;
     if(loop == NUM) {
-        goto meta(context, ThreadExit);
+        goto threadExit();
     }
     (*count)++;
     allocate->after_get = Code7;
-    struct Queue* queue = &context->data[Queue]->queue;
     goto receiver(queue);
 }
 
@@ -122,11 +118,11 @@
 }
 
 __code receiver(struct Context* context, struct Queue* queue) {
-    goto meta_receiver(context, queue, Get);
+    goto get(queue);
 }
 
-__code meta_get(struct Context* context, enum Code next) {
-    pthread_mutex_unlock(&context->data[Queue]->queue.mutex);
+__code meta_get(struct Context* context, struct Queue* queue, enum Code next) {
+    pthread_mutex_unlock(&queue->mutex);
     goto (context->code[next])(context);
 }