comparison src/tmp/context.h @ 86:e06e1a9e569e parallel_execution

create worker
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Mon, 18 Jan 2016 17:50:52 +0900
parents
children
comparison
equal deleted inserted replaced
83:c13575c3dbe9 86:e06e1a9e569e
1 /* Context definition for llrb example */
2 #include <pthread.h>
3 #include "stack.h"
4
5 #define ALLOCATE_SIZE 1000
6
7 enum Code {
8 Code1,
9 Code2,
10 Code3,
11 Code4,
12 Code5,
13 Find,
14 Not_find,
15 Code6,
16 Allocator,
17 Put,
18 Replace,
19 Insert,
20 Compare,
21 RotateL,
22 RotateR,
23 SetTree,
24 InsertCase1,
25 InsertCase2,
26 InsertCase3,
27 InsertCase4,
28 InsertCase4_1,
29 InsertCase4_2,
30 InsertCase5,
31 StackClear,
32 Get,
33 Search,
34 Delete,
35 Delete1,
36 Delete2,
37 Delete3,
38 Replace_d1,
39 Replace_d2,
40 FindMax1,
41 FindMax2,
42 DeleteCase1,
43 DeleteCase2,
44 DeleteCase3,
45 DeleteCase4,
46 DeleteCase5,
47 DeleteCase6,
48 CreateWorker,
49 TaskManager,
50 Exit,
51 };
52
53 enum Relational {
54 EQ,
55 GT,
56 LT,
57 };
58
59 enum UniqueData {
60 Worker,
61 Allocate,
62 Tree,
63 Node,
64 LoopCounter,
65 };
66
67 struct Context {
68 enum Code next;
69 int codeNum;
70 __code (**code) (struct Context*);
71 void* heapStart;
72 void* heap;
73 long heapLimit;
74 pthread_t thread;
75 int dataNum;
76 stack_ptr code_stack;
77 stack_ptr node_stack;
78 union Data **data;
79 };
80
81 union Data {
82 struct LoopCounter {
83 int i;
84 } loopCounter;
85 struct Worker {
86 //enum DataType type;
87 int num;
88 struct Context* contexts;
89 } worker;
90 struct Array {
91 //enum DataType type;
92 int size;
93 int* array;
94 } array;
95 struct Spots {
96 //enum DataType type;
97 int x;
98 int y;
99 } spot;
100 struct Tree {
101 enum Code next;
102 struct Node* root;
103 struct Node* current;
104 struct Node* deleted;
105 int result;
106 } tree;
107 struct Node {
108 // need to tree
109 enum Code next;
110 int key; // comparable data segment
111 int value;
112 struct Node* left;
113 struct Node* right;
114 // need to balancing
115 enum Color {
116 Red,
117 Black,
118 } color;
119 } node;
120 struct Allocate {
121 enum Code next;
122 long size;
123 } allocate;
124 };