contiguous memory

Work in Progress

Summary

Contiguous partitioning

FeatureFixed PartitioningDynamic Partitioning
Partition sizePredefined, equal (or fixed set of sizes)Created dynamically based on process size
Memory allocationOne process per partitionProcess gets exactly what it needs
Fragmentation typeInternal fragmentationExternal fragmentation
FlexibilityLowHigh
ComplexitySimpleMore complex
Utilization efficiencyPoor (wasted space inside partitions)Better, but degrades over time

Allocation algorithms

AlgorithmCore IdeaSearch StrategySpeedFragmentation BehaviorAdvantagesDisadvantages
first-fitallocate the first hole that is large enoughscan from beginning, pick first matchfastmoderate external fragmentation- low overhead
- quick allocation
- small holes near the beginning
best-fitallocate the smallest hole that fits the requestsearch entire listslowhigh external fragmentation (many tiny holes)- minimizes wasted space per allocation- expensive search
- unusable small fragments
worst-fitallocate the largest available holesearch entire listslowlower fragmentation initially, but inefficient use- leaves large holes for future allocations- poor overall utilization
- can waste large blocks

Concept

  • load-store memory model
  • assumes:
    • each process occupies a contiguous region
    • physical memory is large enough to containe 1 or more processes with complete memory space

Fixed partition

  • fixed number of partitions
  • each process occupies one partition
  • easy to manage and allocate
  • partition needs to be large enough to contain the largest of the processes
    • smaller processes will lead to wasted memory space -> internal fragmentation

Internal fragmentation

  • wasted memory inside the pertition

Dynamic partition

  • partition based on actual size of process
  • OS needs to keep track of occupied and free spaces(holes)
  • flexible
  • leads to large number of holes
    • smaller holes cannot accommodate larger processes -> external fragmentation

External fragmentation

  • wasted memory outside the partition
  • holes that are too small

Partition info

  • linked list
  • store the starting physical address and the size of the partition
Initial:RunA&B:FreeA:F2563840T256512T7681024F17922304F256512T7681024F17922304

T - true for occupied, F - false for not occupied

Allocation algorithms

First-fit

  • take the first hole that is large enough
    Best-fit
  • take the smallest hole that is large enough
  • lead to small holes, hard to fit other processes
    Worst-fit
  • take the largest hole
  • created holes are larger, hopefully other processes can fit

Merge

  • join adjacent holes if possible

Compaction

  • move the occupied partitions arround to consolidate holes
  • less frequently used
    • time consuming -> OS will take up CPU time
    • moved processes have to pause
ProcessPerformance
Allocation
Deallocation or if base register is tracked in PCB
Merging