-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPVMmain.c
93 lines (93 loc) · 1.71 KB
/
PVMmain.c
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
#include <stdio.h>
#include "PVM.h"
#define EN_STEP 's'
#define EN_DEBUG 'd'
#define EN_GRAPH 'g'
char flag_graph;
char flag_step;
char flag_debug;
void flag_init();
int main(int argc,char **argv)
{
int a0;
signal(SIGSEGV,handlerSegFault);
if(argc==1)
{
printf("PVM Warning: No input file.\n");
return -1;
}
flag_init();
//read argv
for(a0=2;a0<argc;a0++)
{
//the configuration section
if(argv[a0][0] == '-')
{
switch(argv[a0][1])
{
case EN_GRAPH:flag_graph=1;break;
case EN_DEBUG:flag_debug=1;break;
case EN_STEP:flag_step=1;break;
default:
printf("Error : unknown argument.\n");
return -1;
}
}
else
{
printf("Error : Bad argument at %d\n",a0-1);
return -1;
}
}
//check confliction
if(flag_step && flag_debug)
{
printf("runtime mode conflict.\n");
return -1;
}
printf("Reading %s\n",*(argv+1));
VMReadFile(*(argv+1));
//checkStructure(VMpe);
clearFile(VMpe,CODE_RESERVED);
printf("execution file loaded.\n");
debugPrintConstraint();
dispatcher();
debugPrintMountingList();
printf("dispatching finished\n");
//mutexTinit();
printf("mutex finished\n");
/*conf start*/
//make graph
//graphStartUp(&argc,argv);
//pthread_create(&graphT,NULL,graphMonitor,NULL);
if(flag_graph==1)
{
graphStartUp(&argc,argv);
pthread_create(&graphT,NULL,graphMonitor,NULL);
}
//mode selection
if(flag_step)
{
//step
VMStartUp_step();
}
else if(flag_debug)
{
//show debug info
VMStartUp_debug();
}
else
{
//normal
VMStartUp();
}
/*conf finished*/
return 0;
}
void flag_init()
{
//
flag_graph=0;
flag_step=0;
flag_debug=0;
}