-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPVM.h
More file actions
145 lines (145 loc) · 3.2 KB
/
PVM.h
File metadata and controls
145 lines (145 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef PVM_H
#define PVM_H
/**
* This is the header of Process VM
* it describes the organization of the main body.
* structures and utility functions.
**/
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <GL/glut.h>
#include "PCore.h"
#include "PFile.h"
#include "PVMAPILib.h"
//<<<<<<< Updated upstream
#define NUM_E_THREAD 4
//#define M_WAITING_LIST_SIZE 256
//#define NUM_E_THREAD 2
//#define M_WAITING_LIST_SIZE 256
//>>>>>>> Stashed changes
#define INITIAL_PERFORMANCE_VAL 8
#define INITIAL_DELAY_VAL 2000
#define MAX_PERFORMANCE_VAL 32000
#define MAX_DELAY_VAL 500000
#define PRINTADDR(x) printf("ADDR:%lx\n",(long)(x))
#define SEEK_TABLE(x,y,a) ((x)+(y)*(a))
//graph global
#define GRAPH_WINDOW_L 600
#define GRAPH_WINDOW_H 400
#define GRAPH_SLEEPING_TIME 50000
/** MACRO Section **/
//the number of execution threads, it mainly depends on the hardware
//#define TN_EXE 3//my computer has 8 logical core, extended by the technology known as intel's hyper threading.
typedef struct instanceMountingLinkList
{
PBase *instance;
struct instanceMountingLinkList *next;
}IMLList;
typedef struct instanceMountingElement
{
int INumber;
IMLList *start;
IMLList *list;
}IME;
typedef struct waitLinkList
{
PBase *pid;
struct waitLinkList *next;
}waitL;
typedef struct MutexStructure
{
unsigned long size;
void* lock;//can be used to the id of threads
void* content;
waitL *waitList;
}mutex;
typedef struct haltInformations
{
PBase *pid;
int val;
}hInfo;
#define MTX_HDL_TYP_WAIT 0
#define MTX_HDL_TYP_TEST 1
#define MTX_HDL_TYP_LEAVE 2
//#define TRIGGER 3
typedef struct mutexHandlerWaitingQueue
{
PBase *pid;
int opTyp;
mutex *mTarget;
}MHQ;
typedef struct triggerListElement
{
int number;
int *list;
}tgr;
typedef struct graphInstancePosition
{
float x;
float y;
}gPos;
/** Global Section **/
//necassary sole data
PExe *VMpe;
//Lists & boundary
int listCodeSize;
void* *listCode;
int listMutexSize;
mutex *listMutex;
int listInstanceSize;
PBase *listInstance;
//halt
hInfo haltInfo;
//mutex handler global
pthread_mutex_t rtLock;
pthread_mutex_t rtExecLock;
pthread_mutex_t triggerLock;
//pthread_mutex_t qLock;
pthread_mutex_t haltExecLock;
//int queueH,queueT;
//MHQ waitingQueue[M_WAITING_LIST_SIZE];
MHQ mutexHandlerArg;
//thread pool
pthread_t haltT;
//pthread_t constraintHandler;
pthread_t mutexT;
pthread_t executionThread[NUM_E_THREAD];
pthread_t graphT;
IME executionGroup[NUM_E_THREAD];
//global variables
tgr *triggerList;
/** Error Handle Val **/
int errno;
/** graph global section **/
gPos *gpp;
float graph_size;
//Statistic Data
/** utility functions **/
/** mutex **/
//void mutexTinit();
void *mutexHandler();
/** Functions **/
void VMReadFile(char *file);
void debugVM(PBase *p,int howManyStack0Elem);
void debugPrintConstraint();
void debugPrintMountingList();
void *execDebug_old(void* no);
void *execNormal();
void dispatcher();
void VMStartUp();
void VMStartUp_step();
void VMStartUp_debug();
void *VMHalt();
void graphStartUp(int* argv,char **argc);
void graphShape();
void graphDrawInstance(int id);
void graphDisp();
void *graphMonitor();
void handlerSegFault(int);
void releaseMemory();
void debugPrintWaitingList();
#endif