-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
100 lines (92 loc) · 3.15 KB
/
Main.java
File metadata and controls
100 lines (92 loc) · 3.15 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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
public class Main {
//static int num_res = 3;
public static void main(String[] args) {
// TODO Auto-generated method stub
int sim_stop_time = 0;
int num_tasks = 0;
int j = 1;
int k = 1;
try{
URL path = ClassLoader.getSystemResource("Trace1.txt"); //---------->Input file
if(path==null) {
System.out.println("Specified input file cannot be found");
}
File f = new File(path.toURI());
String thisLine = null;
BufferedReader br = null;
ArrayList<Task> al = new ArrayList<Task>();
try {
br = new BufferedReader(new FileReader(f)); //------------->Parsing the input file
sim_stop_time = Integer.parseInt(br.readLine());
num_tasks = Integer.parseInt(br.readLine());
System.out.println("Simulation stop time:" + sim_stop_time);
System.out.println("Number of tasks:" + num_tasks);
System.out
.println("/***************************Input****************************/");
while ((thisLine = br.readLine()) != null) {
System.out.println(thisLine);
String[] sArray = thisLine.trim().split("\\s+|\t");
j = 1;
try{
PeriodicTask pt = new PeriodicTask(sArray[0], //---------->Initializing periodic tasks and resources
Integer.parseInt(sArray[1]),
Integer.parseInt(sArray[2]),
Integer.parseInt(sArray[3]),
Integer.parseInt(sArray[4]),
Integer.parseInt(sArray[5]), k);
ArrayList<Resource> rl = new ArrayList<Resource>();
for (int i = 0; i < Integer.parseInt(sArray[5]); i++) {
String in = "R" + (i+1);
//System.out.println(in);
if(!(sArray[6+i+j-1].equals(in)))
{
for(int z = 0; z < (Integer.parseInt(sArray[6].substring(1))-1);z++)
{
Resource r = new Resource("0",0,0);
rl.add(r);
}
Resource r1 = new Resource(sArray[5 + i + j],
Integer.parseInt(sArray[5 + i + j + 1]),
Integer.parseInt(sArray[5 + i + j + 2]));
rl.add(r1);
}
else
{
Resource r1 = new Resource(sArray[5 + i + j],
Integer.parseInt(sArray[5 + i + j + 1]),
Integer.parseInt(sArray[5 + i + j + 2]));
rl.add(r1);
}
j = j + 2;
}
Task t = new Task(pt, rl);
// System.out.println(t.p.order + " " + t.p);
al.add(t);
k++;
}catch(Exception e)
{
System.out.println("^Invalid input task");
continue;
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println();
System.out
.println("/************************** Output **************************/");
Scheduler sch = new Scheduler(al, sim_stop_time, num_tasks);
sch.EDF_Scheduler(); //---------------->Invoking the scheduler
System.out.println("/*************************** End of execution **************************/");
}catch(URISyntaxException e)
{
System.out.println("Specified input file cannot be found");
}
}
}