Unit 4 of 4 · BCA Sem 2

Unit 4: Memory and I/O management

Operating Systems notes · PTU syllabus (UGCC2508)

3 min read5 topics10 exam questions
On this page
  1. Unit summary
  2. Logical and physical addresses, swapping
  3. Contiguous allocation: MFT and MVT
  4. Paging and segmentation
  5. Virtual memory, page replacement and thrashing
  6. I/O hardware and disk scheduling
  7. Key terms
  8. Quick revision
  9. Important questions

Unit summary

Memory management decides how programs are placed in main memory, and I/O management controls devices and disks. This unit covers address binding, swapping, contiguous allocation (MFT and MVT), fragmentation, paging, segmentation, virtual memory with demand paging and page replacement, thrashing, and disk scheduling.

After this unit you can

  • Distinguish logical and physical addresses and explain swapping
  • Compare MFT and MVT and internal and external fragmentation
  • Explain paging, segmentation and demand paging
  • Solve page replacement and disk scheduling problems

PTU syllabus topics

  • Logical and physical address mapping
  • swapping
  • memory allocation
  • MFT/MVT
  • internal/external fragmentation and compaction
  • paging
  • segmentation
  • demand paging
  • page replacement algorithms
  • frame allocation
  • thrashing
  • I/O hardware principles
  • disk structure and scheduling algorithms
ComparisonPaging vs segmentation
Paging
Segmentation

Division

Fixed-size pages and frames

Variable-size logical segments

Fragmentation

Internal

External

Programmer view

Invisible to the programmer

Matches program structure (code, data, stack)

Address

Page number + offset

Segment number + offset

1

Topic 1

Logical and physical addresses, swapping

A logical address is generated by the CPU; a physical address is the actual location in memory. The Memory Management Unit (MMU) maps logical to physical addresses at run time, for example by adding a relocation (base) register value. Swapping temporarily moves a process from memory to disk (backing store) and back, so that more processes can run than fit in memory at once.

2

Topic 2

Contiguous allocation: MFT and MVT

ComparisonMFT vs MVT
MFT (fixed partitions)
MVT (variable partitions)

Partitions

Memory divided into fixed-size parts in advance

Created to fit each process as it arrives

Fragmentation

Internal

External

Degree of multiprogramming

Limited by the number of partitions

Flexible

Placement strategies for variable partitions: first fit (first hole big enough — fast), best fit (smallest hole big enough — least leftover), worst fit (largest hole).

  • Internal fragmentation: wasted space inside an allocated partition.
  • External fragmentation: enough total free memory exists, but not in one contiguous block. Compaction shuffles processes together to create one large free block.
3

Topic 3

Paging and segmentation

Paging divides logical memory into fixed-size pages and physical memory into frames of the same size. A page table maps each page to a frame, so a process need not be contiguous. Paging removes external fragmentation.

  • Logical address = (page number p, offset d); physical address = frame number × page size + d.

Segmentation divides a program into variable-size logical segments (code, data, stack). A segment table stores each segment's base and limit.

ComparisonPaging vs segmentation
Paging
Segmentation

Unit

Fixed-size pages

Variable-size segments

View

Physical, invisible to the programmer

Logical, matches program structure

Fragmentation

Internal (last page)

External

Table

Page table

Segment table with base and limit

4

Topic 4

Virtual memory, page replacement and thrashing

Virtual memory lets a process run even if only part of it is in memory. Demand paging loads a page only when it is needed; accessing a page not in memory causes a page fault.

ComparisonPage replacement algorithms
Replaces
Note

FIFO

The oldest page in memory

Simple; Belady's anomaly possible

Optimal

The page not needed for the longest time

Lowest faults; needs future knowledge

LRU

The least recently used page

Good approximation of optimal

Example

Reference string 7, 0, 1, 2, 0, 3, 0, 4 with 3 frames under FIFO gives 7 page faults: 7, 0, 1, 2, 3, 0, 4 (only the 5th reference, 0, is a hit).

Frame allocation can be equal or proportional to process size. Thrashing happens when processes have too few frames and spend more time paging than executing; it is controlled with the working-set model or by reducing multiprogramming.

5

Topic 5

I/O hardware and disk scheduling

I/O devices connect through controllers; data moves by programmed I/O, interrupts or DMA. A disk has platters, tracks, sectors and cylinders; access time = seek time + rotational latency + transfer time. Disk scheduling reduces seek time.

AlgorithmHow it moves the head
FCFSServes requests in arrival order
SSTFServes the nearest request next (may starve far ones)
SCAN (elevator)Moves end to end, serving requests on the way
C-SCANServes in one direction only, then jumps back
LOOK / C-LOOKLike SCAN / C-SCAN but turns at the last request

Exam tip

For disk problems, draw the head movement on a number line and add up every cylinder moved.

Key terms

Logical address
An address generated by the CPU
Page fault
An access to a page not currently in memory
Fragmentation
Wasted memory, internal or external
Thrashing
Excessive paging that stops useful work
Seek time
Time to move the disk head to the required track

Quick revision

  • MMU maps logical to physical addresses.
  • MFT → internal fragmentation; MVT → external; compaction fixes external.
  • Paging: fixed pages, no external fragmentation; segmentation: logical, variable segments.
  • FIFO, Optimal, LRU; Belady's anomaly in FIFO.
  • Disk scheduling: FCFS, SSTF, SCAN, C-SCAN, LOOK.

Important exam questions

Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).

Short-answer questions

  1. Q1.Differentiate between logical and physical addresses.
  2. Q2.What is swapping?
  3. Q3.Differentiate between internal and external fragmentation.
  4. Q4.What is a page fault?
  5. Q5.What is thrashing?
  6. Q6.What is Belady's anomaly?

Long-answer questions

  1. Q1.Explain paging with a diagram and compare it with segmentation.
  2. Q2.Explain contiguous memory allocation with first fit, best fit and worst fit.
  3. Q3.Solve a page replacement problem using FIFO, Optimal and LRU and compare page faults.
  4. Q4.Explain disk scheduling algorithms and calculate total head movement for a given request queue.

Stuck on this unit?

Message SBS on WhatsApp for help with Operating Systems, or to ask about studying BCA at Synetic.

WhatsApp us