Operating System Lect9
Operating System Lect9
CPU Scheduling
Objectives
• Mulltilevel Scheduling
• Multilevel feedback
• Realtime scheduling
• Multiprocessor scheduling
• Thread Scheduling
Multilevel Queue Scheduling
• It may happen that processes in the ready queue can be divided into
different classes where each class has its own scheduling needs.
• For example, a common division is a foreground (interactive) process
and a background (batch) process. These two classes have different
scheduling needs. For this kind of situation Multilevel Queue
Scheduling is used.
• Ready Queue is divided into separate queues for each class of processes.
Multilevel Queue Scheduling
• System Processes: The CPU itself has its own process to run which is
generally termed as System Process.
• Interactive Processes: An Interactive Process is a type of process in
which there should be same type of interaction.
• Batch Processes: Batch processing is generally a technique in the
Operating system that collects the programs and data together in the form
of the batch before the processing starts.
• Queue 1 has a higher priority than queue 2. Round Robin is used in
queue 1 (Time Quantum = 2), while FCFS is used in queue 2. P4 is
interrupt.
Process Arrival Time CPU Burst Time Queue Number
P1 0 4 1
P2 0 3 1
P3 0 8 2
P4 10 5 4
Working
• Both queues have been processed at the start. Therefore, queue 1 (P1,
P2) runs first (due to greater priority) in a round-robin way and finishes
after 7 units.
• The process in queue 2 (Process P3) starts running (since there is no
process in queue 1), but while it is executing, P4 enters queue 1 and
interrupts P3, and then P3 takes the CPU and finishes its execution.
Multilevel Feedback Queue Scheduling
• Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling is
like Multilevel Queue(MLQ) Scheduling but in this processes can move
between the queues.
• It prevents starvation by moving a process that waits too long for the
lower priority queue to the higher priority queue.
Multilevel Feedback Queue Scheduling
Multilevel Feedback Queue Scheduling
• Consider a system that has a CPU-bound process, which requires a burst
time of 40 seconds. The multilevel Feed Back Queue scheduling
algorithm is used and the queue time quantum ‘2’ seconds and in each
level it is incremented by ‘5’ seconds. Then how many times the process
will be interrupted and in which queue the process will terminate the
execution?
Real time scheduling
• Real time scheduling is of two types:
• Soft Real-Time scheduling which does not guarantee when when a
critical real-time process will be scheduled;
• Hard Real-Time scheduling in which the process must be scheduled
before the deadline.
• Real time scheduling algorithms: rate monotonic scheduling and earliest
deadline first.
Terminologies
• The foremost is that the processes are considered periodic i.e., the process will repeat
itself after a fixed period of time.
• The period of a process is denoted by p.
• The next characteristic is the processing time t i.e., the time for which the process
requires the CPU within each period. In other words processing time refers to the burst
time.
• The final characteristic is the deadline d, i.e., the time before which the process must
be serviced. In general the relationship between these three characteristics is
0≤t≤d≤p
Rate Monotonic Scheduling
• In rate-monotonic scheduling algorithm a static priority policy with
preemption is used.
• Whenever a high priority process arrives it will preempt a lower priority
process.
• Every process gets the priority according to its period. Lower the period
higher is the priority. Also, the processing time remains the same in each
period.
• Suppose there are two processes, P1 and P2. The periods for P1 and P2
are 50 and 100. The processing times are t1 = 20 for P1 and t2 = 35
for P2. The deadline for each process requires that it complete its CPU
burst by the start of its next period.
P1 50 20
P2 100 35
Earliest Deadline First Scheduling
• The second algorithm under real time scheduling is Earliest Deadline First
Scheduling. This algorithm assigns priority to the process based on the
deadline.
• Earlier the deadline, higher is the priority.
• Thus, the priorities keep on changing in this scheduling.
Assume that process P1 has a period of p1 = 50 and a CPU burst of t1 = 25. For P2, the
corresponding values are p2 = 80 and t2 = 35