comparison Paper/src/context.h @ 1:a72446879486

Init paper
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Thu, 12 Jan 2023 20:28:50 +0900 (2023-01-12)
parents
children
comparison
equal deleted inserted replaced
0:8df537cb6a18 1:a72446879486
1 /* define context */
2
3 #define ALLOCATE_SIZE 20000000
4 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
5 #define ALLOC_DATA(context, dseg) ({ context->data[dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[dseg]; })
6
7 enum Code {
8 Code1,
9 Code2,
10 Code3,
11 };
12
13 enum UniqueData {
14 Allocate,
15 Tree,
16 Queue,
17 Worker,
18 };
19
20 struct Context {
21 enum Code next;
22 int codeNum;
23 __code (**code) (struct Context*);
24 void* heapStart;
25 void* heap;
26 long heapLimit;
27 pthread_t thread;
28 int thread_num;
29 int dataNum;
30 union Data **data;
31 };
32
33 union Data {
34 struct Worker {
35 int num;
36 struct Context* contexts;
37 } worker;
38 struct Tree {
39 struct Node* root;
40 } tree;
41 struct Node {
42 // need to tree
43 enum Code next;
44 int key; // comparable data segment
45 union Data* value;
46 struct Node* left;
47 struct Node* right;
48 // need to balancing
49 enum Color {
50 Red,
51 Black,
52 } color;
53 } node;
54 struct Allocate {
55 enum Code next;
56 long size;
57 } allocate;
58 };