-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessControlBlock.java
More file actions
57 lines (50 loc) · 1.3 KB
/
ProcessControlBlock.java
File metadata and controls
57 lines (50 loc) · 1.3 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
import java.util.Random;
public class ProcessControlBlock {
Random r = new Random();
private SimProcess simProcess;
private int R1 = r.nextInt();
private int R2 = r.nextInt();
private int R3 = r.nextInt();
private int R4 = r.nextInt();
private int currInstruction = 0;
public ProcessControlBlock(SimProcess simProcess) {
this.simProcess = simProcess;
}
public SimProcess getSimProcess() {
return simProcess;
}
public void setCurrInstruction(int currInstruction) {
this.currInstruction = currInstruction;
}
public int getCurrInstruction() {
return currInstruction;
}
public void setRegisterValue(int register, int value) {
if (register == 1) {
R1 = value;
}
if (register == 2) {
R2 = value;
}
if (register == 3) {
R3 = value;
}
if (register == 4) {
R4 = value;
}
}
public int getRegisterValues(int register) {
if (register == 1) {
return R1;
}
if (register == 2) {
return R2;
}
if (register == 3) {
return R3;
}
else {
return R4;
}
}
}