Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write the program in Java: 4. Priority queue You have been asked to test the effectiveness of the following different scheduling algorithms for different
Please write the program in Java:
4. Priority queue You have been asked to test the effectiveness of the following different scheduling algorithms for different types of queuing applications. 1) First-In-First-Out (FIFO): The jobs are processed in the arriving order. The job at the front of the queue is served until it has completed. That job is then removed from the queue. The next job at the front of the queue is served until it has completed and then it is removed from the queue. This process is continued until the queue is empty 2) Shortest-Job-First (SJF): The job with the shortest processing time is processed first until it has completed. That job is then removed from the queue. The next job with leted and then it is removed from st processing is then served until it has the queue. This process is continued until the queue is empty 3) Round-Robin (RR): Jobs are processed using a fixed time-slice. The jobs are initially kept in a queue based on the order of arrival. The job at the front of the queue is removed and served similar to the FIFO algorithm. However, unlike the FIFO algorithm, each job is served up to the pre-defined slice of time. If job can be completed within the allotted time it is fully served and removed from the queue. If the job cannot be completed in the allotted time, it is served for the allotted time and then added to the end of the queue to process is continued until the queue is empty be served later for the remaining time. This The total turnaround time is the total time a job spends in the system: Turnaround time processing time + waiting time (time spend in queue. For example, it the work load is 15 units, but it spends 50 units of time in queue, waiting to be processed, then the turnaround time is equal to 65 units. A) Write a program to test the effectiveness of these algorithms. Create 100 jobs, each with a random processing time of 0 to 100 time units. Then process the jobs according to the above sched and RR scheduling schemes. Implement the SJF using a binary heap (priority heap). Use a time slice of 20 units. Compare the average turnaround time for the different strategies. uling methods. You can use an ArrayList for the FIFO B) Experiment with different time slices for the RR strategy and compare the results. Use time slices in increments of 5 units and see if there are any differences in the average turnaround time. 4. Priority queue You have been asked to test the effectiveness of the following different scheduling algorithms for different types of queuing applications. 1) First-In-First-Out (FIFO): The jobs are processed in the arriving order. The job at the front of the queue is served until it has completed. That job is then removed from the queue. The next job at the front of the queue is served until it has completed and then it is removed from the queue. This process is continued until the queue is empty 2) Shortest-Job-First (SJF): The job with the shortest processing time is processed first until it has completed. That job is then removed from the queue. The next job with leted and then it is removed from st processing is then served until it has the queue. This process is continued until the queue is empty 3) Round-Robin (RR): Jobs are processed using a fixed time-slice. The jobs are initially kept in a queue based on the order of arrival. The job at the front of the queue is removed and served similar to the FIFO algorithm. However, unlike the FIFO algorithm, each job is served up to the pre-defined slice of time. If job can be completed within the allotted time it is fully served and removed from the queue. If the job cannot be completed in the allotted time, it is served for the allotted time and then added to the end of the queue to process is continued until the queue is empty be served later for the remaining time. This The total turnaround time is the total time a job spends in the system: Turnaround time processing time + waiting time (time spend in queue. For example, it the work load is 15 units, but it spends 50 units of time in queue, waiting to be processed, then the turnaround time is equal to 65 units. A) Write a program to test the effectiveness of these algorithms. Create 100 jobs, each with a random processing time of 0 to 100 time units. Then process the jobs according to the above sched and RR scheduling schemes. Implement the SJF using a binary heap (priority heap). Use a time slice of 20 units. Compare the average turnaround time for the different strategies. uling methods. You can use an ArrayList for the FIFO B) Experiment with different time slices for the RR strategy and compare the results. Use time slices in increments of 5 units and see if there are any differences in the average turnaround timeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started