-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPCB.java
More file actions
114 lines (95 loc) · 1.96 KB
/
PCB.java
File metadata and controls
114 lines (95 loc) · 1.96 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
/** -----------------------------------------------------------------------
PCB.java
@author William Clift
Operating Systems
Ursinus College
Project 2 - Scheduling Schemes
14 April 2020
Compile Instructions:
Compile: javac PCB.java
------------------------------------------------------------------- **/
public class PCB{
public int pid, arrival_time, burst_time, time_remaining;
private PCB next;
private int wait_time;
private int response_time;
private int turnaround_time;
/**
* Process Control Block Constructor
* No parameterrs
*/
public PCB(){
}
/**
* Process Control Block Constructor with parameters
* @param pid
* @param arrival_time
* @param burst_time
*/
public PCB(int pid, int arrival_time, int burst_time){
this.pid = pid;
this.arrival_time = arrival_time;
this.burst_time = burst_time;
this.time_remaining = burst_time;
this.next = null;
this.wait_time = 0;
}
/**
* @return the PCB it points to
*/
public PCB getNext(){
return this.next;
}
/**
* @return the pid
*/
public int getPid(){
return this.pid;
}
/**
* Set the next Node of the Circular Linked List
* @param n
*/
public void setNext(PCB n){
this.next = n;
}
/**
* Adds to the wait time for a process
*/
public void waitTick(){
this.wait_time++;
if(time_remaining == burst_time){
this.response_time++;
}
}
/**
* @return this.wait_time
*/
public int getWaitTime(){
return this.wait_time;
}
/**
* @return this.response_time
*/
public int getResponseTime(){
return this.response_time;
}
/**
* @param cpuTime
*/
public void setResponseTime(int cpuTime){
this.response_time = cpuTime - this.arrival_time;
}
/**
* @return this.turnaround_time
*/
public int getTurnaroundTime(){
return this.wait_time + this.burst_time;
}
/**
* @param cpuTime
*/
public void setTurnaroundTime(int cpuTime){
this.turnaround_time = cpuTime - arrival_time;
}
}