Mercurial > hg > GearsTemplate
changeset 68:5c3db1bef268
Edit synchronizedQueueIdeal
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 20 Oct 2015 17:24:59 +0900 |
parents | 9653f09ea8eb |
children | 6e5b0e4245cc |
files | src/synchronizedQueue/CMakeLists.txt src/synchronizedQueue/synchronizedQueue.c src/synchronizedQueue/synchronizedQueueIdeal.c |
diffstat | 3 files changed, 12 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/synchronizedQueue/CMakeLists.txt Wed Oct 14 17:00:38 2015 +0900 +++ b/src/synchronizedQueue/CMakeLists.txt Tue Oct 20 17:24:59 2015 +0900 @@ -8,7 +8,7 @@ #add_executable(synchronizedQueue # synchronizedQueue.c # synchronizedQueueContext.c -# +#) #add_executable(synchronizedQueueForSem # synchronizedQueueForSem.c
--- a/src/synchronizedQueue/synchronizedQueue.c Wed Oct 14 17:00:38 2015 +0900 +++ b/src/synchronizedQueue/synchronizedQueue.c Tue Oct 20 17:24:59 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 Wed Oct 14 17:00:38 2015 +0900 +++ b/src/synchronizedQueue/synchronizedQueueIdeal.c Tue Oct 20 17:24:59 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); }