



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Study notes on scheduling techniques in the operating system.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Categories of Scheduling Algorithms
1. Scheduling in Batch Systems Throughput: complete as many jobs as possible per unit time;
Turnaround: minimize time between submission of a job and its completion;
a) First-Come, First-Served (FCFS) Scheduling Algorithm Jobs are executed on first come, first serve basis. It is a non-preemptive scheduling algorithm. Easy to understand and implement. Its implementation is based on FIFO queue. Poor in performance as average waiting time is high. Consider the following example:
Process CPU time P1 3 P2 5 P3 2 P4 4
Using FCFS algorithm find the average waiting time and average turnaround time if the order is P1, P2, P3, P4. Solution: If the process arrived in the order P1, P2, P3, P4 then according to the FCFS the Gantt chart will be:
The waiting time for process P1 = 0, P2 = 3, P3 = 8, P4 = 10 then the turnaround time for process P1 = 0 + 3 = 3, P2 = 3 + 5 = 8, P3 = 8 + 2 = 10, P4 = 10 + 4 =14. Then average waiting time = (0 + 3 + 8 + 10)/4 = 21/4 = 5. Average turnaround time = (3 + 8 + 10 + 14)/4 = 35/4 = 8.
b) Shortest Job First (SJF) Scheduling Algorithm This is also known as Shortest Job Next (SJN) Process with less burst time will always execute first. This is a non-preemptive scheduling algorithm. Best approach to minimize waiting time. Better than FCFS scheduling.
Easy to implement in Batch systems where required CPU time is known in advance. Impossible to implement in interactive systems where required CPU time is not known.
Consider the following example: Process CPU time P1 3 P2 5 P3 2 P4 4
Solution: According to the SJF the Gantt chart will be
The waiting time for process P1 = 0, P2 = 2, P3 = 5, P4 = 9 then the turnaround time for process P3 = 0 + 2 = 2, P1 = 2 + 3 = 5, P4 = 5 + 4 = 9, P2 = 9 + 5 =14. Then average waiting time = (0 + 2 + 5 + 9)/4 = 16/4 = 4 Average turnaround time = (2 + 5 + 9 + 14)/4 = 30/4 = 7.
c) Shortest Remaining Time Next (SRTN) Scheduling SRTN is a scheduling discipline in which the next process is selected on the basis of the shortest remaining execution time. Preemptive version of the SJF algorithm. It is faster than the non-preemptive SJF. Short processes are handled very quickly. Impossible to implement in interactive systems where required CPU time is not known. It is often used in batch environments where short jobs need to give preference.
Consider the following example. Process Arrival Time CPU time P1 0 8 P2 1 4 P3 2 9 P4 3 5
b) Priority Scheduling Priority scheduling is a non-preemptive algorithm and one of the most common scheduling algorithms in batch systems. Each process is assigned a priority. Process with highest priority is to be executed first and so on. Processes with same priority are executed on first come first served basis. Priority can be decided based on memory requirements, time requirements or any other resource requirement.
Consider the following example: Process CPU Time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2
According to the priority scheduling the Gantt chart will be
The waiting time for process P1 = 6 P2 = 0 P3 = 16 P4 = 18 P4 = 1 The average waiting time = (0 + 1 + 6 + 16 + 18)/5 = 41/5 = 8. average turnaround time: (1+6+16+18+19)/5 = 12
c) Multiple Queues Multiple-level queues are not an independent scheduling algorithm. They make use of other existing algorithms to group and schedule jobs with common characteristics. Multiple queues are maintained for processes with common characteristics. Each queue can have its own scheduling algorithms. Priorities are assigned to each queue.
System process:-
There is various kind of process in the operating system. The operating system itself has own process to run called system process Interactive process:- The interactive process is online game or listing music( there should be the same kind of interaction) Batch system:- We submit the job to the processor and take the result later. Student process:- Normal student processes(Application) comes inside student process
d) Lottery Scheduling The basic idea is to give processes lottery tickets for various system resources, such as CPU time. Whenever a scheduling decision has to be made, a lottery ticket is chosen at random, and the process holding that ticket gets the resource. Scheduler picks winning ticket randomly, gives owner the resource. Lottery scheduling can be preemptive or non-preemptive. Lottery scheduling is highly responsive. If there are 100 tickets outstanding, and one process holds 20 of them, it will have a 20% chance of winning each lottery. Example – If we have two processes A and B having 60 and 40 tickets respectively out of total 100 tickets. CPU share of A is 60% and that of B is 40%.
e) Fair-Share Scheduling Fair Share Scheduling is a scheduling strategy in which the CPU usage is equally distributed among system users or groups, as opposed to equal distribution among processes. It is also known as Guaranteed scheduling. example, consider a system with two users, each of which has been promised 50% of the CPU. User 1 has four processes, A, B, C, and D, and user 2 has only