0% found this document useful (0 votes)
1 views

chatgpt.com-Round Robin Scheduling Summary

The Round Robin (RR) scheduling algorithm allocates fixed CPU time slices to processes, allowing for preemption to ensure fairness and responsiveness in multitasking environments. The Least Recently Used (LRU) page replacement policy selects the page that hasn't been used for the longest time for replacement, often requiring significant hardware support. The document also details Shortest Job First (SJF) scheduling, providing calculations for average waiting time and turnaround time for both preemptive and non-preemptive scenarios.

Uploaded by

Nawaz Wariya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

chatgpt.com-Round Robin Scheduling Summary

The Round Robin (RR) scheduling algorithm allocates fixed CPU time slices to processes, allowing for preemption to ensure fairness and responsiveness in multitasking environments. The Least Recently Used (LRU) page replacement policy selects the page that hasn't been used for the longest time for replacement, often requiring significant hardware support. The document also details Shortest Job First (SJF) scheduling, providing calculations for average waiting time and turnaround time for both preemptive and non-preemptive scenarios.

Uploaded by

Nawaz Wariya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Round Robin Scheduling Summary

chatgpt.com/c/6730dbbc-b540-8010-b33f-103d4a415dd6

The Round Robin (RR) scheduling algorithm allocates CPU time to


each process for a short, fixed period called a time quantum or time
slice. When this time is up, if the process hasn't finished its task, it is
temporarily stopped (or preempted) and moved to the back of the ready
queue, allowing other processes to run. This method is similar to the
First-Come, First-Served (FCFS) approach, but with the added feature
of preemption to ensure fairness. There are two scenarios: if a process
finishes its work before the time quantum expires, it voluntarily releases
the CPU; but if it needs more time, an interrupt signals the operating
system, which pauses the current process, performs a context switch,
and lets the next process in the queue take its turn. This way, all
processes get a fair share of CPU time, improving responsiveness in a
multitasking environment. make it short

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:

Process Arrival Time (AT) Burst Time (BT)

P0 0 10

P1 1 29

P2 2 3

P3 3 7

P4 4 12

Preemptive SJF (SRTF)

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:

Completion Turnaround Time (TT = Waiting Time (WT =


Process Time (CT) CT - AT) TT - BT)

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

Average Waiting Time (AWT):

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

In non-preemptive SJF, a process runs to completion once started.

Execution Order:

1. P0 runs from 0 to 10.


2. P2 runs from 10 to 13 (shortest available after P0).
3. P3 runs from 13 to 20.
4. P4 runs from 20 to 32.
5. P1 runs from 32 to 61.

Completion Times:

Completion Turnaround Time (TT = Waiting Time (WT =


Process Time (CT) CT - AT) TT - BT)

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

Average Waiting Time (AWT):

AWT=50+31+8+10+16​=565​=13.0
Average Turnaround Time (ATT):

ATT=510+60+11+17+28​=5126​=25.2

Summary:

Preemptive SJF (SRTF):


AWT = 12.4
ATT = 24.6
Non-Preemptive SJF:
AWT = 13.0
ATT = 25.2

givee gantt chart also

Here's how the Gantt chart and detailed calculations for preemptive and non-
preemptive SJF scheduling would look:

Gantt Chart for Preemptive SJF (Shortest Remaining Time First)

| P0 | P2 | P3 | P0 | P4 | P1 |
0 2 5 12 21 33 62

Preemptive SJF Calculations


Completion Times (CT), Turnaround Times (TT), and Waiting Times (WT):

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

Average Waiting Time (AWT):

AWT=511+32+0+2+17​=562​=12.4
Average Turnaround Time (ATT):

ATT=521+61+3+9+29​=5123​=24.6

Gantt Chart for Non-Preemptive SJF

| P0 | P2 | P3 | P4 | P1 |
0 10 13 20 32 61

Non-Preemptive SJF Calculations

Completion Times (CT), Turnaround Times (TT), and Waiting Times (WT):

Arrival Burst Turnaround


Time Time Completion Time (TT = CT - Waiting Time
Process (AT) (BT) Time (CT) AT) (WT = TT - BT)

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

give a perfect gantt chart

Here's the Gantt chart for both preemptive (SRTF) and non-preemptive SJF
scheduling:

1. Preemptive SJF (SRTF) Gantt Chart

| P0 | P2 | P3 | P0 | P4 | P1 |
0 2 5 12 21 33 62

Explanation:

P0 starts at time 0 but is preempted at time 2 when P2 arrives.


P2 runs from 2 to 5 (finishes at 5).
P3 runs from 5 to 12 (finishes at 12).
P0 resumes at 12 and runs until it finishes at 21.
P4 runs from 21 to 33.
P1 runs last from 33 to 62.

2. Non-Preemptive SJF Gantt Chart

6/8
| P0 | P2 | P3 | P4 | P1 |
0 10 13 20 32 61

Explanation:

P0 runs first from 0 to 10.


P2 starts at 10 (next shortest job) and runs until 13.
P3 runs from 13 to 20.
P4 runs from 20 to 32.
P1 runs from 32 to 61.

Calculations for Both Schedules

Preemptive SJF Completion Times:

Completion Turnaround Time (TT = Waiting Time (WT =


Process Time (CT) CT - AT) TT - BT)

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

Non-Preemptive SJF Completion Times:

Completion Turnaround Time (TT = Waiting Time (WT =


Process Time (CT) CT - AT) TT - BT)

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:

AWT = (11 + 32 + 0 + 2 + 17) / 5 = 62 / 5 = 12.4


ATT = (21 + 61 + 3 + 9 + 29) / 5 = 123 / 5 = 24.6

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.

ChatGPT can make mistakes. Check important info.

8/8

You might also like