-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO.java
More file actions
57 lines (39 loc) · 879 Bytes
/
IO.java
File metadata and controls
57 lines (39 loc) · 879 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
55
56
57
public class IO implements Runnable{
OperatingSys OS;
public IO(OperatingSys OS){
this.OS = OS;
}
@Override
public void run() {
ProcessControlBlock process = null;
while(OS.IOq.isEmpty()){
try{
Thread.sleep(1);
}catch (InterruptedException e){
e.printStackTrace();
}
}
while(true){
if(!OS.IOq.isEmpty()){
synchronized (OS.IOq){
process = OS.IOq.remove(0);
}
process.tATime += process.IOBurst.get(0);
process.ioTime += process.IOBurst.get(0);
synchronized(OS.IOq){
for(ProcessControlBlock buf: OS.IOq){
buf.wTime += process.IOBurst.get(0);
buf.tATime += process.IOBurst.get(0);
}
}
process.IOBurst.remove(0);
synchronized(OS.CPUq){
OS.CPUq.add(process);
}
}
if (OS.done.size() == OS.total){
break;
}
}
}
}