-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReady.java
More file actions
47 lines (43 loc) · 1.04 KB
/
Ready.java
File metadata and controls
47 lines (43 loc) · 1.04 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
import java.util.Queue;
import java.util.LinkedList;
public class Ready {
static Queue <Process> ReadyProcs = new LinkedList<Process>();
static Process running;
static void enqueue(Process proc)
{
proc.state=3;
ReadyProcs.add(proc);
CpuSpec spec_head = (CpuSpec)proc.specifications.element();
proc.curr_mem = spec_head.mem_req;
MemQueue.updateCurrentFreeMem(proc.curr_mem, -1);
}
static void update(int psg)
{
System.out.println("Came to update the Ready Queue");
System.out.println("Running process : ");
if(running!=null)
running.printDetails();
else
System.out.println("NULL");
if (running!=null)
{
if(running.state==-1)
{
running=null;
return;
}
PCB.entries.get(running.tableIndex).current_exec+=psg;
PCB.addtoQueue(running.tableIndex,0);
}
try
{
running = ReadyProcs.remove();
//changing the state of the guy after putting him to run
PCB.entries.get(running.tableIndex).state=0;
}
catch (Exception e)
{
System.out.println("There is no Running Process");
}
}
}