diff paper/src/context.h @ 1:19917a6272f6

sigos_test
author suruga
date Thu, 20 Apr 2017 16:29:05 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/context.h	Thu Apr 20 16:29:05 2017 +0900
@@ -0,0 +1,58 @@
+/* define context */
+
+#define ALLOCATE_SIZE 20000000
+#define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
+#define ALLOC_DATA(context, dseg) ({ context->data[dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[dseg]; })
+
+enum Code {
+    Code1,
+    Code2,
+    Code3,
+};
+
+enum UniqueData {
+    Allocate,
+    Tree,
+    Queue,
+    Worker,
+};
+
+struct Context {
+    enum Code next;
+    int codeNum;
+    __code (**code) (struct Context*);
+    void* heapStart;
+    void* heap;
+    long heapLimit;
+    pthread_t thread;
+    int thread_num;
+    int dataNum;
+    union Data **data;
+};
+
+union Data {
+    struct Worker {
+        int num;
+        struct Context* contexts;
+    } worker;
+    struct Tree {
+        struct Node* root;
+    } tree;
+    struct Node {
+        // need to tree
+        enum Code next;
+        int key; // comparable data segment
+        union Data* value;
+        struct Node* left;
+        struct Node* right;
+        // need to balancing
+        enum Color {
+            Red,
+            Black,
+        } color;
+    } node;
+    struct Allocate {
+        enum Code next;
+        long size;
+    } allocate;
+};