1. LPU MCA Semester 1
  2. CAP366
  3. Unit 7

CAP366 · Unit 7: Memory management

Allocation of frames, thrashing and the working-set model

10 practice questions · in the ETE syllabus

Key points

  • Equal and proportional frame allocation
  • Thrashing: more time paging than executing
  • Working set = distinct pages in last Δ references
  • If total demand exceeds frames, suspend a process

Every process needs a minimum number of frames, set by the instruction set architecture. Allocation schemes: equal (m frames among n processes, m/n each) and proportional (in proportion to process size, a_i = s_i / S x m). Example: 62 frames shared by processes of 10 and 127 pages give about 4 and 57 frames. Replacement can be global (a victim from any process) or local (a victim from the faulting process only).

Thrashing occurs when a process spends more time paging than executing because it lacks enough frames. CPU utilisation drops, so the scheduler may admit more processes, which makes it worse.

The working-set model uses a window of the most recent Δ page references; the set of distinct pages in it is the working set, an approximation of the process's current locality. If the total demand D = sum of working-set sizes exceeds the number of frames m, thrashing is likely and a process should be suspended. If Δ is too small it misses part of the locality; if too large it spans several localities and over-estimates the need.

An alternative is page-fault frequency (PFF): increase frames when the fault rate exceeds an upper bound, reduce them below a lower bound.

Exam trap: low CPU utilisation caused by thrashing is cured by lowering, not raising, the degree of multiprogramming.

Try two questions

Question 1 · Tier 4, Analyse

The working-set sizes of four processes are 20, 35, 15 and 40 frames, and the system has 100 frames. What is the conclusion?

  1. The total demand of 90 is below 100 frames, so all four processes fit
  2. The total demand of 110 is high, so the system should admit more processes
  3. The total demand of 110 exceeds 100 frames, so a process should be suspended
  4. The total demand of 100 fills memory exactly, so nothing needs to change
Show the answer

C. The total working set demand is 110, which exceeds the 100 available frames, so thrashing is likely and a process should be suspended.

Why not A: The sum is 110, not 90, so the demand exceeds the frames.

Why not B: Admitting more processes would deepen the shortage of frames.

Why not D: The sum is 110, not 100, so memory is over-committed.

Question 2 · Tier 3, Apply

93 free frames are shared equally among 5 processes. How many frames does each process get and what happens to the remainder?

  1. 19 frames each, using 95 frames in total
  2. 15 frames each, with 18 left in the free pool
  3. 17 frames each, with 8 left in the free pool
  4. 18 frames each, with 3 left in the free pool
Show the answer

D. 93 divided by 5 is 18 remainder 3, so 18 frames each with 3 frames left in the free pool.

Why not A: Five times 19 is 95, which exceeds the 93 frames available.

Why not B: The equal share is 93 divided by 5 rounded down, which is 18, not 15.

Why not C: The equal share is 18, not 17; 93 divided by 5 is 18 remainder 3.