1. SCHEDULING
CA1
Name- Sarupya Datta Sub- Operating System
Roll No.- 13000121089 Code- PCC-CS502
Stream- CSE Sec- B
Registration No.- 211300100110097
2. INTRODUCTION
• CPU scheduling in operating systems is the process of determining which process or task should have access
to the CPU (Central Processing Unit) at any given time. The scheduler makes this decision based on
predefined algorithms and policies, with the goal of optimizing system performance, responsiveness, and
resource utilization. CPU scheduling enables multitasking, allowing multiple processes to run concurrently
and share the CPU's processing time, leading to efficient execution of tasks and a smooth user experience .
• There are different CPU scheduling algorithms, but here we are going to discuss only those
two type which are related to our assignment–
SRTF
FCFS
3. Shortest RemainingTime First Algorithm
(SRTF)
• Shortest Time Remaining First (STRF) is a CPU scheduling algorithm used in operating
systems. In STRF, the operating system selects the process with the smallest remaining burst
time (time required to complete its execution) to execute next.
• This ensures that the process with the least amount of work remaining is given priority.
• STRF aims to minimize the average waiting time and turnaround time for processes, making
it an efficient scheduling algorithm for certain scenarios, particularly when dealing with
short tasks.
• It is a preemptive variant of Shortest Job Next (SJN) scheduling.
• Mode -> preemptive
• Criteria -> Burst time(B.T)
4. Numericals
• Q1). Consider a uniprocessor system, where three processes (Process ID 1, 2, 3 respectively) are there. Arrival
time of the three processes are last 3 digits of your registration number (i.e. if your registration number is
201300100110019, arrival time of P1=0, P2=1, P3=9). Burst time of process 1 is the addition of date (dd, i.e. if
21/07/2003 is Date of Birth, then it is 2+1 = 3), process 2 is addition of month (mm, if July then 0+7, i.e. 7),
and process 3 is addition of last two digit of the year (yy, if 2003 then 0+3, i.e. 3, if it is 2000 then take first 2
digit). Assume that CPU is using Shortest remaining time first algorithm.
i. Calculate Waiting time of each of the process
ii. Calculate turnaround time of each of the process.
iii. Calculate the percentage of time CPU remains idle.
Sol-
• Priority:- Shortest Remaining Time First (SRTF)
• To Calculate:- 1) Waiting time of each process.
2) Turn around time of each of the process.
3) Percentage of time CPU remains idle.
• Registration no. 211300100110097
• Date of Birth- 02/03/2003
5. Processors Arrival Burst
P1 0 2
P2 9 3
P3 7 3
PROCESS
ID
ARRIVAL
TIME
(AT)
BURST
TIME
(BT)
COMPLETION
TIME
(CT)
Turn
Around
Time
(CT-AT)
WAITING
TIME
(TAT-BT)
P1 0 2 2 2 0
P2 9 3 13 4 1
P3 7 3 10 3 0
P1 --- P3 P2
0 2 7 10 13
GANTT CHART:-
6. i) Calculated Waiting time of each of the process:- P1=0
P2=1
P3=0
ii) Calculated Turn-around Time of each of the process:- P1=2
P2=4
P3=3
iii) Calculate the percentage of time CPU remains idle:-
(Total idle time of CPU/ Total time take for competition of whole process)*100
= (5/13)*100
= 38.46 %
7. FCFS
• First Come First Serve (FCFS) is a non-preemptive CPU scheduling algorithm used in operating systems.
• In FCFS, processes are executed in the order they arrive in the ready queue .
• The process that arrives first is the first to be allocated the CPU, and it continues running until it completes
its execution or enters a waiting state. Only when the first process finishes, the next process in the queue is
executed, and this process continues until all processes are completed.
• FCFS operates on a first-come, first-served basis, without any consideration of the length of the processes or
their priority.
• While FCFS is easy to implement and ensures fairness, it may lead to long average waiting times, especially
if longer processes arrive first and block shorter ones from executing.
• Criteria:- Arrival Time(A.T)
• Mode:-Non-preemptive
• FCFS is not the most efficient scheduling algorithm and may not be suitable for scenarios with varying
process execution times.
8. Q2) Consider a uniprocessor system, where there exist three processes (Process ID 1, 2, 3 respectively). CPU assigns priority
of the processes based on highest waiting time of the processes present at that time after every 2-unit time. In any process
terminates before the interval time then the default situation will be FCFS scheduling. Each of the process will arrive based
on the last 3 digits of your university roll number. (If Roll No. is 13000118137, arrival time of P0 =1, P1=3, P2=7). CPU
Burst time will be first three digits of your mobile number (i.e. if your mobile number is 8756540439, CPU burst time of
P1=8, P2=7, P3=5, if any number is 0, then take next non zero value from your mobile number like 7000312867, CPU burst
time of P1=7, P2=3, P3=1).
i. Calculate Average Waiting Time.
ii. Calculate Average Turnaround Time.
iii. Calculate the percentage of time CPU remains idle
Sol-
Priority:-
Highest waiting time after every 2 unit of time interval
FCFS(Default: If any process terminates before the interval )
To Calculate:-
i. Average Waiting Time
ii. Average turn around Time
iii. Percentage of time CPU remains idle
University roll number : 13000121089
Mobile number : 7003072392
9. Process Arrival Time Burst Time
P1 0 7
P2 8 3
P3 9 7
PROCESS
ID
ARRIVAL
TIME
(AT)
BURST
TIME
(BT)
COMPLETION
TIME
(CT)
Turn Around Time
(CT-AT)
WAITING
TIME
(TAT-BT)
P1 0 7 7 7 0
P2 8 3 13 5 2
P3 9 7 18 9 2
P1 P1 P1 P1 ----- P2 P3 P2 P3
0 2 4 6 7 8 10 12 13 18
10. i) Calculate Average Waiting Time: (WT of P1 + WT of P2 + WT of P3 )/3
= (0 + 2 + 2)/3
= 4/3
= 1.33 %
ii) Calculate Average Turnaround Time : (TAT of P1 + TAT of P2 + TAT of P3)/3
= (7 + 5 + 9)/3
= 21/3
= 7 %
iii) Calculate the percentage of time CPU remains idle : (Total idle time of CPU/ Total time take for competition of whole process)*100
= 1/18 * 100
= 5.55 %
11. Conclusion
Scheduling algorithms tell the CPU which will be the next process to have CPU time. The main goal
of scheduling algorithms in OS is to Maximize Throughput. Scheduling algorithms can be preemptive
and non-preemptive.