Operating Systems Level 8
PART 3 • MEMORY & STORAGE

Translate Every Address and Place Every Process Safely

Follow a program address from CPU to RAM, enforce protection with bounds, compare contiguous placement strategies and understand why paging removes external fragmentation.

Level 08 of 15 Intermediate 100–130 minutes Two interactive labs
BY THE END, YOU CAN

Reason about memory placement

  • Separate logical and physical addresses.
  • Explain compile-, load- and execution-time binding.
  • Translate base/limit and paged addresses.
  • Calculate internal and external fragmentation.
  • Compare paging with segmentation.
01 • FOLLOW THE ADDRESS LIFECYCLE

A Program Uses Addresses before It Knows Its Final RAM Location

Address binding maps program references to memory locations. The later binding occurs, the more freely the OS can move a process.

COMPILE TIME

Absolute code

If the final location is known, the compiler emits absolute addresses. Moving the program requires recompilation.

Least flexible
LOAD TIME

Relocatable code

The compiler leaves relative addresses; the loader selects a physical region and completes relocation.

Move before execution
EXECUTION TIME

Dynamic relocation

Hardware translates every reference while the program runs, allowing movement and virtual memory.

Most flexible; requires MMU support
CPU logical address MMU translation + protection Physical memory address
02 • INTERACTIVE ADDRESS TRANSLATION

Calculate the Address, Then Check Protection

Switch between base/limit relocation, paging and segmentation. Each mode shows the formula and rejects an invalid reference rather than silently translating it.

ADDRESS RESULT

Enter a logical address

The formula and protection decision will appear here.

03 • PLACE PROCESSES IN CONTIGUOUS MEMORY

One Process, One Continuous Physical Region

FIRST FIT

Take the first sufficient hole

Search from the beginning and stop immediately when a large enough hole appears.

Fast search; early memory may fragment
BEST FIT

Take the smallest sufficient hole

Search all suitable holes and leave the smallest immediate remainder.

May create many tiny unusable holes
WORST FIT

Take the largest hole

Preserve medium-size holes by splitting the largest available region.

Large holes disappear quickly

External fragmentation

Total free memory may be sufficient, but it is divided into non-contiguous holes and no single hole fits the request.

Compaction can combine holes, but moving memory costs time.

Internal fragmentation

An allocated fixed-size unit is larger than the request, so unused space remains inside the assigned region.

Paging can create waste in the final page/frame.
04 • INTERACTIVE PLACEMENT LAB

Compare First Fit, Best Fit and Worst Fit on the Same Holes

Choose a dataset, algorithm and process size. The lab highlights the selected hole and calculates the remaining holes.

PLACEMENT RESULT

Ready to allocate

Select an algorithm and process size.

05 • FIXED-SIZE TRANSLATION

Paging Separates Logical Pages from Physical Frames

LOGICAL ADDRESS
page number p offset d

p = floor(address / page size)
d = address mod page size

page table → frame f
PHYSICAL ADDRESS
frame number f same offset d

physical = f × frame size + d

No external fragmentation

A process’s frames need not be adjacent, so any free frame can hold any page.

Possible internal fragmentation

The last allocated page may not be completely used.

Page-table overhead

Each process needs mappings and metadata; large address spaces require structured page tables.

TLB acceleration

A Translation Lookaside Buffer caches recent page-table entries to reduce translation cost.

06 • VARIABLE-SIZE LOGICAL UNITS

Segmentation Matches the Program’s Own Structure

Segment 0 • code Segment 1 • data Segment 2 • heap Segment 3 • stack

Logical address = ⟨segment, offset⟩

The segment table stores a base and limit for each segment. If offset < limit, physical address = base + offset; otherwise the reference traps.

  • Natural protection per logical unit
  • Easy sharing of a code segment
  • Variable sizes cause external fragmentation
  • Segments can grow differently
07 • CHOOSE THE MODEL

Paging and Segmentation Solve Different Problems

Question Paging Segmentation
Unit size Fixed-size pages and frames Variable-size logical segments
Programmer view Usually transparent Matches code, data, stack and modules
Fragmentation Internal possible; no external External possible
Address parts Page number + offset Segment number + offset
Protection/sharing Per page Natural per logical segment
Modern use Dominant basis of virtual memory Ideas often combined with paging/protection regions
08 • CHECK YOUR UNDERSTANDING

Ten Misconception-Specific Checks

Each option explains the exact address or fragmentation error.

Answered correctly: 0 of 10
09 • EXPLAIN & PREPARE

University and Placement Questions

2-MARK QUESTIONS
  1. Logical versus physical address?
  2. Define relocation.
  3. Internal versus external fragmentation?
  4. What is a page table?
  5. What does a TLB store?
5-MARK QUESTIONS
  1. Explain address binding.
  2. Compare placement algorithms.
  3. Translate a paged address.
  4. Explain segmentation.
  5. Compare paging and segmentation.
INTERVIEW QUESTIONS
  1. Why does paging remove external fragmentation?
  2. Why is the offset preserved?
  3. Can paging waste memory?
  4. What happens on a TLB miss?
  5. Why use multi-level page tables?
Show a strong answer: “Paging address translation”
  1. Divide the logical address by page size to obtain page number and offset.
  2. Validate the page number and page-table entry.
  3. Read the frame number from the page table, possibly through the TLB.
  4. Combine frame number with the unchanged offset.
  5. Physical address = frame × frame size + offset.
LEVEL 8 SUMMARY

You Can Now Explain Where a Program Address Goes

  • Binding connects symbolic/logical references to physical placement.
  • Base and limit provide relocation plus bounds protection.
  • Contiguous allocation can suffer external fragmentation.
  • Paging maps fixed-size pages to frames and preserves the offset.
  • Segmentation represents variable-size logical program units.
COURSE CHECKPOINT

Mark Level 8 after you can translate one paged address and distinguish internal from external fragmentation.

Saved only in this browser.