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/ 8
CPU Scheduling | Practice Problems | Numericals
& Operating System
Spread the love
M
CPU Scheduling Algorithms-
Various CPU scheduling algorithms are-
+ ECES Scheduling
+ SJF Scheduling | SRTF Scheduling
+ Round Robin Scheduling
+ Priority Scheduling
PRACTICE PROBLEMS BASED ON CPU SCHEDULING
ALGORITHMS.
A JUST $1 AMONTH’GIVES LIBRARY ACCESS.4O A STUDENT FOR
|
EVENS
ey DYNConsider three process, all arriving at time zero, with total execution time of 10, 20 and 30 units
respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing
‘computation, and the last 10% of time doing /O again. The operating system uses a shortest remaining
‘compute time first scheduling algorithm and schedules a new process
‘er when the running process gets
blocked on /O or when the running process finishes its compute burst. Assume that all /O operations can
be overlapped as much as possible. For what percentage of does the CPU remain idle?
ee
Br}
Ceo)
eerie
rod
een
healthier lives
1.0%
2.106%
3. 30.0%
4, 89.4%
According to question, we have-
Total Riret Tima UO Rust CPI Ruret UO RustProcess P2 20
14 2
Process P3 30 6 24 3
The scheduling algorithm used is Shortest Remaining Time First.
Gantt Chart-
0 Z 4 6 9 10 23 25 44 4T
— — == < >
PA P41 P2 "
—m——>
P2
<>
P3
Gantt ChartPercentage of time CPU remains idle
= (6/47) x 100
= 10.638%
Thus, Option (B) is correct.
Problem-0;
Consider the set of 4 processes whose arrival time and burst time are given below-
Burst Time
Process No. | Arrival Time
‘CPU Burst VO Burst ‘CPU Burst
Pt 0 3 2 2
P2 0 2 4 1
P3 2 1 3 2
P4 5 2 2 1
Ifthe CPU scheduling policy is Shortest Remaining Time First, calculate the average waiting time and
average turn around time.Solution-Now, we know-
‘+ Tum Around time = Exit time — Arrival time
‘+ Waiting time = Turn Around time — Burst time.
Also read- Various Times Of Process
Process Id Exit time Turn Around time Waiting time
Pt 1" 1-0-1 11 -(842)=6
P2 7 7-057 7-H =4
P3 9 9-2-7 7-(142)=4
Pa 6 16-5=11 1-21) =8+ Average waiting time = (6 +4 +4 +8)/4=22/5=4.4 units
Problem-03:
Consider the set of 4 processes whose arrival time and burst time are given below-
Arrival Burst Time
Process No. |. | Priority
Time cPUBurst | VOBurst | CPU Burst
PL oO 2 1 5 3
P2 2 3 3 3 1
P3 3 1 2 3 1
Ifthe CPU scheduling policy is Priority Scheduling, calculate the average waiting time and average turn
around time. (Lower number means higher priority)The scheduling algorithm used is Priority Scheduling.
Gantt Chart-
0 1 2 3 4 5 6 7
pt MM ee [es [ee [ee | ms [et | Ps
Pi <>
P3
9 10 1 12 13 14 15
[es | 2 | =
SS
P2
Gantt Chart
Now, we know-
‘+ Tum Around time = Exit time — Arrival time
‘* Waiting time = Turn Around time — Burst time
Process Id Exit time Turn Around time
Pt 10 10-0=10
P2 15 15-2=13
PS. 9 9-3-6
Waiting time
10-(143)=6
13-(3+1)=9
6-(2+1)=3