Mercurial > hg > Members > Moririn
comparison src/parallel_execution/context.c @ 87:9e139a340bd1 parallel_execution
rename directory
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 19 Jan 2016 16:16:26 +0900 |
parents | src/tmp/context.c@e06e1a9e569e |
children | 4b5bf5b40970 |
comparison
equal
deleted
inserted
replaced
86:e06e1a9e569e | 87:9e139a340bd1 |
---|---|
1 #include <stdlib.h> | |
2 | |
3 #include "context.h" | |
4 | |
5 extern __code code1_stub(struct Context*); | |
6 extern __code code2_stub(struct Context*); | |
7 extern __code code3_stub(struct Context*); | |
8 extern __code code4(struct Context*); | |
9 extern __code code5(struct Context*); | |
10 extern __code find(struct Context*); | |
11 extern __code not_find(struct Context*); | |
12 extern __code code6(struct Context*); | |
13 extern __code meta(struct Context*); | |
14 extern __code put_stub(struct Context*); | |
15 extern __code replaceNode_stub(struct Context*); | |
16 extern __code insertNode_stub(struct Context*); | |
17 extern __code rotateLeft_stub(struct Context*); | |
18 extern __code rotateRight_stub(struct Context*); | |
19 extern __code colorFlip_stub(struct Context*); | |
20 extern __code fixUp_stub(struct Context*); | |
21 extern __code changeReference_stub(struct Context*); | |
22 extern __code insert1_stub(struct Context*); | |
23 extern __code insert2_stub(struct Context*); | |
24 extern __code insert3_stub(struct Context*); | |
25 extern __code insert4_stub(struct Context*); | |
26 extern __code insert4_1_stub(struct Context*); | |
27 extern __code insert4_2_stub(struct Context*); | |
28 extern __code insert5_stub(struct Context*); | |
29 extern __code stackClear_stub(struct Context*); | |
30 extern __code get_stub(struct Context*); | |
31 extern __code search_stub(struct Context*); | |
32 extern __code delete_stub(struct Context*); | |
33 extern __code delete1_stub(struct Context*); | |
34 extern __code delete2_stub(struct Context*); | |
35 extern __code delete3_stub(struct Context*); | |
36 extern __code replaceNodeForDelete1_stub(struct Context*); | |
37 extern __code replaceNodeForDelete2_stub(struct Context*); | |
38 extern __code findMax1_stub(struct Context*); | |
39 extern __code findMax2_stub(struct Context*); | |
40 extern __code deleteCase1_stub(struct Context*); | |
41 extern __code deleteCase2_stub(struct Context*); | |
42 extern __code deleteCase3_stub(struct Context*); | |
43 extern __code deleteCase4_stub(struct Context*); | |
44 extern __code deleteCase5_stub(struct Context*); | |
45 extern __code deleteCase6_stub(struct Context*); | |
46 extern __code createWorker_stub(struct Context*); | |
47 extern __code taskManager_stub(struct Context*); | |
48 extern __code exit_code(struct Context*); | |
49 | |
50 __code initContext(struct Context* context) { | |
51 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; | |
52 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); | |
53 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); | |
54 context->heapStart = malloc(context->heapLimit); | |
55 | |
56 context->codeNum = Exit; | |
57 | |
58 context->code[Code1] = code1_stub; | |
59 //context->code[Code2] = code2_stub; | |
60 /* context->code[Code3] = code3_stub; */ | |
61 /* context->code[Code4] = code4; */ | |
62 /* context->code[Code5] = code5; */ | |
63 /* context->code[Find] = find; */ | |
64 /* context->code[Not_find] = not_find; */ | |
65 /* context->code[Code6] = code6; */ | |
66 context->code[Put] = put_stub; | |
67 context->code[Replace] = replaceNode_stub; | |
68 context->code[Insert] = insertNode_stub; | |
69 context->code[RotateL] = rotateLeft_stub; | |
70 context->code[RotateR] = rotateRight_stub; | |
71 context->code[InsertCase1] = insert1_stub; | |
72 context->code[InsertCase2] = insert2_stub; | |
73 context->code[InsertCase3] = insert3_stub; | |
74 context->code[InsertCase4] = insert4_stub; | |
75 context->code[InsertCase4_1] = insert4_1_stub; | |
76 context->code[InsertCase4_2] = insert4_2_stub; | |
77 context->code[InsertCase5] = insert5_stub; | |
78 context->code[StackClear] = stackClear_stub; | |
79 /* context->code[Get] = get_stub; */ | |
80 /* context->code[Search] = search_stub; */ | |
81 /* context->code[Delete] = delete_stub; */ | |
82 /* context->code[Delete1] = delete1_stub; */ | |
83 /* context->code[Delete2] = delete2_stub; */ | |
84 /* context->code[Delete3] = delete3_stub; */ | |
85 /* context->code[Replace_d1] = replaceNodeForDelete1_stub; */ | |
86 /* context->code[Replace_d2] = replaceNodeForDelete2_stub; */ | |
87 /* context->code[FindMax1] = findMax1_stub; */ | |
88 /* context->code[FindMax2] = findMax2_stub; */ | |
89 /* context->code[DeleteCase1] = deleteCase1_stub; */ | |
90 /* context->code[DeleteCase2] = deleteCase2_stub; */ | |
91 /* context->code[DeleteCase3] = deleteCase3_stub; */ | |
92 /* context->code[DeleteCase4] = deleteCase4_stub; */ | |
93 /* context->code[DeleteCase5] = deleteCase5_stub; */ | |
94 /* context->code[DeleteCase6] = deleteCase6_stub; */ | |
95 context->code[CreateWorker] = createWorker_stub; | |
96 context->code[TaskManager] = taskManager_stub; | |
97 context->code[Exit] = exit_code; | |
98 | |
99 context->heap = context->heapStart; | |
100 | |
101 context->data[Worker] = context->heap; | |
102 context->heap += sizeof(struct Worker); | |
103 | |
104 context->data[Allocate] = context->heap; | |
105 context->heap += sizeof(struct Allocate); | |
106 | |
107 context->data[Tree] = context->heap; | |
108 context->heap += sizeof(struct Tree); | |
109 | |
110 context->data[Node] = context->heap; | |
111 context->heap += sizeof(struct Node); | |
112 | |
113 context->data[LoopCounter] = context->heap; | |
114 context->heap += sizeof(struct LoopCounter); | |
115 | |
116 context->data[WaitQueue] = context->heap; | |
117 context->heap += sizeof(struct Queue); | |
118 | |
119 context->data[ActiveQueue] = context->heap; | |
120 context->heap += sizeof(struct Queue); | |
121 | |
122 context->dataNum = ActiveQueue; | |
123 | |
124 struct Worker* worker = &context->data[Worker]->worker; | |
125 worker->num = 0; | |
126 worker->contexts = 0; | |
127 | |
128 struct Allocate* allocate = &contexts->data[Allocate]->allocate; | |
129 allocate->size = 0; | |
130 | |
131 struct Tree* tree = &context->data[Tree]->tree; | |
132 tree->root = 0; | |
133 tree->current = 0; | |
134 | |
135 struct Node* node = &context->data[Node]->node; | |
136 node->key = 0; | |
137 node->value = 0; | |
138 node->left = 0; | |
139 node->right = 0; | |
140 | |
141 struct LoopCounter* counter = &context->data[LoopCounter]->loopCounter; | |
142 counter->i = 0; | |
143 | |
144 struct Queue* waitQueue = &context->data[WaitQueue]->queue; | |
145 waitQueue->first = 0; | |
146 waitQueue->last = 0; | |
147 waitQueue->count = 0; | |
148 | |
149 context->node_stack = stack_init(sizeof(struct Node*), 100); | |
150 context->code_stack = stack_init(sizeof(enum Code), 100); | |
151 } |