Mercurial > hg > GearsTemplate
view src/parallel_execution/context.c @ 182:57a11c15ff4c
Add queue_test
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Dec 2016 21:33:11 +0900 |
parents | 5077cf9bf54e |
children | 21840c7fb309 |
line wrap: on
line source
#include <stdlib.h> #include "context.h" #include "stack.h" #include "queue.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 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 replaceNode1_stub(struct Context*); extern __code insertNode_stub(struct Context*); extern __code rotateLeft_stub(struct Context*); extern __code rotateLeft1_stub(struct Context*); extern __code rotateRight_stub(struct Context*); extern __code rotateRight1_stub(struct Context*); extern __code colorFlip_stub(struct Context*); extern __code fixUp_stub(struct Context*); extern __code changeReference_stub(struct Context*); extern __code insertCase1_stub(struct Context*); extern __code insertCase2_stub(struct Context*); extern __code insertCase3_stub(struct Context*); extern __code insertCase4_stub(struct Context*); extern __code insertCase5_stub(struct Context*); extern __code insertCase51_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 createTask3_stub(struct Context*); extern __code createTask4_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 getTask1_stub(struct Context*); extern __code getTask2_stub(struct Context*); extern __code queue_test1_stub(struct Context*); extern __code queue_test2_stub(struct Context*); extern __code queue_test3_stub(struct Context*); extern __code queue_test4_stub(struct Context*); extern __code spawnTask_stub(struct Context*); extern __code twice_stub(struct Context*); extern __code start_time_stub(struct Context*); extern __code end_time_stub(struct Context*); extern __code exit_code(struct Context*); extern __code clearSingleLinkedQueue_stub(struct Context*); extern __code putSingleLinkedQueue_stub(struct Context *); extern __code takeSingleLinkedQueue_stub(struct Context *); extern __code isEmptySingleLinkedQueue_stub(struct Context *); extern __code clearSynchronizedQueue_stub(struct Context*); extern __code putSynchronizedQueue_stub(struct Context *); extern __code takeSynchronizedQueue_stub(struct Context *); extern __code isEmptySynchronizedQueue_stub(struct Context *); extern __code spawnTaskManager_stub(struct Context*); extern __code shutdownTaskManager_stub(struct Context*); __code initContext(struct Context* context) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); context->data = NEWN(ALLOCATE_SIZE, union Data*); context->heapStart = NEWN(context->heapLimit, char); context->heap = context->heapStart; context->codeNum = Exit; context->code[C_code1] = code1_stub; context->code[C_code2] = code2_stub; context->code[C_put] = put_stub; context->code[C_replaceNode] = replaceNode_stub; context->code[C_replaceNode1] = replaceNode1_stub; context->code[C_insertNode] = insertNode_stub; context->code[C_rotateLeft] = rotateLeft_stub; context->code[C_rotateLeft1] = rotateLeft1_stub; context->code[C_rotateRight] = rotateRight_stub; context->code[C_rotateRight1] = rotateRight1_stub; context->code[C_insertCase1] = insertCase1_stub; context->code[C_insertCase2] = insertCase2_stub; context->code[C_insertCase3] = insertCase3_stub; context->code[C_insertCase4] = insertCase4_stub; context->code[C_insertCase5] = insertCase5_stub; context->code[C_insertCase51] = insertCase51_stub; context->code[C_get] = get_stub; context->code[C_search] = search_stub; context->code[C_clearSingleLinkedStack] = clearSingleLinkedStack_stub; context->code[C_pushSingleLinkedStack] = pushSingleLinkedStack_stub; context->code[C_popSingleLinkedStack] = popSingleLinkedStack_stub; context->code[C_pop2SingleLinkedStack] = pop2SingleLinkedStack_stub; context->code[C_getSingleLinkedStack] = getSingleLinkedStack_stub; context->code[C_get2SingleLinkedStack] = get2SingleLinkedStack_stub; context->code[C_isEmptySingleLinkedStack] = isEmptySingleLinkedStack_stub; context->code[C_clearSingleLinkedQueue] = clearSingleLinkedQueue_stub; context->code[C_putSingleLinkedQueue] = putSingleLinkedQueue_stub; context->code[C_takeSingleLinkedQueue] = takeSingleLinkedQueue_stub; context->code[C_isEmptySingleLinkedQueue] = isEmptySingleLinkedQueue_stub; context->code[C_clearSynchronizedQueue] = clearSynchronizedQueue_stub; context->code[C_putSynchronizedQueue] = putSynchronizedQueue_stub; context->code[C_takeSynchronizedQueue] = takeSynchronizedQueue_stub; context->code[C_isEmptySynchronizedQueue] = isEmptySynchronizedQueue_stub; context->code[C_spawnTaskManager] = spawnTaskManager_stub; context->code[C_taskSendTaskManager] = taskSendTaskManager_stub; context->code[C_shutdownTaskManager] = shutdownTaskManager_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[CreateTask3] = createTask3_stub; context->code[CreateTask4] = createTask4_stub; context->code[PutQueue1] = putQueue1_stub; context->code[PutQueue2] = putQueue2_stub; context->code[PutQueue3] = putQueue3_stub; context->code[PutQueue4] = putQueue4_stub; context->code[C_getTask1] = getTask1_stub; context->code[C_getTask2] = getTask2_stub; context->code[SpawnTask] = spawnTask_stub; context->code[C_QueueTest1] = queue_test1_stub; context->code[C_QueueTest2] = queue_test2_stub; context->code[C_QueueTest3] = queue_test3_stub; context->code[C_QueueTest4] = queue_test4_stub; context->code[Twice] = twice_stub; context->code[StartTime] = start_time_stub; context->code[EndTime] = end_time_stub; context->code[Exit] = exit_code; struct Worker* worker = ALLOC_DATA(context, Worker); worker->num = 0; worker->contexts = 0; struct Allocate* allocate = ALLOC_DATA(context, Allocate); allocate->size = 0; ALLOC_DATA(context, Stack); ALLOC_DATA(context, Tree); ALLOC_DATA(context, RedBlackTree); ALLOC_DATA(context, RotateTree); struct Node* node = ALLOC_DATA(context, Node); node->key = 0; node->value = 0; node->left = 0; node->right = 0; struct LoopCounter* counter = ALLOC_DATA(context, LoopCounter); counter->i = 0; struct Element* element = ALLOC_DATA(context, Element); element->data = 0; element->next = 0; ALLOC_DATA(context, Time); context->data[D_ActiveQueue] = createSynchronizedQueue(context); context->data[D_WaitQueue] = createSynchronizedQueue(context); context->dataNum = D_Queue; }