-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.java
More file actions
54 lines (45 loc) · 844 Bytes
/
Copy pathProcess.java
File metadata and controls
54 lines (45 loc) · 844 Bytes
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
//Process
import java.util.Comparator;
public class Process {
String name;
int BT,WT,AT,CT,TAT,remBT,priority;
boolean flag;
public Process(String name,int burst,int AT)
{
this.name=name;
BT=burst;
this.AT=AT;
WT=CT=TAT=0;
remBT=BT;
priority=0;
}
public Process(String name,int burst,int AT,int PR)
{
this.name=name;
BT=burst;
this.AT=AT;
WT=CT=TAT=0;
remBT=BT;
priority=PR;
flag=false;
}
public void display()
{
System.out.println(name+"\t"+BT+"\t"+AT+"\t"+CT+"\t"+TAT+"\t"+WT+"\t"+priority);
}
}
//Class for sorting Processes
class SortByArrival implements Comparator<Process>
{
@Override
public int compare(Process p1, Process p2) {
return p1.AT-p2.AT;
}
}
class SortByPriority implements Comparator<Process>
{
@Override
public int compare(Process o1, Process o2) {
return o1.priority-o2.priority;
}
}