Mercurial > hg > GearsTemplate
view src/synchronizedQueue/synchronizedQueueContext.c @ 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 | 2a40d697bf4e |
children |
line wrap: on
line source
#include <stdlib.h> #include "synchronizedQueueContext.h" extern __code code1_stub(struct Context*); extern __code code2_stub(struct Context*); extern __code code3_stub(struct Context*); extern __code code4_stub(struct Context*); extern __code code5_stub(struct Context*); extern __code code6_stub(struct Context*); extern __code code7_stub(struct Context*); extern __code code8_stub(struct Context*); extern __code code9_stub(struct Context*); extern __code code10_stub(struct Context*); extern __code code11_stub(struct Context*); extern __code meta(struct Context*); extern __code sender_stub(struct Context*); extern __code put_stub(struct Context*); extern __code continue_put_stub(struct Context*); extern __code receiver_stub(struct Context*); extern __code get_stub(struct Context*); extern __code continue_get_stub(struct Context*); extern __code exit_code(struct Context*); extern __code thread_exit_stub(struct Context*); __code initSynchronizedQueueContext(struct Context* context) { context->dataSize = sizeof(union Data)*ALLOCATE_SIZE; context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); context->heapStart = malloc(context->dataSize); context->codeNum = Exit; context->code[Code1] = code1_stub; context->code[Code2] = code2_stub; context->code[Code3] = code3_stub; context->code[Code4] = code4_stub; context->code[Code5] = code5_stub; context->code[Code6] = code6_stub; context->code[Code7] = code7_stub; context->code[Code8] = code8_stub; context->code[Code9] = code9_stub; context->code[Code10] = code10_stub; context->code[Code11] = code11_stub; context->code[Sender] = sender_stub; context->code[Put] = put_stub; context->code[ContinuePut] = continue_put_stub; context->code[Receiver] = receiver_stub; context->code[Get] = get_stub; context->code[ContinueGet] = continue_get_stub; context->code[ThreadExit] = thread_exit_stub; context->code[Exit] = exit_code; context->heap = context->heapStart; context->data[Allocate] = context->heap; context->heap += sizeof(struct Allocate); context->data[Queue] = context->heap; context->heap += sizeof(struct Queue); context->data[Queue]->queue.first = 0; pthread_mutex_init(&context->data[Queue]->queue.mutex, NULL); pthread_cond_init(&context->data[Queue]->queue.cond, NULL); context->dataNum = Queue; }