comparison 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
comparison
equal deleted inserted replaced
90:4b5bf5b40970 91:1e074c3878c7
51 extern __code createTask2_stub(struct Context*); 51 extern __code createTask2_stub(struct Context*);
52 extern __code putQueue1_stub(struct Context*); 52 extern __code putQueue1_stub(struct Context*);
53 extern __code putQueue2_stub(struct Context*); 53 extern __code putQueue2_stub(struct Context*);
54 extern __code putQueue3_stub(struct Context*); 54 extern __code putQueue3_stub(struct Context*);
55 extern __code putQueue4_stub(struct Context*); 55 extern __code putQueue4_stub(struct Context*);
56 extern __code getQueue_stub(struct Context*);
56 extern __code exit_code(struct Context*); 57 extern __code exit_code(struct Context*);
57 58
58 __code initContext(struct Context* context) { 59 __code initContext(struct Context* context) {
59 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; 60 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
60 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); 61 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
108 context->code[CreateTask2] = createTask2_stub; 109 context->code[CreateTask2] = createTask2_stub;
109 context->code[PutQueue1] = putQueue1_stub; 110 context->code[PutQueue1] = putQueue1_stub;
110 context->code[PutQueue2] = putQueue2_stub; 111 context->code[PutQueue2] = putQueue2_stub;
111 context->code[PutQueue3] = putQueue3_stub; 112 context->code[PutQueue3] = putQueue3_stub;
112 context->code[PutQueue4] = putQueue4_stub; 113 context->code[PutQueue4] = putQueue4_stub;
114 context->code[GetQueue] = getQueue_stub;
113 context->code[Exit] = exit_code; 115 context->code[Exit] = exit_code;
114 116
115 context->heap = context->heapStart; 117 context->heap = context->heapStart;
116 118
117 context->data[Worker] = context->heap; 119 context->data[Worker] = context->heap;
120 context->data[Allocate] = context->heap; 122 context->data[Allocate] = context->heap;
121 context->heap += sizeof(struct Allocate); 123 context->heap += sizeof(struct Allocate);
122 124
123 context->data[Tree] = context->heap; 125 context->data[Tree] = context->heap;
124 context->heap += sizeof(struct Tree); 126 context->heap += sizeof(struct Tree);
127
128 context->data[Traverse] = context->heap;
129 context->heap += sizeof(struct Traverse);
125 130
126 context->data[Node] = context->heap; 131 context->data[Node] = context->heap;
127 context->heap += sizeof(struct Node); 132 context->heap += sizeof(struct Node);
128 133
129 context->data[LoopCounter] = context->heap; 134 context->data[LoopCounter] = context->heap;
143 148
144 struct Allocate* allocate = &context->data[Allocate]->allocate; 149 struct Allocate* allocate = &context->data[Allocate]->allocate;
145 allocate->size = 0; 150 allocate->size = 0;
146 151
147 struct Tree* tree = &context->data[Tree]->tree; 152 struct Tree* tree = &context->data[Tree]->tree;
148 context->tree = tree;
149 tree->root = 0; 153 tree->root = 0;
150 tree->current = 0;
151 154
152 struct Node* node = &context->data[Node]->node; 155 struct Node* node = &context->data[Node]->node;
153 node->key = 0; 156 node->key = 0;
154 node->value = 0; 157 node->value = 0;
155 node->left = 0; 158 node->left = 0;
161 struct Element* element = &context->data[Element]->element; 164 struct Element* element = &context->data[Element]->element;
162 element->task = 0; 165 element->task = 0;
163 element->next = 0; 166 element->next = 0;
164 167
165 struct Queue* activeQueue = &context->data[ActiveQueue]->queue; 168 struct Queue* activeQueue = &context->data[ActiveQueue]->queue;
166 context->activeQueue = activeQueue;
167 activeQueue->first = 0; 169 activeQueue->first = 0;
168 activeQueue->last = 0; 170 activeQueue->last = 0;
169 activeQueue->count = 0; 171 activeQueue->count = 0;
170 172
171 context->node_stack = stack_init(sizeof(struct Node*), 100); 173 context->node_stack = stack_init(sizeof(struct Node*), 100);