changes
[IRC.git] / Robust / src / Runtime / bamboo / multicoretask.h
1 #ifndef BAMBOO_MULTICORE_TASK_H
2 #define BAMBOO_MULTICORE_TASK_H
3 #ifdef TASK
4 #include "multicore.h"
5 // TASK specific data structures
6 // get rid of lock msgs for GC version
7 #ifndef MULTICORE_GC
8 // data structures for locking
9 struct RuntimeHash locktable;
10 static struct RuntimeHash* locktbl = &locktable;
11 struct RuntimeHash * lockRedirectTbl;
12 struct RuntimeHash * objRedirectLockTbl;
13 #endif // ifndef MULTICORE_GC
14 struct LockValue {
15   int redirectlock;
16   int value;
17 };
18 int lockobj;
19 int lock2require;
20 int lockresult;
21 bool lockflag;
22
23 // data structures for waiting objs
24 struct Queue objqueue;
25 struct Queue * totransobjqueue; // queue to hold objs to be transferred
26                                 // should be cleared whenever enter a task
27                                         
28 // for test TODO
29 int total_num_t6;
30
31 // lock related functions
32 bool getreadlock(void* ptr);
33 void releasereadlock(void* ptr);
34 bool getwritelock(void* ptr);
35 void releasewritelock(void* ptr);
36 bool getwritelock_I(void* ptr);
37 void releasewritelock_I(void * ptr);
38 #ifndef MULTICORE_GC
39 void releasewritelock_r(void * lock, void * redirectlock);
40 #endif // ifndef MULTICORE_GC
41 /* this function is to process lock requests.
42  * can only be invoked in receiveObject_I() */
43 // if return -1: the lock request is redirected
44 //            0: the lock request is approved
45 //            1: the lock request is denied
46 int processlockrequest_I(int locktype,int lock,int obj,int requestcore,int rootrequestcore,bool cache);
47 void processlockrelease_I(int locktype,int lock,int redirectlock,bool redirect);
48
49 void inittaskdata();
50 void distaskdata();
51
52 #define INITTASKDATA() inittaskdata()
53 #define DISTASKDATA() distaskdata()
54 #else // TASK
55 #define INITTASKDATA()
56 #define DISTASKDATA()
57 #endif // TASK
58 #endif // BAMBOO_MULTICORE_TASK_H