diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tmp/context.h	Mon Jan 18 17:50:52 2016 +0900
@@ -0,0 +1,124 @@
+/* Context definition for llrb example */
+#include <pthread.h>
+#include "stack.h"
+
+#define ALLOCATE_SIZE 1000
+
+enum Code {
+    Code1,
+    Code2,
+    Code3,
+    Code4,
+    Code5,
+    Find,
+    Not_find,
+    Code6,
+    Allocator,
+    Put,
+    Replace,
+    Insert,
+    Compare,
+    RotateL,
+    RotateR,
+    SetTree,
+    InsertCase1,
+    InsertCase2,
+    InsertCase3,
+    InsertCase4,
+    InsertCase4_1,
+    InsertCase4_2,
+    InsertCase5,
+    StackClear,
+    Get,
+    Search,
+    Delete,
+    Delete1,
+    Delete2,
+    Delete3,
+    Replace_d1,
+    Replace_d2,
+    FindMax1,
+    FindMax2,
+    DeleteCase1,
+    DeleteCase2,
+    DeleteCase3,
+    DeleteCase4,
+    DeleteCase5,
+    DeleteCase6,
+    CreateWorker,
+    TaskManager,
+    Exit,
+};
+
+enum Relational {
+    EQ,
+    GT,
+    LT,
+};
+
+enum UniqueData {
+    Worker,
+    Allocate,
+    Tree,
+    Node,
+    LoopCounter,
+};
+
+struct Context {
+    enum Code next;
+    int codeNum;
+    __code (**code) (struct Context*);
+    void* heapStart;
+    void* heap;
+    long heapLimit;
+    pthread_t thread;
+    int dataNum;
+    stack_ptr code_stack;
+    stack_ptr node_stack;
+    union Data **data;
+};
+
+union Data {
+    struct LoopCounter {
+        int i;
+    } loopCounter;
+    struct Worker {
+        //enum DataType type;
+        int num;
+        struct Context* contexts;
+    } worker;
+    struct Array {
+        //enum DataType type;
+        int size;
+        int* array;
+    } array;
+    struct Spots {
+        //enum DataType type;
+        int x;
+        int y;
+    } spot;
+    struct Tree {
+        enum Code next;
+        struct Node* root;
+        struct Node* current;
+        struct Node* deleted;
+        int result;
+    } tree;
+    struct Node {
+        // need to tree
+        enum Code next;
+        int key; // comparable data segment
+        int value;
+        struct Node* left;
+        struct Node* right;
+        // need to balancing
+        enum Color {
+            Red,
+            Black,
+        } color;
+    } node;
+    struct Allocate {
+        enum Code next;
+        long size;
+    } allocate;
+};