Mercurial > hg > Members > Moririn
comparison src/parallel_execution/context.c @ 186:dbc064c26b98
generate context script
author | mir3636 |
---|---|
date | Thu, 15 Dec 2016 19:38:18 +0900 |
parents | 247a2c4a8908 |
children | bacc37265386 |
comparison
equal
deleted
inserted
replaced
185:247a2c4a8908 | 186:dbc064c26b98 |
---|---|
2 | 2 |
3 #include "context.h" | 3 #include "context.h" |
4 #include "stack.h" | 4 #include "stack.h" |
5 #include "queue.h" | 5 #include "queue.h" |
6 | 6 |
7 extern __code code1_stub(struct Context*); | 7 #include "c/extern.h" |
8 extern __code code2_stub(struct Context*); | |
9 extern __code code3_stub(struct Context*); | |
10 extern __code code4_stub(struct Context*); | |
11 extern __code code5_stub(struct Context*); | |
12 extern __code find(struct Context*); | |
13 extern __code not_find(struct Context*); | |
14 extern __code code6(struct Context*); | |
15 extern __code meta(struct Context*); | |
16 extern __code put_stub(struct Context*); | |
17 extern __code replaceNode_stub(struct Context*); | |
18 extern __code replaceNode1_stub(struct Context*); | |
19 extern __code insertNode_stub(struct Context*); | |
20 extern __code rotateLeft_stub(struct Context*); | |
21 extern __code rotateLeft1_stub(struct Context*); | |
22 extern __code rotateRight_stub(struct Context*); | |
23 extern __code rotateRight1_stub(struct Context*); | |
24 extern __code colorFlip_stub(struct Context*); | |
25 extern __code fixUp_stub(struct Context*); | |
26 extern __code changeReference_stub(struct Context*); | |
27 extern __code insertCase1_stub(struct Context*); | |
28 extern __code insertCase2_stub(struct Context*); | |
29 extern __code insertCase3_stub(struct Context*); | |
30 extern __code insertCase4_stub(struct Context*); | |
31 extern __code insertCase5_stub(struct Context*); | |
32 extern __code insertCase51_stub(struct Context*); | |
33 extern __code get_stub(struct Context*); | |
34 extern __code search_stub(struct Context*); | |
35 extern __code delete_stub(struct Context*); | |
36 extern __code delete1_stub(struct Context*); | |
37 extern __code delete2_stub(struct Context*); | |
38 extern __code delete3_stub(struct Context*); | |
39 extern __code replaceNodeForDelete1_stub(struct Context*); | |
40 extern __code replaceNodeForDelete2_stub(struct Context*); | |
41 extern __code findMax1_stub(struct Context*); | |
42 extern __code findMax2_stub(struct Context*); | |
43 extern __code deleteCase1_stub(struct Context*); | |
44 extern __code deleteCase2_stub(struct Context*); | |
45 extern __code deleteCase3_stub(struct Context*); | |
46 extern __code deleteCase4_stub(struct Context*); | |
47 extern __code deleteCase5_stub(struct Context*); | |
48 extern __code deleteCase6_stub(struct Context*); | |
49 extern __code createWorker_stub(struct Context*); | |
50 extern __code taskManager_stub(struct Context*); | |
51 extern __code createData1_stub(struct Context*); | |
52 extern __code createData2_stub(struct Context*); | |
53 extern __code createTask1_stub(struct Context*); | |
54 extern __code createTask2_stub(struct Context*); | |
55 extern __code createTask3_stub(struct Context*); | |
56 extern __code createTask4_stub(struct Context*); | |
57 extern __code putQueue1_stub(struct Context*); | |
58 extern __code putQueue2_stub(struct Context*); | |
59 extern __code putQueue3_stub(struct Context*); | |
60 extern __code putQueue4_stub(struct Context*); | |
61 extern __code getTask1_stub(struct Context*); | |
62 extern __code getTask2_stub(struct Context*); | |
63 extern __code queue_test1_stub(struct Context*); | |
64 extern __code queue_test2_stub(struct Context*); | |
65 extern __code queue_test3_stub(struct Context*); | |
66 extern __code queue_test4_stub(struct Context*); | |
67 extern __code spawnTask_stub(struct Context*); | |
68 extern __code twice_stub(struct Context*); | |
69 extern __code start_time_stub(struct Context*); | |
70 extern __code end_time_stub(struct Context*); | |
71 extern __code exit_code(struct Context*); | |
72 extern __code clearSingleLinkedQueue_stub(struct Context*); | |
73 extern __code putSingleLinkedQueue_stub(struct Context *); | |
74 extern __code takeSingleLinkedQueue_stub(struct Context *); | |
75 extern __code isEmptySingleLinkedQueue_stub(struct Context *); | |
76 extern __code clearSynchronizedQueue_stub(struct Context*); | |
77 extern __code putSynchronizedQueue_stub(struct Context *); | |
78 extern __code takeSynchronizedQueue_stub(struct Context *); | |
79 extern __code isEmptySynchronizedQueue_stub(struct Context *); | |
80 extern __code spawnTaskManager_stub(struct Context*); | |
81 extern __code shutdownTaskManager_stub(struct Context*); | |
82 extern __code executeWorker_stub(struct Context*); | |
83 extern __code taskSendWorker_stub(struct Context*); | |
84 extern __code taskReciveWorker_stub(struct Context*); | |
85 extern __code shutdownWorker_stub(struct Context*); | |
86 | |
87 | 8 |
88 __code initContext(struct Context* context) { | 9 __code initContext(struct Context* context) { |
89 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; | 10 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; |
90 context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); | 11 context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); |
91 context->data = NEWN(ALLOCATE_SIZE, union Data*); | 12 context->data = NEWN(ALLOCATE_SIZE, union Data*); |
92 context->heapStart = NEWN(context->heapLimit, char); | 13 context->heapStart = NEWN(context->heapLimit, char); |
93 context->heap = context->heapStart; | 14 context->heap = context->heapStart; |
94 | 15 |
95 context->codeNum = Exit; | 16 context->codeNum = Exit; |
96 | 17 |
97 context->code[C_code1] = code1_stub; | 18 #include "c/codeGearInit.c" |
98 context->code[C_code2] = code2_stub; | |
99 context->code[C_put] = put_stub; | |
100 context->code[C_replaceNode] = replaceNode_stub; | |
101 context->code[C_replaceNode1] = replaceNode1_stub; | |
102 context->code[C_insertNode] = insertNode_stub; | |
103 context->code[C_rotateLeft] = rotateLeft_stub; | |
104 context->code[C_rotateLeft1] = rotateLeft1_stub; | |
105 context->code[C_rotateRight] = rotateRight_stub; | |
106 context->code[C_rotateRight1] = rotateRight1_stub; | |
107 context->code[C_insertCase1] = insertCase1_stub; | |
108 context->code[C_insertCase2] = insertCase2_stub; | |
109 context->code[C_insertCase3] = insertCase3_stub; | |
110 context->code[C_insertCase4] = insertCase4_stub; | |
111 context->code[C_insertCase5] = insertCase5_stub; | |
112 context->code[C_insertCase51] = insertCase51_stub; | |
113 context->code[C_get] = get_stub; | |
114 context->code[C_search] = search_stub; | |
115 | 19 |
116 context->code[C_clearSingleLinkedStack] = clearSingleLinkedStack_stub; | 20 #include "c/dataGearInit.c" |
117 context->code[C_pushSingleLinkedStack] = pushSingleLinkedStack_stub; | |
118 context->code[C_popSingleLinkedStack] = popSingleLinkedStack_stub; | |
119 context->code[C_pop2SingleLinkedStack] = pop2SingleLinkedStack_stub; | |
120 context->code[C_getSingleLinkedStack] = getSingleLinkedStack_stub; | |
121 context->code[C_get2SingleLinkedStack] = get2SingleLinkedStack_stub; | |
122 context->code[C_isEmptySingleLinkedStack] = isEmptySingleLinkedStack_stub; | |
123 | |
124 context->code[C_clearSingleLinkedQueue] = clearSingleLinkedQueue_stub; | |
125 context->code[C_putSingleLinkedQueue] = putSingleLinkedQueue_stub; | |
126 context->code[C_takeSingleLinkedQueue] = takeSingleLinkedQueue_stub; | |
127 context->code[C_isEmptySingleLinkedQueue] = isEmptySingleLinkedQueue_stub; | |
128 | |
129 context->code[C_clearSynchronizedQueue] = clearSynchronizedQueue_stub; | |
130 context->code[C_putSynchronizedQueue] = putSynchronizedQueue_stub; | |
131 context->code[C_takeSynchronizedQueue] = takeSynchronizedQueue_stub; | |
132 context->code[C_isEmptySynchronizedQueue] = isEmptySynchronizedQueue_stub; | |
133 | |
134 context->code[C_spawnTaskManager] = spawnTaskManager_stub; | |
135 context->code[C_shutdownTaskManager] = shutdownTaskManager_stub; | |
136 | |
137 /* context->code[Delete] = delete_stub; */ | |
138 /* context->code[Delete1] = delete1_stub; */ | |
139 /* context->code[Delete2] = delete2_stub; */ | |
140 /* context->code[Delete3] = delete3_stub; */ | |
141 /* context->code[Replace_d1] = replaceNodeForDelete1_stub; */ | |
142 /* context->code[Replace_d2] = replaceNodeForDelete2_stub; */ | |
143 /* context->code[FindMax1] = findMax1_stub; */ | |
144 /* context->code[FindMax2] = findMax2_stub; */ | |
145 /* context->code[DeleteCase1] = deleteCase1_stub; */ | |
146 /* context->code[DeleteCase2] = deleteCase2_stub; */ | |
147 /* context->code[DeleteCase3] = deleteCase3_stub; */ | |
148 /* context->code[DeleteCase4] = deleteCase4_stub; */ | |
149 /* context->code[DeleteCase5] = deleteCase5_stub; */ | |
150 /* context->code[DeleteCase6] = deleteCase6_stub; */ | |
151 context->code[CreateWorker] = createWorker_stub; | |
152 context->code[C_executeWorker] = executeWorker_stub; | |
153 context->code[C_taskSendWorker] = taskSendWorker_stub; | |
154 context->code[C_taskReciveWorker] = taskReciveWorker_stub; | |
155 context->code[C_shutdownWorker] = shutdownWorker_stub; | |
156 context->code[TaskManager] = taskManager_stub; | |
157 context->code[CreateData1] = createData1_stub; | |
158 context->code[CreateData2] = createData2_stub; | |
159 context->code[CreateTask1] = createTask1_stub; | |
160 context->code[CreateTask2] = createTask2_stub; | |
161 context->code[CreateTask3] = createTask3_stub; | |
162 context->code[CreateTask4] = createTask4_stub; | |
163 context->code[PutQueue1] = putQueue1_stub; | |
164 context->code[PutQueue2] = putQueue2_stub; | |
165 context->code[PutQueue3] = putQueue3_stub; | |
166 context->code[PutQueue4] = putQueue4_stub; | |
167 context->code[C_getTask1] = getTask1_stub; | |
168 context->code[C_getTask2] = getTask2_stub; | |
169 context->code[SpawnTask] = spawnTask_stub; | |
170 context->code[C_QueueTest1] = queue_test1_stub; | |
171 context->code[C_QueueTest2] = queue_test2_stub; | |
172 context->code[C_QueueTest3] = queue_test3_stub; | |
173 context->code[C_QueueTest4] = queue_test4_stub; | |
174 context->code[Twice] = twice_stub; | |
175 context->code[StartTime] = start_time_stub; | |
176 context->code[EndTime] = end_time_stub; | |
177 context->code[Exit] = exit_code; | |
178 | |
179 struct Worker* worker = ALLOC_DATA(context, Worker); | |
180 worker->id = 0; | |
181 worker->contexts = 0; | |
182 | |
183 struct Allocate* allocate = ALLOC_DATA(context, Allocate); | |
184 allocate->size = 0; | |
185 | |
186 | |
187 ALLOC_DATA(context, Stack); | |
188 | |
189 ALLOC_DATA(context, Tree); | |
190 | |
191 ALLOC_DATA(context, RedBlackTree); | |
192 | |
193 ALLOC_DATA(context, RotateTree); | |
194 | |
195 struct Node* node = ALLOC_DATA(context, Node); | |
196 node->key = 0; | |
197 node->value = 0; | |
198 node->left = 0; | |
199 node->right = 0; | |
200 | |
201 struct LoopCounter* counter = ALLOC_DATA(context, LoopCounter); | |
202 counter->i = 0; | |
203 | |
204 struct Element* element = ALLOC_DATA(context, Element); | |
205 element->data = 0; | |
206 element->next = 0; | |
207 | |
208 ALLOC_DATA(context, Time); | |
209 | 21 |
210 context->data[D_ActiveQueue] = createSynchronizedQueue(context); | 22 context->data[D_ActiveQueue] = createSynchronizedQueue(context); |
211 context->data[D_WaitQueue] = createSynchronizedQueue(context); | 23 context->data[D_WaitQueue] = createSynchronizedQueue(context); |
212 | 24 |
213 context->dataNum = D_Queue; | 25 context->dataNum = D_Queue; |