Mercurial > hg > GearsTemplate
annotate src/parallel_execution/context.c @ 167:34562e63981f
create queue.c
author | mir3636 |
---|---|
date | Mon, 21 Nov 2016 18:03:43 +0900 |
parents | 473b7d990a1f |
children | ea7b11f3e717 |
rev | line source |
---|---|
86 | 1 #include <stdlib.h> |
2 | |
3 #include "context.h" | |
132 | 4 #include "stack.h" |
167 | 5 #include "queue.h" |
86 | 6 |
7 extern __code code1_stub(struct Context*); | |
8 extern __code code2_stub(struct Context*); | |
9 extern __code code3_stub(struct Context*); | |
10 extern __code code4(struct Context*); | |
11 extern __code code5(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*); | |
124 | 18 extern __code replaceNode1_stub(struct Context*); |
86 | 19 extern __code insertNode_stub(struct Context*); |
20 extern __code rotateLeft_stub(struct Context*); | |
140 | 21 extern __code rotateLeft1_stub(struct Context*); |
86 | 22 extern __code rotateRight_stub(struct Context*); |
140 | 23 extern __code rotateRight1_stub(struct Context*); |
86 | 24 extern __code colorFlip_stub(struct Context*); |
25 extern __code fixUp_stub(struct Context*); | |
26 extern __code changeReference_stub(struct Context*); | |
144 | 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*); | |
86 | 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*); | |
90 | 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*); | |
112 | 55 extern __code createTask3_stub(struct Context*); |
56 extern __code createTask4_stub(struct Context*); | |
90 | 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*); | |
91 | 61 extern __code getQueue_stub(struct Context*); |
112 | 62 extern __code spawnTask_stub(struct Context*); |
92 | 63 extern __code twice_stub(struct Context*); |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
64 extern __code start_time_stub(struct Context*); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
65 extern __code end_time_stub(struct Context*); |
86 | 66 extern __code exit_code(struct Context*); |
67 | |
68 __code initContext(struct Context* context) { | |
69 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; | |
101 | 70 context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); |
71 context->data = NEWN(ALLOCATE_SIZE, union Data*); | |
72 context->heapStart = NEWN(context->heapLimit, char); | |
73 context->heap = context->heapStart; | |
86 | 74 |
75 context->codeNum = Exit; | |
76 | |
144 | 77 context->code[C_code1] = code1_stub; |
78 context->code[C_code2] = code2_stub; | |
79 context->code[C_put] = put_stub; | |
80 context->code[C_replaceNode] = replaceNode_stub; | |
81 context->code[C_replaceNode1] = replaceNode1_stub; | |
82 context->code[C_insertNode] = insertNode_stub; | |
83 context->code[C_rotateLeft] = rotateLeft_stub; | |
84 context->code[C_rotateLeft1] = rotateLeft1_stub; | |
85 context->code[C_rotateRight] = rotateRight_stub; | |
86 context->code[C_rotateRight1] = rotateRight1_stub; | |
87 context->code[C_insertCase1] = insertCase1_stub; | |
88 context->code[C_insertCase2] = insertCase2_stub; | |
89 context->code[C_insertCase3] = insertCase3_stub; | |
90 context->code[C_insertCase4] = insertCase4_stub; | |
91 context->code[C_insertCase5] = insertCase5_stub; | |
92 context->code[C_insertCase51] = insertCase51_stub; | |
93 context->code[C_stackClear] = stackClear_stub; | |
94 context->code[C_get] = get_stub; | |
95 context->code[C_search] = search_stub; | |
140 | 96 |
145
cc071cf1ba85
add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
97 context->code[C_clearSingleLinkedStack] = clearSingleLinkedStack_stub; |
144 | 98 context->code[C_pushSingleLinkedStack] = pushSingleLinkedStack_stub; |
99 context->code[C_popSingleLinkedStack] = popSingleLinkedStack_stub; | |
100 context->code[C_pop2SingleLinkedStack] = pop2SingleLinkedStack_stub; | |
101 context->code[C_getSingleLinkedStack] = getSingleLinkedStack_stub; | |
102 context->code[C_get2SingleLinkedStack] = get2SingleLinkedStack_stub; | |
103 context->code[C_isEmptySingleLinkedStack] = isEmptySingleLinkedStack_stub; | |
140 | 104 |
167 | 105 context->code[C_clearSingleLinkedQueue] = clearSingleLinkedQueue_stub; |
106 context->code[C_putSingleLinkedQueue] = putSingleLinkedQueue_stub; | |
107 context->code[C_takeSingleLinkedQueue] = takeSingleLinkedQueue_stub; | |
108 context->code[C_isEmptySingleLinkedQueue] = isEmptySingleLinkedQueue_stub; | |
109 | |
86 | 110 /* context->code[Delete] = delete_stub; */ |
111 /* context->code[Delete1] = delete1_stub; */ | |
112 /* context->code[Delete2] = delete2_stub; */ | |
113 /* context->code[Delete3] = delete3_stub; */ | |
114 /* context->code[Replace_d1] = replaceNodeForDelete1_stub; */ | |
115 /* context->code[Replace_d2] = replaceNodeForDelete2_stub; */ | |
116 /* context->code[FindMax1] = findMax1_stub; */ | |
117 /* context->code[FindMax2] = findMax2_stub; */ | |
118 /* context->code[DeleteCase1] = deleteCase1_stub; */ | |
119 /* context->code[DeleteCase2] = deleteCase2_stub; */ | |
120 /* context->code[DeleteCase3] = deleteCase3_stub; */ | |
121 /* context->code[DeleteCase4] = deleteCase4_stub; */ | |
122 /* context->code[DeleteCase5] = deleteCase5_stub; */ | |
123 /* context->code[DeleteCase6] = deleteCase6_stub; */ | |
124 context->code[CreateWorker] = createWorker_stub; | |
125 context->code[TaskManager] = taskManager_stub; | |
90 | 126 context->code[CreateData1] = createData1_stub; |
127 context->code[CreateData2] = createData2_stub; | |
128 context->code[CreateTask1] = createTask1_stub; | |
129 context->code[CreateTask2] = createTask2_stub; | |
112 | 130 context->code[CreateTask3] = createTask3_stub; |
131 context->code[CreateTask4] = createTask4_stub; | |
90 | 132 context->code[PutQueue1] = putQueue1_stub; |
133 context->code[PutQueue2] = putQueue2_stub; | |
134 context->code[PutQueue3] = putQueue3_stub; | |
135 context->code[PutQueue4] = putQueue4_stub; | |
91 | 136 context->code[GetQueue] = getQueue_stub; |
112 | 137 context->code[SpawnTask] = spawnTask_stub; |
92 | 138 context->code[Twice] = twice_stub; |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
139 context->code[StartTime] = start_time_stub; |
112 | 140 context->code[EndTime] = end_time_stub; |
141 context->code[Exit] = exit_code; | |
86 | 142 |
101 | 143 struct Worker* worker = ALLOC_DATA(context, Worker); |
87 | 144 worker->num = 0; |
145 worker->contexts = 0; | |
146 | |
101 | 147 struct Allocate* allocate = ALLOC_DATA(context, Allocate); |
87 | 148 allocate->size = 0; |
149 | |
131
a4507906938c
Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
150 |
132 | 151 ALLOC_DATA(context, Stack); |
130 | 152 |
101 | 153 struct Tree* tree = ALLOC_DATA(context, Tree); |
86 | 154 tree->root = 0; |
87 | 155 |
124 | 156 struct Traverse* traverse = ALLOC_DATA(context, Traverse); |
132 | 157 traverse->nodeStack = &createSingleLinkedStack(context)->stack; |
101 | 158 |
147 | 159 ALLOC_DATA(context, RotateTree); |
160 | |
101 | 161 struct Node* node = ALLOC_DATA(context, Node); |
87 | 162 node->key = 0; |
163 node->value = 0; | |
164 node->left = 0; | |
165 node->right = 0; | |
101 | 166 |
167 struct LoopCounter* counter = ALLOC_DATA(context, LoopCounter); | |
86 | 168 counter->i = 0; |
87 | 169 |
101 | 170 struct Element* element = ALLOC_DATA(context, Element); |
113
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
171 element->data = 0; |
90 | 172 element->next = 0; |
173 | |
101 | 174 ALLOC_DATA(context, Time); |
175 | |
176 struct Queue* activeQueue = ALLOC_DATA_TYPE(context, ActiveQueue, Queue); | |
90 | 177 activeQueue->first = 0; |
178 activeQueue->last = 0; | |
179 activeQueue->count = 0; | |
101 | 180 |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
181 struct Queue* waitQueue = ALLOC_DATA_TYPE(context, WaitQueue, Queue); |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
182 waitQueue->first = 0; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
183 waitQueue->last = 0; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
184 waitQueue->count = 0; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
185 |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
147
diff
changeset
|
186 context->dataNum = D_Queue; |
86 | 187 } |