chatgpt.com-Round Robin Scheduling Summary
chatgpt.com-Round Robin Scheduling Summary
chatgpt.com/c/6730dbbc-b540-8010-b33f-103d4a415dd6
The Round Robin (RR) scheduling algorithm allocates CPU time in fixed intervals
called time quanta. Each process runs for one time quantum, then, if not finished, it is
preempted and moved to the back of the queue, allowing the next process to run. If a
process completes before the time expires, it releases the CPU voluntarily. This
preemptive approach ensures all processes get fair CPU access, enhancing
responsiveness in multitasking systems.
1/8
The Least Recently Used (LRU) page replacement policy replaces the
page that has not been used for the longest period of time. LRU
replacement associates with each page the time of that page's last use.
When a page must be replaced, LRU chooses the page that has not
been used for the longest period of time. The LRU policy is often used
as a page-replacement algorithm and is considered to be good. An
LRU page-replacement algorithm may require substantial hardware
assistance. MAKE IT MORE SHORT
The Least Recently Used (LRU) policy replaces the page that hasn't been used for
the longest time. It tracks each page's last access time and selects the oldest for
replacement. While effective, LRU often requires significant hardware support.
Q15 Solve given problem using SJF and calculate AWT and ATT
Process Arrival Time (AT) Burst Time (BT) P0 0 10 P1 1 29 P2 2 3 P3 3
7 P4 4 12 give preemptive and non preemptivw
To solve the problem using Shortest Job First (SJF) scheduling for both preemptive
(Shortest Remaining Time First, SRTF) and non-preemptive, we need to calculate
the waiting time and turnaround time for each process and then find the average
waiting time (AWT) and average turnaround time (ATT).
Given:
P0 0 10
P1 1 29
P2 2 3
P3 3 7
P4 4 12
In preemptive SJF, we always choose the process with the shortest remaining time.
Execution Order:
1. P0 runs from 0 to 1.
2. P2 arrives and runs from 2 to 5 (shortest at that time).
3. P3 runs from 5 to 12.
2/8
4. P0 resumes and runs from 12 to 21.
5. P4 runs from 21 to 33.
6. P1 runs from 33 to 62.
Completion Times:
P0 21 21 - 0 = 21 21 - 10 = 11
P1 62 62 - 1 = 61 61 - 29 = 32
P2 5 5-2=3 3-3=0
P3 12 12 - 3 = 9 9-7=2
P4 33 33 - 4 = 29 29 - 12 = 17
AWT=511+32+0+2+17=562=12.4
Average Turnaround Time (ATT):
ATT=521+61+3+9+29=5123=24.6
Non-Preemptive SJF
Execution Order:
Completion Times:
P0 10 10 - 0 = 10 10 - 10 = 0
P1 61 61 - 1 = 60 60 - 29 = 31
P2 13 13 - 2 = 11 11 - 3 = 8
P3 20 20 - 3 = 17 17 - 7 = 10
3/8
Completion Turnaround Time (TT = Waiting Time (WT =
Process Time (CT) CT - AT) TT - BT)
P4 32 32 - 4 = 28 28 - 12 = 16
AWT=50+31+8+10+16=565=13.0
Average Turnaround Time (ATT):
ATT=510+60+11+17+28=5126=25.2
Summary:
Here's how the Gantt chart and detailed calculations for preemptive and non-
preemptive SJF scheduling would look:
| P0 | P2 | P3 | P0 | P4 | P1 |
0 2 5 12 21 33 62
4/8
Arrival Burst Turnaround
Time Time Completion Time (TT = CT - Waiting Time
Process (AT) (BT) Time (CT) AT) (WT = TT - BT)
P0 0 10 21 21 - 0 = 21 21 - 10 = 11
P1 1 29 62 62 - 1 = 61 61 - 29 = 32
P2 2 3 5 5-2=3 3-3=0
P3 3 7 12 12 - 3 = 9 9-7=2
P4 4 12 33 33 - 4 = 29 29 - 12 = 17
AWT=511+32+0+2+17=562=12.4
Average Turnaround Time (ATT):
ATT=521+61+3+9+29=5123=24.6
| P0 | P2 | P3 | P4 | P1 |
0 10 13 20 32 61
Completion Times (CT), Turnaround Times (TT), and Waiting Times (WT):
P0 0 10 10 10 - 0 = 10 10 - 10 = 0
P2 2 3 13 13 - 2 = 11 11 - 3 = 8
P3 3 7 20 20 - 3 = 17 17 - 7 = 10
P4 4 12 32 32 - 4 = 28 28 - 12 = 16
P1 1 29 61 61 - 1 = 60 60 - 29 = 31
5/8
Average Waiting Time (AWT):
AWT=50+8+10+16+31=565=13
Average Turnaround Time (ATT):
ATT=510+11+17+28+60=5126=25.2
Summary:
Preemptive SJF AWT: 12.4, ATT: 24.6
Non-Preemptive SJF AWT: 13, ATT: 25.2
Here's the Gantt chart for both preemptive (SRTF) and non-preemptive SJF
scheduling:
| P0 | P2 | P3 | P0 | P4 | P1 |
0 2 5 12 21 33 62
Explanation:
6/8
| P0 | P2 | P3 | P4 | P1 |
0 10 13 20 32 61
Explanation:
P0 21 21 - 0 = 21 21 - 10 = 11
P1 62 62 - 1 = 61 61 - 29 = 32
P2 5 5-2=3 3-3=0
P3 12 12 - 3 = 9 9-7=2
P4 33 33 - 4 = 29 29 - 12 = 17
P0 10 10 - 0 = 10 10 - 10 = 0
P1 61 61 - 1 = 60 60 - 29 = 31
P2 13 13 - 2 = 11 11 - 3 = 8
P3 20 20 - 3 = 17 17 - 7 = 10
P4 32 32 - 4 = 28 28 - 12 = 16
7/8
Average Waiting Time (AWT) and Average Turnaround Time (ATT)
Preemptive SJF:
Non-Preemptive SJF:
AWT = (0 + 31 + 8 + 10 + 16) / 5 = 65 / 5 = 13
ATT = (10 + 60 + 11 + 17 + 28) / 5 = 126 / 5 = 25.2
These calculations show the process flow and timing under each SJF scheduling
type.
8/8