-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCB.java
43 lines (37 loc) · 1.14 KB
/
PCB.java
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
public class PCB {
public int id;
public int priority;
public int cpuBurst;
public int arrivalTime;
public int startTime;
public int terminateTime;
public int waittingTime;
public int remaining;
public PCB(int id, int priority, int arrivalTime, int cpuBurstTime) {
this.id = id;
this.priority = priority;
this.arrivalTime = arrivalTime;
this.cpuBurst = cpuBurstTime;
this.startTime = 0;
this.terminateTime = 0;
this.waittingTime = 0;
this.remaining = cpuBurstTime;
}
public int getTurnAround() {
return waittingTime + cpuBurst;
}
public int getResponseTime() {
return startTime - arrivalTime;
}
public String toString() {
return "Process ID: PN" + id +
"\n Priority: " + priority +
"\n CPU burst: " + cpuBurst +
"\n Arrival Time: " + arrivalTime +
"\n Start Time: " + startTime +
"\n Termination Time: " + terminateTime +
"\n Turn around Time: " + getTurnAround() +
"\n Waiting Time: " + waittingTime +
"\n Response Time: " + getResponseTime();
}
}