Mercurial > hg > Members > innparusu > Gears
view src/parallel_execution/context.c @ 91:1e074c3878c7
modify tree
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 26 Jan 2016 07:46:26 +0900 |
parents | 4b5bf5b40970 |
children | 851da1107223 |
line wrap: on
line source
#include <stdlib.h> #include "context.h" extern __code code1_stub(struct Context*); extern __code code2_stub(struct Context*); extern __code code3_stub(struct Context*); extern __code code4(struct Context*); extern __code code5(struct Context*); extern __code find(struct Context*); extern __code not_find(struct Context*); extern __code code6(struct Context*); extern __code meta(struct Context*); extern __code put_stub(struct Context*); extern __code replaceNode_stub(struct Context*); extern __code insertNode_stub(struct Context*); extern __code rotateLeft_stub(struct Context*); extern __code rotateRight_stub(struct Context*); extern __code colorFlip_stub(struct Context*); extern __code fixUp_stub(struct Context*); extern __code changeReference_stub(struct Context*); extern __code insert1_stub(struct Context*); extern __code insert2_stub(struct Context*); extern __code insert3_stub(struct Context*); extern __code insert4_stub(struct Context*); extern __code insert4_1_stub(struct Context*); extern __code insert4_2_stub(struct Context*); extern __code insert5_stub(struct Context*); extern __code stackClear_stub(struct Context*); extern __code get_stub(struct Context*); extern __code search_stub(struct Context*); extern __code delete_stub(struct Context*); extern __code delete1_stub(struct Context*); extern __code delete2_stub(struct Context*); extern __code delete3_stub(struct Context*); extern __code replaceNodeForDelete1_stub(struct Context*); extern __code replaceNodeForDelete2_stub(struct Context*); extern __code findMax1_stub(struct Context*); extern __code findMax2_stub(struct Context*); extern __code deleteCase1_stub(struct Context*); extern __code deleteCase2_stub(struct Context*); extern __code deleteCase3_stub(struct Context*); extern __code deleteCase4_stub(struct Context*); extern __code deleteCase5_stub(struct Context*); extern __code deleteCase6_stub(struct Context*); extern __code createWorker_stub(struct Context*); extern __code taskManager_stub(struct Context*); extern __code createData1_stub(struct Context*); extern __code createData2_stub(struct Context*); extern __code createTask1_stub(struct Context*); extern __code createTask2_stub(struct Context*); extern __code putQueue1_stub(struct Context*); extern __code putQueue2_stub(struct Context*); extern __code putQueue3_stub(struct Context*); extern __code putQueue4_stub(struct Context*); extern __code getQueue_stub(struct Context*); extern __code exit_code(struct Context*); __code initContext(struct Context* context) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); context->heapStart = malloc(context->heapLimit); context->codeNum = Exit; context->code[Code1] = code1_stub; //context->code[Code2] = code2_stub; /* context->code[Code3] = code3_stub; */ /* context->code[Code4] = code4; */ /* context->code[Code5] = code5; */ /* context->code[Find] = find; */ /* context->code[Not_find] = not_find; */ /* context->code[Code6] = code6; */ context->code[PutTree] = put_stub; context->code[Replace] = replaceNode_stub; context->code[Insert] = insertNode_stub; context->code[RotateL] = rotateLeft_stub; context->code[RotateR] = rotateRight_stub; context->code[InsertCase1] = insert1_stub; context->code[InsertCase2] = insert2_stub; context->code[InsertCase3] = insert3_stub; context->code[InsertCase4] = insert4_stub; context->code[InsertCase4_1] = insert4_1_stub; context->code[InsertCase4_2] = insert4_2_stub; context->code[InsertCase5] = insert5_stub; context->code[StackClear] = stackClear_stub; /* context->code[Get] = get_stub; */ /* context->code[Search] = search_stub; */ /* context->code[Delete] = delete_stub; */ /* context->code[Delete1] = delete1_stub; */ /* context->code[Delete2] = delete2_stub; */ /* context->code[Delete3] = delete3_stub; */ /* context->code[Replace_d1] = replaceNodeForDelete1_stub; */ /* context->code[Replace_d2] = replaceNodeForDelete2_stub; */ /* context->code[FindMax1] = findMax1_stub; */ /* context->code[FindMax2] = findMax2_stub; */ /* context->code[DeleteCase1] = deleteCase1_stub; */ /* context->code[DeleteCase2] = deleteCase2_stub; */ /* context->code[DeleteCase3] = deleteCase3_stub; */ /* context->code[DeleteCase4] = deleteCase4_stub; */ /* context->code[DeleteCase5] = deleteCase5_stub; */ /* context->code[DeleteCase6] = deleteCase6_stub; */ context->code[CreateWorker] = createWorker_stub; context->code[TaskManager] = taskManager_stub; context->code[CreateData1] = createData1_stub; context->code[CreateData2] = createData2_stub; context->code[CreateTask1] = createTask1_stub; context->code[CreateTask2] = createTask2_stub; context->code[PutQueue1] = putQueue1_stub; context->code[PutQueue2] = putQueue2_stub; context->code[PutQueue3] = putQueue3_stub; context->code[PutQueue4] = putQueue4_stub; context->code[GetQueue] = getQueue_stub; context->code[Exit] = exit_code; context->heap = context->heapStart; context->data[Worker] = context->heap; context->heap += sizeof(struct Worker); context->data[Allocate] = context->heap; context->heap += sizeof(struct Allocate); context->data[Tree] = context->heap; context->heap += sizeof(struct Tree); context->data[Traverse] = context->heap; context->heap += sizeof(struct Traverse); context->data[Node] = context->heap; context->heap += sizeof(struct Node); context->data[LoopCounter] = context->heap; context->heap += sizeof(struct LoopCounter); context->data[Element] = context->heap; context->heap += sizeof(struct Element); context->data[ActiveQueue] = context->heap; context->heap += sizeof(struct Queue); context->dataNum = ActiveQueue; struct Worker* worker = &context->data[Worker]->worker; worker->num = 0; worker->contexts = 0; struct Allocate* allocate = &context->data[Allocate]->allocate; allocate->size = 0; struct Tree* tree = &context->data[Tree]->tree; tree->root = 0; struct Node* node = &context->data[Node]->node; node->key = 0; node->value = 0; node->left = 0; node->right = 0; struct LoopCounter* counter = &context->data[LoopCounter]->loopCounter; counter->i = 0; struct Element* element = &context->data[Element]->element; element->task = 0; element->next = 0; struct Queue* activeQueue = &context->data[ActiveQueue]->queue; activeQueue->first = 0; activeQueue->last = 0; activeQueue->count = 0; context->node_stack = stack_init(sizeof(struct Node*), 100); context->code_stack = stack_init(sizeof(enum Code), 100); }