reorganize multicore version runtime codes for easy support of new platforms
[IRC.git] / Robust / src / Runtime / ThreadSim / runtime_arch.h
1 #ifndef RUNTIME_ARCH
2 #define RUNTIME_ARCH
3
4 #include "structdefs.h"
5 #include "mem.h"
6 #include "checkpoint.h"
7 #include "Queue.h"
8 #include "SimpleHash.h"
9 #include "GenericHashtable.h"
10 #include <sys/select.h>
11 #include <sys/types.h>
12 #include <sys/mman.h>
13 #include <string.h>
14 #include <signal.h>
15 #include <assert.h>
16 #include <errno.h>
17 // use POSIX message queue
18 // for each core, its message queue named as
19 // /msgqueue_corenum
20 #include <mqueue.h>
21 #include <sys/stat.h>
22
23 static struct RuntimeHash* locktbl;
24 struct thread_data {
25   int corenum;
26   int argc;
27   char** argv;
28   int numsendobjs;
29   int numreceiveobjs;
30 };
31 struct thread_data thread_data_array[NUMCORES];
32 mqd_t mqd[NUMCORES];
33 static pthread_key_t key;
34 static pthread_rwlock_t rwlock_tbl;
35 static pthread_rwlock_t rwlock_init;
36
37 #define BAMBOO_NUM_OF_CORE (pthread_getspecific(key))
38 #define BAMBOO_GET_NUM_OF_CORE() (pthread_getspecific(key))
39
40 /* This function updates the flag for object ptr.  It or's the flag
41    with the or mask and and's it with the andmask. */
42
43 void flagbody(struct ___Object___ *ptr, int flag, struct parameterwrapper ** queues, int length, bool isnew);
44
45 void run(void * arg);
46
47 #endif // #ifndef RUNTIME_ARCH