Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views25 pages

OS Class - 3

The document discusses various CPU scheduling algorithms including preemptive and non-preemptive scheduling, First Come First Serve (FCFS), Shortest Job First (SJF), and Round Robin. It outlines the advantages and disadvantages of each scheduling method, emphasizing their impact on average waiting time and turnaround time. Additionally, it provides examples for calculating these metrics based on given processes' arrival and burst times.

Uploaded by

mahafujalam90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
9 views25 pages

OS Class - 3

The document discusses various CPU scheduling algorithms including preemptive and non-preemptive scheduling, First Come First Serve (FCFS), Shortest Job First (SJF), and Round Robin. It outlines the advantages and disadvantages of each scheduling method, emphasizing their impact on average waiting time and turnaround time. Additionally, it provides examples for calculating these metrics based on given processes' arrival and burst times.

Uploaded by

mahafujalam90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 25
Computer teacher 2025 Preemptive Scheduling: > Preemptive scheduling is used when a process switches from running state to ready state or from waiting state to ready state. The resources (mainly CPU cycles) are allocated to the process for the limited amount of time and then is taken away, and the process is again placed back in the ready queue if that process still has CPU burst time remaining. That process stays in ready queue tilHitg (sj next chance to execute Ex ann le CPv] | Rounet Rabsn SRTE Prony (Pend Computer teacher 2025 SIF 6 cr on vg ( non- prcarretve) Non-preemptive Scheduling is used when a process terminates, or a process switches from running to waiting state. In this scheduling, once the resources (CPU cycles) is allocated to a process, the process holds the CPU till it gets terminated or it reaches a waiting state. In case of non-preemptive scheduling does not interrupt a process running CPU in middle of the execution. Instead, it waits till the process complete its CPU burst time and then it can allocate the CPU to another process. pie Allo} men ¢ Hl] 48m wlio) reemptive Schedu' | Computer teacher 2025 _Drtival Time: Time at which the process arrives in the ready queue. _Completion Time: Time at which process completes its execution. _Byet Time; Time required by a process for CPU execution. xecuh'on _JurfAround Time: Time Difference between completion time and arrival time. Turn Around Time =|Completion Time — Arrival Time _whaiting Time(W-T): Time Differ turnaround time and burst time. Gis a wee (Turn Around Time — Burst Time @& "se GF Bae hen) Computer teacher 2025 First Come First Serve (FCFS) In FCFS Scheduling The process which arrives first in t! ady queue is firstly assigned the CPU. 12, case of a tie, process with smaller process id is executed first. It is always. Ton-preemptive jn nature. Jobs are executed on first come, first serve basis. It is a non-preemptive, préxémptive scheduling algorithm. Easy to understand and implement. Its implementation is based on]FIFO fueue. Poor in performance as average.wait time is high Computer teacher 2025 Advantages- Itis simple an Cosy to understand. It can be easily implemented -dsing queue data structure. fl=so It does not lead te aryation Disadvantages- Paz s It does not consider the priority or burst time of the processes. suffers from|convoy effectli.e. processes with higher burst time arrived before the processes with smaller burst time. Computer teacher 2025 Advantages- It is simple and easy to understand. It can be easily implemented using queue data structure. It does not lead to starvation. Disadvantages- It does not consider the priority or burst time of the processes. It suffers from convoy effect i.e. processes with higher burst time arrived before the processes with smaller burst time. | 2 Computer teacher 2025 } Ct CZ Q. Consider the following processes with burst time (CPU Execution time). Calculate the A Process id _| Arrival time Bursttime/CPU execution time |<. [TAT | ws T Wt [rate at | PL 0 2 278 foe P2 1 3 SM ' P3 2 5 lo [873 ~ Pa 3 4 TY [pe TAT = |CTAT °5 4 6 a0 [1 | lo CS) FRERE| Ee ITS OWD & P! pe PS 4 Computer teacher 2025 } Consider the processes P1, P2, P3, P4 given in the below table, arrives for execution in the same order, with given Arrival Time and Burst Time. PROCESS | ARRIVAL TIME | BURST TIME Pl 0 8 P2 1 4 3 2 9 cD) PA 4 5 Computer teacher 2025 shortest Job First (SiF) 7. P=E NS Process which have the shortest burst time are scheduled first. If two processes have the same bust time, then FCFS is used to break the tie. This is a non-pre-emptva) pre-emptlye scheduling algorithm. @ Best approach to Chinimize waiting time sy to Implement in Batch systems where required CPU time is known in advance. possible to implement in interactive systems where required CPU time is not known. The processer should know in advance how much time process wil take. Computer teacher 2025 Advantages- _5B7P optimal and guarantees the minimum average waiting time. It provides a standard for other algorithms since no other algorithm performs better than it. Disadvantages It can not be implemented practically since burst time of the processes can not be known in advance. It leads to starvation for processes with larger burst time. Priorities can not be set for the processes. (? Processes with larger burst time have poor response time Computer teacher 2025 Advantages- BSRTF is optimal and guarantees the imum average waiting time. It provides a standard for other algorithms since no other algorithm performs better than it. Disadvantages- Bit can not be implemented practically since burst time of the processes can not be known in advance, Blt leads to starvation for processes with larger burst time. Priorities can not be set for the processes. @ Processes with larger burst time have poor response time Computer teacher 2025 } Example-01; Consider the set of 5 processes whose arrival time and burst time are given below- Process Id fT] Arrival time [74] 7] Burst time PL fe 3743, OO P2116 yi 4 BF 4-7s[3] 2 aa PG 0 [6[°] 6 PS pie 2-JPla[ 3 @ Py] rR] palPs| re L Yi Coes TAT: Yo/e g Computer teacher 2025 Consider the set of 5 processes whose arrival time and burst time are given below- Process Id Arrival time Burst time Pl 3 I P2 | 4 P3 4 2 P4 0 6 PS 2 3 Ifthe CPU scheduling policy is SIF pre-emptive, calculate the average waiting time and average turnaround time, Computer teacher 2025 Consider the set of 3 processes whose arrival time and burst time are given below- Process Id_| Arrivaltime | Burst time Pi 0 9 P2 1 4 P3 2 9 Ifthe CPU scheduling policy is SRTF, calculate the average waiting time and average tum around time. Computer teacher 2025 Round Robin Scheduling [1 CPU is assigned to the process on the basis of FCFS for a fixed amount of time. This fixed amount of time is called as time quantum or time slice. @ After the time quantum expires, the running process is preempted and sent to the ready queue. Then, the processor is assigned to the next arrived process. & It is always preemptive in nature Select a process Burst Time < ves Execute till No Time Quantum completion eo I ¥ Termination Execute for Time ‘Quantum Time Quantum Expires Round Robin Scheduling Computer teacher 2025 Advantages- It gives the best performance in terms of average response time. It is best suited for time sharing system, client server architecture and interactive system. Computer teacher 2025 Disadvantages- It leads to starvation for processes with larger burst time as they have to repeat the cycle many times. Its performance heavily depends on time quantum. Priorities can not be set for the processes. Computer teacher 2025 With decreasing value of time quantum, Number of context switch increases esponse time decreases Chances of starvation decreases response time. Computer teacher 2025 With increasing value of time quantum, @ Number of context switch decreases @ Response time increases Chances of starvation increases Thus, higher value of time quantum is better in terms of number of context switch. Computer teacher 2025 With increasing value of time quantum, Round Robin Scheduling tends to become FCFS Scheduling. When time quantum tends to infinity, Round Robin Scheduling becomes FCFS Scheduling. The performance of Round Robin scheduling heavily depends on the value of time quantum. The value of time quantum should be such that it is neither too big nor too small. Computer teacher 2025 Example-01: Consider the set of 5 processes whose arrival time and burst time are given below- Process Id. Arrival time Burst time PL 0 j P2 I 3 P3 2 1 P4 3 2 P5 4 3 Computer teacher 2025 APP FEATURES ¥ ® 8 @ % 2 G E 65 Beas) UOG8

You might also like