-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
40 lines (31 loc) · 1.26 KB
/
Main.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
import java.util.List;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.Queue;
public class Main{
public static void main(String[] args) {
List<Integer> proc_id = new ArrayList<Integer>();
List<Integer> exec_time = new ArrayList<Integer>();
ArrayList<Job> jobQueue = new ArrayList<Job>();
ReadyQueue readyQueue = new ReadyQueue();
Queue<Job> queue = new LinkedList<Job>();
// TO DO: Add Job Here!!
// queue.add(new Job(0, 0, 3));
// queue.add(new Job(1, 5, 8));
// queue.add(new Job(2, 0, 4));
queue.add(new Job(0, 0, 15)); //id, arrival time, brust time
queue.add(new Job(1, 1, 9));
queue.add(new Job(2, 10, 4));
// TO DO: Set time quantum Here!!
int timeQuantum = 2;
Thread creator = new Thread(new Creator(queue, jobQueue));
Thread jobSched = new Thread(new JobScheduler(jobQueue, readyQueue));
Thread cpuSched = new Thread(new CPUScheduler(readyQueue, timeQuantum, proc_id, exec_time));
creator.start();
jobSched.start();
cpuSched.start();
}
}