0% found this document useful (0 votes)
13 views34 pages

Operating Systems QA

Uploaded by

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

Operating Systems QA

Uploaded by

saranm19bct025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Consider three processes (process id 0, 1, 2 respectively) with the bursts time as 2, 4,

and 8 units respectively. All processes arrive at time zero. Compute the average
turnaround time with help of new proposed solution i.e. longest remaining time first
(LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process
with the lowest process id. [5 Marks]
• The Longest Remaining Time First (LRTF) scheduling algorithm prioritizes the process
with the longest remaining burst time. If two processes have the same burst time, the
process with the lowest process ID is chosen.
• Given Data:
• Process IDs: P0,P1,P2P_0, P_1, P_2P0​,P1​,P2​
• Burst times: P0=2,P1=4,P2=8P_0 = 2, P_1 = 4, P_2 = 8P0​=2,P1​=4,P2​=8
• Arrival times: P0=0,P1=0,P2=0P_0 = 0, P_1 = 0, P_2 = 0P0​=0,P1​=0,P2​=0
1
BITS Pilani, Pilani Campus
• Steps to Solve:
1. Initialize all processes in the ready queue at time t=0t = 0t=0.
2. Select the process with the longest remaining burst time at each time step.
3. Update remaining burst times after execution of the selected process.
4. Break ties based on the lowest process ID.
• Execution Timeline:
• Time 0–8: P2P_2P2​executes because it has the longest burst time (8 units).
• Remaining burst times: P0=2,P1=4,P2=0P_0 = 2, P_1 = 4, P_2 = 0P0​=2,P1​=4,P2​=0.
• Time 8–12: P1P_1P1​executes because it has the next longest burst time (4 units).
• Remaining burst times: P0=2,P1=0,P2=0P_0 = 2, P_1 = 0, P_2 = 0P0​=2,P1​=0,P2​=0.
• Time 12–14: P0P_0P0​executes because it has the shortest burst time (2 units).
• Remaining burst times: P0=0,P1=0,P2=0P_0 = 0, P_1 = 0, P_2 = 0P0​=0,P1​=0,P2​=0.
2
BITS Pilani, Pilani Campus
• Turnaround Times (TAT):
• The turnaround time is calculated as:
• TAT=Completion Time−Arrival Time\text{TAT} = \text{Completion Time} - \text{Arrival
Time}TAT=Completion Time−Arrival TimeP0P_0P0​: Completion time = 14, TAT = 14−0=1414 - 0 =
1414−0=14
• P1P_1P1​: Completion time = 12, TAT = 12−0=1212 - 0 = 1212−0=12
• P2P_2P2​: Completion time = 8, TAT = 8−0=88 - 0 = 88−0=8
• Average Turnaround Time:
• Average TAT=TAT(P0)+TAT(P1)+TAT(P2)3\text{Average TAT} = \frac{\text{TAT}(P_0) + \text{TAT}(P_1)
+ \text{TAT}(P_2)}{3}Average TAT=3TAT(P0​)+TAT(P1​)+TAT(P2​)​Average TAT=14+12+83=343≈11.33
units\text{Average TAT} = \frac{14 + 12 + 8}{3} = \frac{34}{3} \approx 11.33 \, \
text{units}Average TAT=314+12+8​=334​≈11.33unitsFinal Answer:
• The average turnaround time is approximately 11.33 units.
3
BITS Pilani, Pilani Campus
• Assume that the following jobs are to be executed on a single processor system
----------------------- Job-Id CPU-BurstTime ----------------------- p 4 q 1 r 8 s 1 t 2
----------------------- The jobs are assumed to have arrived at time 0 and in the order p, q,
r, s, t. Calculate the departure time (completion time) for job p if scheduling is round
robin with one time slice. Also compute the average turnaround time. [5 Marks]
• Problem Setup:
• Jobs: p,q,r,s,tp, q, r, s, tp,q,r,s,t
• CPU Burst Times:
• p=4p = 4p=4, q=1q = 1q=1, r=8r = 8r=8, s=1s = 1s=1, t=2t = 2t=2
• Arrival Times: All arrive at t=0t = 0t=0
• Scheduling: Round Robin (RR) with a time slice of 1 unit.

4
BITS Pilani, Pilani Campus
• Step-by-Step Execution:
• Initial State:
• Ready Queue (at t=0t = 0t=0): [p,q,r,s,t][p, q, r, s, t][p,q,r,s,t]
• Time Execution:
• We execute each job in the order they arrive, giving each one a
time slice of 1 unit before moving to the next.

5
BITS Pilani, Pilani Campus
• Step-by-Step Execution:
• Initial State:
• Ready Queue (at t=0t = 0t=0): [p,q,r,s,t][p, q, r, s, t][p,q,r,s,t]
• Time Execution:
• We execute each job in the order they arrive, giving each one a time slice of 1 unit before
moving to the next.
• Completion Times:
• ppp: 11 units
• qqq: 2 units
• rrr: 15 units
• sss: 4 units
• ttt: 8 units
6
BITS Pilani, Pilani Campus
• Turnaround Times:
• Turnaround Time (TAT)=Completion Time−Arrival Time\text{Turnaround Time (TAT)} = \
text{Completion Time} - \text{Arrival
Time}Turnaround Time (TAT)=Completion Time−Arrival TimeTATp=11−0=11TAT_p = 11 - 0 =
11TATp​=11−0=11
• TATq=2−0=2TAT_q = 2 - 0 = 2TATq​=2−0=2
• TATr=15−0=15TAT_r = 15 - 0 = 15TATr​=15−0=15
• TATs=4−0=4TAT_s = 4 - 0 = 4TATs​=4−0=4
• TATt=8−0=8TAT_t = 8 - 0 = 8TATt​=8−0=8

7
BITS Pilani, Pilani Campus
• Average Turnaround Time:
• Average TAT=TATp+TATq+TATr+TATs+TATt5\text{Average TAT} = \
frac{TAT_p + TAT_q + TAT_r + TAT_s + TAT_t}{5}Average TAT=5TATp​
+TATq​+TATr​+TATs​+TATt​​Average TAT=11+2+15+4+85=405=8\text
• {Average TAT} = \frac{11 + 2 + 15 + 4 + 8}{5} = \frac{40}{5} =
8Average TAT=511+2+15+4+8​=540​=8
• Final Answers:
• Completion time for job ppp: 11 units.
• Average Turnaround Time: 8 units.
8
BITS Pilani, Pilani Campus
• 3. Differentiate between logical and physical address. [2 Marks]
• Logical Address:Generated by the CPU during program
execution.Acts as a virtual address used by programs.Translated
to a physical address by the Memory Management Unit
(MMU).Visible to the user/programmer.Depends on the CPU
and operating system.Physical Address:The actual location in
the memory hardware.Used by the hardware to access
data/instructions.Not visible to the user/programmer.Directly
depends on the memory hardware.
9
BITS Pilani, Pilani Campus
• 4. Let the page fault service time be 10ms in a computer with average
memory access time being 20ns. If one page fault is generated for every
106 memory accesses, what is the effective access time for the memory?
[3 Marks]

• To calculate the Effective Access Time (EAT) for memory, we use the
formula:
• EAT=(1−P)×MAT+P×Page Fault Service Time\text{EAT} = (1 - P) \times \
text{MAT} + P \times \text{Page Fault Service
Time}EAT=(1−P)×MAT+P×Page Fault Service Time
10
BITS Pilani, Pilani Campus
• Where:
• PPP = Probability of a page fault = 1106\frac{1}{10^6}1061​
• MAT\text{MAT}MAT = Memory Access Time = 20 ns20 \, \text{ns}20ns
• Page Fault Service Time\text{Page Fault Service
Time}Page Fault Service Time = 10 ms=10,000,000 ns10 \, \text{ms} =
10,000,000 \, \text{ns}10ms=10,000,000ns
• Substituting values:
• EAT=(1−1106)×20 ns+1106×10,000,000 ns\text{EAT} = \left(1 - \frac{1}
{10^6}\right) \times 20 \, \text{ns} + \frac{1}{10^6} \times 10,000,000 \, \
text{ns}EAT=(1−1061​)×20ns+1061​×10,000,000ns
11
BITS Pilani, Pilani Campus
• Step 1: Simplify the first term:
• (1−1106)×20 ns=20 ns−20106 ns=20 ns−0.00002 ns\left(1 - \frac{1}{10^6}\right) \times 20
\, \text{ns} = 20 \, \text{ns} - \frac{20}{10^6} \, \text{ns} = 20 \, \text{ns} - 0.00002 \, \
text{ns}(1−1061​)×20ns=20ns−10620​ns=20ns−0.00002nsStep 2: Simplify the second term:
• 1106×10,000,000 ns=10 ns\frac{1}{10^6} \times 10,000,000 \, \text{ns} = 10 \, \
text{ns}1061​×10,000,000ns=10nsStep 3: Add the terms:
• EAT=(20−0.00002) ns+10 ns=30−0.00002 ns\text{EAT} = (20 - 0.00002) \, \text{ns} + 10 \, \
text{ns} = 30 - 0.00002 \, \text{ns}EAT=(20−0.00002)ns+10ns=30−0.00002nsFinal Result:
• EAT≈30 ns (rounded to significant figures for practical use).\text{EAT} \approx 30 \, \
text{ns} \, \text{(rounded to significant figures for practical
use)}.EAT≈30ns(rounded to significant figures for practical use).

12
BITS Pilani, Pilani Campus
• 5. Draw Resource Allocation Graph for the system described in the following Table.
Current Allocation Request Available R1 R2 R3 R1 R2 R3 R1 R2 R3 P1 2 0 0 1 0 0 0 2 0 P2
1 2 0 0 0 1 P3 0 1 1 0 0 0 P4 0 0 1 0 0 1 Also, determine the max matrix content, and
check whether the system is in safe state or not. [8 Marks]
• Step 1: Understanding the Resource Allocation Graph (RAG)
• A Resource Allocation Graph (RAG) represents the allocation and request of resources
by processes in a system.
• Nodes: Processes (P1,P2,P3,P4P1, P2, P3, P4P1,P2,P3,P4) and Resources (R1,R2,R3R1,
R2, R3R1,R2,R3).
• Edges:
• Request Edge: From process Pi​​to resource Rj​, indicating PiP_iPi​is requesting RjR_jRj​.
• Allocation Edge: From resource RjR_jRj​to process PiP_iPi​, indicating RjR_jRj​is allocated to PiP_iPi​.
13
BITS Pilani, Pilani Campus
• Step 2: Constructing the RAG
• Using the given table:
• Initial Allocations:
• P1P1P1 holds 2 units of R1R1R1.
• P2P2P2 holds 1 unit of R1R1R1 and 2 units of R2R2R2.
• P3P3P3 holds 1 unit of R2R2R2 and 1 unit of R3R3R3.
• P4P4P4 holds 1 unit of R3R3R3.
• Requests:
• P1P1P1 requests 1 unit of R1R1R1.
• P2P2P2 requests 1 unit of R3R3R3.
• P4P4P4 requests 1 unit of R3R3R3.
• Available Resources:
• R1R1R1: 0, R2R2R2: 2, R3R3R3: 0.
14
BITS Pilani, Pilani Campus
• Step 3: Determine the Max Matrix Content
• The Max Matrix indicates the maximum resources each process may request during its
execution. It is calculated as follows:
• Max=Current Allocation+Request\text{Max} = \text{Current Allocation} + \
text{Request}Max=Current Allocation+Request
• Step 4: Check for Safe State
• To determine if the system is in a safe state:
1. Work and Finish Initialization:
1. Work = Available = [0,2,0][0, 2, 0][0,2,0]
2. Finish = [False,False,False,False][False, False, False, False][False,False,False,False]
2. Safe Sequence Check (Banker's Algorithm):
1. Identify processes that can complete (Request ≤ Work).
15
BITS Pilani, Pilani Campus
• Iteration 1:
• P2P2P2 can execute since its Request [0,0,1][0, 0, 1][0,0,1] ≤ Work [0,2,0][0, 2, 0]
[0,2,0].
• After P2P2P2 finishes, Work becomes [1,4,0][1, 4, 0][1,4,0] (Work + Allocation of
P2P2P2).
• Finish = [False,True,False,False][False, True, False, False][False,True,False,False].
• Iteration 2:
• P3P3P3 can execute since its Request [0,0,0][0, 0, 0][0,0,0] ≤ Work [1,4,0][1, 4, 0]
[1,4,0].
• After P3P3P3 finishes, Work becomes [1,5,1][1, 5, 1][1,5,1].
• Finish = [False,True,True,False][False, True, True, False][False,True,True,False].
16
BITS Pilani, Pilani Campus
• Iteration 3:
• P1P1P1 can execute since its Request [1,0,0][1, 0, 0][1,0,0] ≤ Work [1,5,1][1,
5, 1][1,5,1].
• After P1P1P1 finishes, Work becomes [3,5,1][3, 5, 1][3,5,1].
• Finish = [True,True,True,False][True, True, True, False][True,True,True,False].
• Iteration 4:
• P4P4P4 can execute since its Request [0,0,1][0, 0, 1][0,0,1] ≤ Work [3,5,1][3,
5, 1][3,5,1].
• After P4P4P4 finishes, Work becomes [3,5,2][3, 5, 2][3,5,2].
• Finish = [True,True,True,True][True, True, True, True][True,True,True,True].
17
BITS Pilani, Pilani Campus
• 6. A uni-processor computer system only has two processes, both of which alternate 10ms CPU
bursts with 90ms I/O bursts. Both the processes were created at nearly the same time. The I/O of
both processes can proceed in parallel. Which of the following scheduling strategies will result in
the least CPU utilization (over a long period of time) for this system? First come first served
scheduling a) Shortest remaining time first scheduling b) Static priority scheduling with different
priorities for the two processes c) Round robin scheduling with a time quantum of 5ms. [6 Marks]
• To determine the scheduling strategy that results in the least CPU utilization, let’s analyze each
option considering the behavior of the processes:
• Key Points
• Two processes alternate between 10 ms CPU bursts and 90 ms I/O bursts.
• I/O operations can proceed in parallel, meaning while one process is doing I/O, the CPU can be
idle or execute the other process.
• CPU Utilization depends on the amount of CPU idle time.
18
BITS Pilani, Pilani Campus
• Analysis of Scheduling Strategies
1. First-Come-First-Served (FCFS) Scheduling:
1. Process 1 executes its 10 ms CPU burst first, then goes for a 90 ms I/O burst.
2. During Process 1’s I/O, Process 2 executes its 10 ms CPU burst.
3. This creates a back-and-forth pattern where the CPU is always active, except for a
negligible startup period.
4. CPU Utilization: High.
2. Shortest Remaining Time First (SRTF) Scheduling:
1. Both processes have the same CPU burst duration (10 ms), so there’s no preemption.
2. The behavior will mimic FCFS, where the CPU alternates between the two processes'
bursts without being idle.
3. CPU Utilization: High (similar to FCFS).
19
BITS Pilani, Pilani Campus
• Static Priority Scheduling:Assume Process 1 has a higher priority than
Process 2.Process 1 executes its 10 ms burst first, then performs I/O.If
Process 2 starts its CPU burst, it could be preempted if Process 1 returns
from I/O.However, since the bursts are non-overlapping, there is no
significant CPU idle time.CPU Utilization: High.Round-Robin (RR) Scheduling
with 5 ms Quantum:Each process gets 5 ms of CPU time before being
preempted.Process 1 executes 5 ms, then Process 2 executes 5 ms, and
then Process 1 completes its remaining 5 ms, followed by Process 2
completing its remaining 5 ms.This frequent switching introduces significant
context-switching overhead, leading to lower effective CPU utilization.CPU
Utilization: Lowest due to context-switching overhead.
20
BITS Pilani, Pilani Campus
• 7. Consider a disk with 1000 tracks i.e. 0 to 999 and the queue has random
requests from different processes in the order:
• 67, 58, 43, 14,31, 99, 178, 265, 38, 115, 55, 121, 184
• Currently the arm is at 100 and previous served track was 161. Find the seek length
and Average Seek length using FCFS, SSTF, SCAN and C-SCAN algorithm. [15
Marks]
• solve this problem, we will calculate the seek length and average seek length for the
given disk scheduling algorithms: FCFS, SSTF, SCAN, and C-SCAN.Problem DetailsDisk
Tracks: 0 to 999.Queue of Requests:
67,58,43,14,31,99,178,265,38,115,55,121,18467,58,43,14,31,99,178,265,38,115,55,
121,184.Current Head Position: 100100.Previous Head Position: 161161 (used for
SCAN and C-SCAN to determine direction).
21
BITS Pilani, Pilani Campus
• Step 1: FCFS (First-Come, First-Served)
• FCFS processes requests in the order they appear in the queue.
• Calculation:
1. Initial position: 100100100.
2. Sequence: 67,58,43,14,31,99,178,265,38,115,55,121,18467, 58, 43, 14, 31, 99, 178, 265, 38, 115, 55, 121,
18467,58,43,14,31,99,178,265,38,115,55,121,184.
3. Seek distances:
1. ∣100−67∣=33|100 - 67| = 33∣100−67∣=33
2. ∣67−58∣=9|67 - 58| = 9∣67−58∣=9
3. ∣58−43∣=15|58 - 43| = 15∣58−43∣=15
4. ∣43−14∣=29|43 - 14| = 29∣43−14∣=29
5. ∣14−31∣=17|14 - 31| = 17∣14−31∣=17
6. ∣31−99∣=68|31 - 99| = 68∣31−99∣=68
7. ∣99−178∣=79|99 - 178| = 79∣99−178∣=79
8. ∣178−265∣=87|178 - 265| = 87∣178−265∣=87
9. ∣265−38∣=227|265 - 38| = 227∣265−38∣=227
22
BITS Pilani, Pilani Campus
• ∣38−115∣=77∣115−55∣=60∣115−55∣=60∣55−121∣=66∣55−12
1∣=66∣121−184∣=63∣121−184∣=63.Total Seek
Length:33+9+15+29+17+68+79+87+227+77+60+66+63=83033+
9+15+29+17+68+79+87+227+77+60+66+63=830Average Seek
Length:Average=83013≈63.85Average= 13830​≈63.85Step 2:
SSTF (Shortest Seek Time First)SSTF always processes the
request closest to the current head position.Calculation:Start
at 100100.Process the closest request iteratively:

23
BITS Pilani, Pilani Campus
• Total Seek Length:
• 1+16+6+63+6+87+198+9+3+12+5+7+17=4301 + 16 + 6 + 63 + 6 + 87 + 198 + 9 +
3 + 12 + 5 + 7 + 17 = 4301+16+6+63+6+87+198+9+3+12+5+7+17=430Average
Seek Length:
• Average=43013≈33.08\text{Average} = \frac{430}{13} \approx
33.08Average=13430​≈33.08
• Step 3: SCAN (Elevator Algorithm)
• SCAN moves the head in one direction (toward 0 or 999) and services requests
until it reaches the end. Then, it reverses direction.
• Previous position 161>100161 > 100161>100, so the direction is downward
toward 0.
24
BITS Pilani, Pilani Campus
• Order of Processing:
• 100→99→67→58→55→43→38→31→14→0→115→121→178→184→265100 \to 99 \to 67 \
to 58 \to 55 \to 43 \to 38 \to 31 \to 14 \to 0 \to 115 \to 121 \to 178 \to 184 \to
265100→99→67→58→55→43→38→31→14→0→115→121→178→184→265Seek Distances:
• ∣100−99∣+∣99−67∣+∣67−58∣+∣58−55∣+∣55−43∣+∣43−38∣+∣38−31∣+ ∣31−14 ∣+ ∣14−0 ∣+ ∣0−1
15∣+∣115−121∣+∣121−178∣+∣178−184∣+∣184−265∣|100 - 99| + |99 - 67| + |67 - 58| + |58 -
55| + |55 - 43| + |43 - 38| + |38 - 31| + |31 - 14| + |14 - 0| + |0 - 115| + |115 - 121| + |121 -
178| + |178 - 184| + |184 - 265|
∣100−99∣+∣99−67∣+∣67−58∣+∣58−55∣+∣55−43∣+∣43−38∣+∣38−31 ∣+ ∣31−14 ∣+ ∣14−0 ∣+ ∣0−1
15∣+∣115−121∣+∣121−178∣+∣178−184∣+∣184−265∣
1+32+9+3+12+5+7+17+14+115+6+57+6+81=3871 + 32 + 9 + 3 + 12 + 5 + 7 + 17 + 14 + 115 + 6 +
57 + 6 + 81 = 3871+32+9+3+12+5+7+17+14+115+6+57+6+81=387Average Seek Length:
• Average=38713≈29.77\text{Average} = \frac{387}{13} \approx 29.77Average=13387​≈29.77
25
BITS Pilani, Pilani Campus
• Step 4: C-SCAN (Circular SCAN)
• C-SCAN moves in one direction (toward 0 or 999) and jumps to the
other end without servicing in reverse.
• Direction: downward toward 0, then jumps to 999.
• Order of Processing:
• 100→99→67→58→55→43→38→31→14→0→999→115→121→178→
184→265100 \to 99 \to 67 \to 58 \to 55 \to 43 \to 38 \to 31 \to 14 \to
0 \to 999 \to 115 \to 121 \to 178 \to 184 \to
265100→99→67→58→55→43→38→31→14→0→999→115→121→1
78→184→265Seek Distances:
26
BITS Pilani, Pilani Campus
• Seek Distances:
• ∣100−99∣+∣99−67∣+∣67−58∣+∣58−55∣+∣55−43∣+∣43−38∣+∣38−31∣+∣31−14∣+∣14−
0∣+∣0−999∣+∣999−115∣+∣115−121∣+∣121−178∣+∣178−184∣+∣184−265∣|100 - 99|
+ |99 - 67| + |67 - 58| + |58 - 55| + |55 - 43| + |43 - 38| + |38 - 31| + |31 - 14| + |14
- 0| + |0 - 999| + |999 - 115| + |115 - 121| + |121 - 178| + |178 - 184| + |184 - 265|
∣100−99∣+∣99−67∣+∣67−58∣+∣58−55∣+∣55−43∣+∣43−38∣+∣38−31∣+∣31−14∣+∣14−
0∣+∣0−999∣+∣999−115∣+∣115−121∣+∣121−178∣+∣178−184∣+∣184−265∣
1+32+9+3+12+5+7+17+14+999+884+6+57+6+81=21231 + 32 + 9 + 3 + 12 + 5 + 7 + 17
+ 14 + 999 + 884 + 6 + 57 + 6 + 81 =
21231+32+9+3+12+5+7+17+14+999+884+6+57+6+81=2123Average Seek Length:
• Average=212313≈163.31\text{Average} = \frac{2123}{13} \approx
163.31Average=132123​≈163.31
27
BITS Pilani, Pilani Campus
28
BITS Pilani, Pilani Campus
• 8. A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4V (signal)
operations were completed on this semaphore. The resulting value of the semaphore is?
• [2 Marks]

value, the number of 𝑃P (wait) operations, and 𝑉V (signal) operations.Given:Initial value of the
• ChatGPT said:ChatGPTThe value of the counting semaphore is calculated based on the initial

semaphore: 1010.Number of 𝑃P (wait) operations: 66. Each 𝑃P operation decrements the


semaphore by 11.Number of 𝑉V (signal) operations: 44. Each 𝑉V operation increments the
semaphore by 11.
• Calculation:
• Final Value=Initial Value−(Number of P)+(Number of V)\text{Final Value} = \text{Initial Value} - (\
text{Number of } P) + (\text{Number of } V)Final Value=Initial Value−(Number of P)+(Number of V)
Final Value=10−6+4=8\text{Final Value} = 10 - 6 + 4 = 8Final Value=10−6+4=8Result:
• The resulting value of the semaphore is 8.

29
BITS Pilani, Pilani Campus
• 9. What is the cause of thrashing? How does the system detect
thrashing? Once it detects thrashing, what can the system do to
eliminate this problem? [4 Marks] of
Thrashing:Thrashing occurs when a system spends more time swapping
pages in and out of memory than executing processes. The main causes
are:High Degree of Multiprogramming: Too many processes are loaded
into memory, leading to insufficient frames for each process.Frequent
Page Faults: Processes repeatedly require pages that are not in memory,
causing excessive swapping.Inadequate Allocation: Memory allocation
does not meet the working set requirements of the processes.
30
BITS Pilani, Pilani Campus
• Detection of Thrashing:
• The system detects thrashing using the following indicators:
1. High Page-Fault Rate: A sudden increase in page-fault rate
indicates processes frequently require non-resident pages.
2. Low CPU Utilization: The CPU remains underutilized because
most of the time is spent handling I/O for swapping.
3. Working Set Analysis: If the combined working set size of all
processes exceeds the available physical memory, thrashing is
likely.
31
BITS Pilani, Pilani Campus
• Steps to Eliminate Thrashing:Reduce Degree of
Multiprogramming:
• Suspend or swap out some processes to ensure that the
remaining processes have enough frames to execute efficiently.
• Use Working Set Model:Allocate enough frames to each process
based on its working set size, ensuring that all frequently
accessed pages are in memory.
• Increase Physical Memory:Adding more RAM reduces
contention for memory and decreases page faults.
32
BITS Pilani, Pilani Campus
• Page Replacement Policy:Use intelligent algorithms (e.g., LRU or
Working Set) to prevent unnecessary evictions of frequently used
pages.Adjust Process Priorities:Prioritize critical processes to
ensure their memory demands are met, preventing resource
contention.Summary:Thrashing is caused by excessive swapping
due to insufficient memory allocation. It is detected by monitoring
page-fault rates, CPU utilization, and working set sizes. To eliminate
thrashing, reduce multiprogramming, use the working set model,
increase memory, or optimize page replacement policies.

33
BITS Pilani, Pilani Campus
34
BITS Pilani, Pilani Campus

You might also like