Question: Scheduling Algorithms This project involves implementing several different process scheduling algorithms. The scheduler will be assigned a predefined set of tasks and will schedule the
Scheduling Algorithms
This project involves implementing several different process scheduling algorithms. The scheduler will be assigned a predefined set of tasks and will schedule the tasks based on the selected scheduling algorithm. Each task is assigned a priority and CPU burst. The following scheduling algorithms will be implemented:
Firstcome, firstserved FCFS which schedules tasks in the order in which they request the CPU.
Shortestjobfirst SJF which schedules tasks in order of the length of the tasks' next CPU burst.
Priority scheduling, which schedules tasks based on priority.
Roundrobin RR scheduling, where each task is run for a time quantum or for the remainder of its CPU burst
Priority with roundrobin, which schedules tasks in order of priority and uses roundrobin scheduling for tasks with equal priority.
Priorities range from to where a higher numeric value indicates a higher relative priority. For roundrobin scheduling, the length of a time quantum is milliseconds.
Implementation
The implementation of this project may be completed in either C or Java, and program files supporting both of these languages are provided in the source code download for the text. These supporting files read in the schedule of tasks, insert the tasks into a list, and invoke the scheduler.
The schedule of tasks has the form task namepriorityCPU burst with the following example format:
T
T
T
T
T
Thus, task T has priority and a CPU burst of milliseconds, and so forth. It is assumed that all tasks arrive at the same time, so your scheduler algorithms do not have to support higherpriority processes preempting processes with lower priorities. In addition, tasks do not have to be placed into a queue or list in any particular order.
There are a few different strategies for organizing the list of tasks, as first presented in Section CPU scheduler. One approach is to place all tasks in a single unordered list, where the strategy for task selection depends on the scheduling algorithm. For example, SJF scheduling would search the list to find the task with the shortest next CPU burst. Alternatively, a list could be ordered according to scheduling criteria that is by priority One other strategy involves having a separate queue for each unique priority, as shown in Figure These approaches are briefly discussed in Section Multilevel feedback queue scheduling. It is also worth highlighting that we are using the terms list and queue somewhat interchangeably. However, a queue has very specific FIFO functionality, whereas a list does not have such strict insertion and deletion requirements. You are likely to find the functionality of a general list to be more suitable when completing this project.
Each program should be able to read a text file of tasks, run the corresponding scheduling algorithm and print out the average turnaround and waiting time, for example,
fcfs schedule.txt
It is assumed that all tasks arrive at the same time and in the order according to the list in the input text file. An example input file scheduletxt is provided for testing your programs. The results of your implementation should match the "exampleout.txt for the example input file. But your program should work for any valid list of tasks following the same format and will be graded using a different input file. Your program should print out the turnaround and waiting time of each task, and the average turnaround time and average waiting time, for example:
T turnaround time
T turnaround time waiting time
T turnaround time waiting time
T turnaround time waiting time
T turnaround time waiting time
T turnaround time waiting time
T turnaround time waiting time
T turnaround time waiting time
Average turnaround time Average waiting time
Further challenges
Two additional challenges are presented for this project:
Each task provided to the scheduler is assigned a unique task tid If a scheduler is running in an SMP environment where each CPU is separately running its own scheduler, there is a possible race condition on the variable that is used to assign task identifiers. Fix this race condition using an atomic integer.
On Linux and Mac os x systems, the syncfetchandadd function can be used to atomically increment an integer value. As an example, the following code sample atomically increments value by :
int value ;
syncfetchandadd&value,;
Calculate the average turnaround time, waiting time, and response time for each of the scheduling algorithms.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
