Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE MAKE THS ON EXCEL import java.io.File; import java.io.FileNotFoundException; import java.util.*; public class ProcessSchedulingEngine { static Process[] processArr; static int quantum; public static void main(String[]

PLEASE MAKE THS ON EXCEL

image text in transcribed

image text in transcribed

import java.io.File; import java.io.FileNotFoundException; import java.util.*; public class ProcessSchedulingEngine { static Process[] processArr; static int quantum; public static void main(String[] args) throws FileNotFoundException, InterruptedException { Thread initializerThread = new Thread(new Runnable() { @Override public void run() { System.out.println("Running the initializer thread."); try { // initializer(processArr, quantum); initializer(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }); initializerThread.start(); initializerThread.join(); Thread schedulerThread = new Thread(new Runnable() { @Override public void run() { System.out.println("Running the scheduler thread."); schedulerThread(processArr, quantum); } }); schedulerThread.start(); } private static void schedulerThread(Process[] processArr, int quantum) { System.out.println("Running the scheduler thread."); System.out.println("Process Arr : " + processArr.length); // this creates a priority queue(order) of the processes to be run // create custom scheduler as per the given condition Queue processQueue = new PriorityQueue(new CustomScheduler()); // add all the processes to the queue for (int i = 0; i quantum){ current.setExecutionTime(current.getExecutionTime() - quantum); current.setArrivalTime(current.getArrivalTime()+quantum); processQueue.add(current); } } } public static void initializer() throws FileNotFoundException { System.out.println("Running the initializer method."); Scanner sc = new Scanner(new File("src/Chegg/java/processinput.txt")); int index = -1; while (sc.hasNextLine()) { String line = sc.nextLine(); System.out.println("Process Line : " + line); if (line.split(",").length == 2) { int n_proc = Integer.parseInt(line.split(",")[0]); quantum = Integer.parseInt(line.split(",")[1]); processArr = new Process[n_proc]; } else { index++; String[] processInfo = line.split(","); System.out.println("Process info : " + processInfo[0] + ", " + processInfo[1] + ", " + processInfo[2] + ", " + processInfo[3]); processArr[index] = new Process(Integer.parseInt(processInfo[0]), Integer.parseInt(processInfo[1]), Integer.parseInt(processInfo[2]), Integer.parseInt(processInfo[3])); } } } } class Process { int[] processIDArray = new int[1001]; int identifier; int arrivalTime; int executionTime; int priority; public Process() { Random random = new Random(); int next = random.nextInt(1001); while (processIDArray[next] != 0) { next = random.nextInt(1001); } if (processIDArray[next] == 0) this.identifier = next; this.arrivalTime = 0; this.executionTime = 0; this.priority = 0; } public Process(int identifier, int arrivalTime, int executionTime, int priority) { this.identifier = identifier; this.arrivalTime = arrivalTime; this.executionTime = executionTime; this.priority = priority; } public int getIdentifier() { return identifier; } public void setIdentifier(int identifier) { this.identifier = identifier; } public int getArrivalTime() { return arrivalTime; } public void setArrivalTime(int arrivalTime) { this.arrivalTime = arrivalTime; } public int getExecutionTime() { return executionTime; } public void setExecutionTime(int executionTime) { this.executionTime = executionTime; } public int getPriority() { return priority; } public void setPriority(int priority) { this.priority = priority; } @Override public String toString() { return "Process{" + "identifier=" + identifier + ", arrivalTime=" + arrivalTime + ", executionTime=" + executionTime + ", priority=" + priority + '}'; } } class CustomScheduler implements Comparator { @Override public int compare(Process o1, Process o2) { // if o1 has lesser arrival time, prioritize it first if (o1.getArrivalTime() > o2.getArrivalTime()) { return 1; } else if (o1.getArrivalTime() == o2.getArrivalTime()) { // if arrival time is same, then choose the one with smaller identifier value if (o1.getIdentifier() > o2.getIdentifier()) { return 1; } } return -1; } } Sample Output Running the initializer thread. Running the initializer method. Process Line : 3,5 Process Line : 1,5,8,1 Process info : 1, 5, 8, 1 Process Line : 2,0,10,2 Process info : 2, 0, 10, 2 Process Line : 3,10,7,3 Process info : 3, 10, 7, 3 Running the scheduler thread. Running the scheduler thread. Process Arr : 3 Running the processes Process{identifier=2, arrivalTime=0, executionTime=10, priority=2} Process{identifier=1, arrivalTime=5, executionTime=8, priority=1} Process{identifier=2, arrivalTime=5, executionTime=5, priority=2} Process{identifier=1, arrivalTime=10, executionTime=3, priority=1} Process{identifier=3, arrivalTime=10, executionTime=7, priority=3} Process{identifier=3, arrivalTime=15, executionTime=2, priority=3

Explanation

Please refer to solution in this step.

CHEGG LNK ;

https://www.chegg.com/homework-help/questions-and-answers/term-project-2-details-scope-term-project-aims-combine-knowledge-quin-theory-analysis-deve-q90870037?trackid=HiHbksWP

Term Project-2 Details Scope: This term project aims to combine your knowledge on Queuing Theory together with your analysis and development skills. You will be working as a team and are asked to provide a decision support tool (DST) to perform various Queuing Theory Queuing Models analysis. Details and deliverible requirements are provided in the requirements section. Requirements: Input requirements: This part is explaining the items related to the user inputs of the DST. List of inputs expected from the user are: - The queuing model (QM) to be analysed. This should be a drop down menu that the user can select from. It can be one of the following: 9 M/M/1:GD/v/p OM/MI:GD/N/ OM/M/c:GD/ OM/M/c:GD/N/ M/MGD/ (self-service model) M/M/R:GD/K/K (repair-shop model) MG/1:GD60/(P-K formula) - Parameters of the QM depending on the selected queuing model. The following matrix provides the necessary input for each QM: Quering Model MMIGD MMIGDN LAN MMCGDN LAN MMG elf service model M/MR:GDKK (repair shop model LARK MGGD (PK formula) LEM. Vart Functionality Requirements. This part of the project describes what kind of calculations and operations your DST must be providing: - Checking if the the user selected a QM from the drop down menu. If not warn the user. -Depending on the menu selected display the required parameter input fields and check for the validity of all required parameters - Calculate the following steady-state measures of performance: OP.P. (for n upto 20). o for limited N QMsp..L.L o L.L.W.W MMEGD Output Requirements: This part of the project describes what outputs your DST should be delivering to users. You are supposed to provide the steady-state measures of performance described previously. Namely, you should display the results for: OP. p. (for n upto 20). o for limited N QMs: P. LL o L.L.W.W Other Details: - You can use any programming language to develop your DST. Excel VB is recommended but not mandatory. Submission deadline: January 7th, Friday, 23:59 - All team members are expected to contribute - An oral presentation and demonstration will be done randomly on the group members, explaining all the details of the project. - You will be delivering all of your source code, project files and related items - You will also deliver a small report/manual on how your DST is used by providing screen shots on a sample data (at most 5 pages) Term Project-2 Details Scope: This term project aims to combine your knowledge on Queuing Theory together with your analysis and development skills. You will be working as a team and are asked to provide a decision support tool (DST) to perform various Queuing Theory Queuing Models analysis. Details and deliverible requirements are provided in the requirements section. Requirements: Input requirements: This part is explaining the items related to the user inputs of the DST. List of inputs expected from the user are: - The queuing model (QM) to be analysed. This should be a drop down menu that the user can select from. It can be one of the following: 9 M/M/1:GD/v/p OM/MI:GD/N/ OM/M/c:GD/ OM/M/c:GD/N/ M/MGD/ (self-service model) M/M/R:GD/K/K (repair-shop model) MG/1:GD60/(P-K formula) - Parameters of the QM depending on the selected queuing model. The following matrix provides the necessary input for each QM: Quering Model MMIGD MMIGDN LAN MMCGDN LAN MMG elf service model M/MR:GDKK (repair shop model LARK MGGD (PK formula) LEM. Vart Functionality Requirements. This part of the project describes what kind of calculations and operations your DST must be providing: - Checking if the the user selected a QM from the drop down menu. If not warn the user. -Depending on the menu selected display the required parameter input fields and check for the validity of all required parameters - Calculate the following steady-state measures of performance: OP.P. (for n upto 20). o for limited N QMsp..L.L o L.L.W.W MMEGD Output Requirements: This part of the project describes what outputs your DST should be delivering to users. You are supposed to provide the steady-state measures of performance described previously. Namely, you should display the results for: OP. p. (for n upto 20). o for limited N QMs: P. LL o L.L.W.W Other Details: - You can use any programming language to develop your DST. Excel VB is recommended but not mandatory. Submission deadline: January 7th, Friday, 23:59 - All team members are expected to contribute - An oral presentation and demonstration will be done randomly on the group members, explaining all the details of the project. - You will be delivering all of your source code, project files and related items - You will also deliver a small report/manual on how your DST is used by providing screen shots on a sample data (at most 5 pages)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions