Memory Management

Behind the curtain

Nathan Tenney

WSU Tri-Cities

Memory Management

Overview

Terms

Sequential Fit Algorithms

Sequential Fit Algorithms

Sequential Fit Algorithms

image

Adaptive Exact Fit

Adaptive Exact Fit

image

Binary Buddy System

Binary Buddy System

Binary Buddy System

Binary Buddy System

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
size of memory = 2^m for some m
avail[i] = -1 for i = 0,...,m-1
avail[m] = first address in memory
reserve(reqSize):
  roundedSize = ceil( lg( reqSize))
  availSize = min(roundedSize,...,m) for which avail[availSize] > -1
  if nosuch availSize exists:
    failure!
  block = avail[availSize]
  detach block from list avail[availSize]
  while (roundedSize < availSize): // While available block is too large, split it
    availSize--
    block = left half of block
    insert buddy of block in list avail[availSize]
  return block

Binary Buddy System

image

Binary Buddy System

Binary Buddy System

image

Garbage Collection

Garbage Collection

Garbage Collection

Garbage Collection

Mark and Sweep

Mark and Sweep

Mark and Sweep

Mark and Sweep

sweep():
  for each location from the last to the first:
    if mark(location) is 0:
      insert location in front of availList
    else:
      set mark(location) to 0

Mark and Sweep

Mark and Sweep

Stop and Copy

Stop and Copy

Stop and Copy

image

Tri-color Marking

Tri-color Marking

Tri-color Marking

Tri-color Marking

Garbage Collection