Unit 3: Memory and device management
Operating Systems notes · PTU syllabus (BSIT303/BSBC403)
On this page
- Unit summary
- Address binding, relocation, loading and linking
- Logical and physical addresses and swapping
- Memory sharing and protection
- Paging and segmentation
- Virtual memory: demand paging, page replacement and thrashing
- I/O devices, controllers, device drivers and disk scheduling
- Key terms
- Quick revision
- Important questions
Unit summary
Memory and device management keep programs in memory and data flowing to and from devices. This unit covers address binding, relocation, loading and linking, memory sharing and protection, paging and segmentation, virtual memory — demand paging, performance, page replacement and thrashing — I/O devices and controllers, device drivers, and disk scheduling and management.
After this unit you can
- Explain address binding, relocation, loading and linking
- Explain paging and segmentation and memory protection
- Explain virtual memory, page replacement and thrashing
- Explain I/O devices, drivers and disk scheduling
PTU syllabus topics
- Address binding
- relocation
- loading
- linking
- memory sharing and protection
- paging and segmentation
- virtual memory (demand paging, performance, page replacement, thrashing)
- I/O devices and controllers
- device drivers
- disk scheduling and management
Divides memory into
Fixed-size pages and frames
Variable-size logical segments
Fragmentation
Internal
External
Programmer sees
One linear address space
Separate segments: code, data, stack
Table
Page table
Segment table
Topic 1
Address binding, relocation, loading and linking
- Address binding: mapping program addresses to memory addresses at compile time (absolute code), load time (relocatable code) or execution time (dynamic, using an MMU).
- Relocation: adjusting addresses when a program is loaded at a different location — relocation register adds a base value.
- Loading: static loading (whole program before execution) vs dynamic loading (routines loaded when called).
- Linking: static linking (libraries copied into the executable) vs dynamic linking (shared libraries — .dll, .so — linked at run time).
Topic 2
Logical and physical addresses and 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.
Topic 3
Memory sharing and protection
- Protection: base and limit registers, page-table protection bits (read, write, execute), valid–invalid bits.
- Sharing: shared pages for common code (reentrant code), shared memory segments for IPC.
Topic 4
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.
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
Topic 5
Virtual memory: demand paging, 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.
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.
Effective access time
(1 − p) × memory access time + p × page fault service time
Note
p = page fault rate; even a small p greatly increases access time
Topic 6
I/O devices, controllers, device drivers 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.
| Algorithm | How it moves the head |
|---|---|
| FCFS | Serves requests in arrival order |
| SSTF | Serves the nearest request next (may starve far ones) |
| SCAN (elevator) | Moves end to end, serving requests on the way |
| C-SCAN | Serves in one direction only, then jumps back |
| LOOK / C-LOOK | Like 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.
- Device driver: OS module that hides device details and translates generic I/O requests into device-specific commands.
- Disk management: formatting (low-level and logical), partitioning, boot block, bad-block handling, RAID for reliability and performance.
Key terms
- Address binding
- Mapping program addresses to physical addresses
- Dynamic linking
- Linking libraries at run time
- Page fault
- Reference to a page not in memory
- Thrashing
- Excessive paging reducing useful work
- Device driver
- Software controlling a specific device
Quick revision
- Compile, load, execution-time binding; relocation; static and dynamic loading and linking.
- Logical vs physical; swapping; MFT, MVT.
- Protection bits; shared pages; paging, segmentation, TLB.
- Demand paging; EAT; FIFO, LRU, optimal; Belady's anomaly; thrashing and working set.
- I/O controllers, drivers; FCFS, SSTF, SCAN, C-SCAN, LOOK; disk management.
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
- Q1.What is address binding?
- Q2.Distinguish static and dynamic linking.
- Q3.What is a page fault?
- Q4.State Belady's anomaly.
- Q5.What is thrashing?
- Q6.Name four disk scheduling algorithms.
Long-answer questions
- Q1.Explain address binding, relocation, loading and linking.
- Q2.Explain paging and segmentation with diagrams.
- Q3.Explain virtual memory and page replacement algorithms (numerical).
- Q4.Explain I/O devices, device drivers and disk scheduling (numerical).
Stuck on this unit?
Message SBS on WhatsApp for help with Operating Systems, or to ask about studying B.Sc IT at Synetic.
