Multiple processes want to use the limited physical memory (RAM).
Goal:
Always stays in memory
Running program
Waiting or ready to run
Unused RAM available
๐ฑ Created by CPU
๐ What programmer sees (starts from 0)
๐ญ Example: 0, 1, 2, 3...
๐ Fake/Virtual address
๐ Actual location in RAM
๐ Hidden from programmer
๐งฎ Calculated using Base Register
โ Real memory address like 1000, 1001...
๐ ๏ธ MMU (Memory Management Unit) converts Logical โ Physical
Formula:
Example: Base = 1000, Logical = 25 โ Physical = 1025
Starting address in physical memory (e.g. 1000)
Total size allowed (e.g. 500 bytes)
Rule: CPU checks every memory access using:
If valid โก๏ธ Then: Physical = Base + Logical
// Memory Protection Check (hardware logic) if (logical_address >= limit_register) { TRAP_TO_OS(); // โ Illegal memory access! } else { physical_address = base_register + logical_address; }
Q: What if a process tries to access memory beyond its limit?
A: CPU generates a trap โก๏ธ OS catches it โก๏ธ Process is terminated โก๏ธ โSegmentation Faultโ
Process memory is in one continuous block
๐ Like parking in adjacent spots
Process memory is in scattered blocks
๐ Like parking in separate spots
Memory divided into fixed-size partitions at boot time
Partition size decided when process loads
after Complete the process, they live and hole is create,then allocate og hole is call free space management
Strategy: Pick first hole that fits
Speed: โก Fastest
Memory Use: ๐ก Average
Strategy: Pick smallest hole that fits
Speed: ๐ Slowest
Memory Use: ๐ข Best (less internal frag)
Strategy: Pick largest hole that fits
Speed: ๐ Slow
Memory Use: ๐ด Worst
Strategy: First fit, but start from last allocated
Speed: โก Fast
Memory Use: ๐ก Average
Q: "Which algorithm is best?"
A: "Depends on requirements. First Fit for speed, Best Fit for memory efficiency. Generally, First Fit and Best Fit are most commonly used."
Moving all allocated partitions together and all free space together
Q: "When should we do compaction?"
A: "When external fragmentation becomes severe and no free block can satisfy new requests, but total free space is sufficient."