• memory management
  • memory paging
  • memory management unit (MMU)
  • virutal memory
  • page replacement
    • local and global replacement
    • page replacement algorithm
      • theoretically optimal (OPT)
      • not recently used (NRU)
        • (referenced, modified)
        • (0,0), (0,1), (1,0), (1,1)
      • FIFO
      • Second-chance
      • least recently used (LRU)
        • Evict the page that has not been used for the longest time in the past. (“temporal locality”)
      • Clock
        • WSClock
      • not frequently used (NFU)
      • aging
      • working set
        • pages referenced by the most recent memory references up to time .
        • approximation for references:
          • pages referenced in the past time units of virtual time (the amount of CPU time a process actually uses) up to the current time .
        • algorithm:
          • in a page fault:
            • for each page in memory:
              • if , then set and
              • if
                • if , then evict the page
                • if , then keep the page
            • if no page is evicted, then evict the page with the largest age
            • if all pages have , then evict a page at random
    • page fault frequency (PFF)
    • reference string
      • is the number of frames allocated to the process
      • is the set of pages in memory after processing
    • distance string
        • if no such exists, then
    • Bélády’s anomaly
  • thrashing
  • fragmentation
    • external fragmentation
    • internal fragmentation
  • buddy memory allocation
  • Memory segmentation
    • segment table
  • swapping
  • allocation algorithms
    • first fit - first hole that is big enough to hold the process
      • pros: fast
      • cons:
    • next fit - similar to ‘first fit’ but it starts searching from where the last allocation ended
      • pros:
      • cons:
    • best fit - smallest hole that is still big enough for the process
      • pros:
      • cons: external fragmentation
    • worse fit - largest available hole
      • pros:
      • cons:
    • quick fit -
      • pros:
      • cons:
  • mapping
    • bitmap
    • linked lists
    • free list
    • quick fit
  • locality of reference (aka the principle of locality)
    • Temporal locality
    • Spatial locality
      • Memory locality (or data locality)
\text{Page frame number} && \text{if present bit = 1}\\ \text{``on disk''} && \text{if present bit = 0} \end{cases}$$ - virutal memory - paging - $\text{page-table}(\text{virtual page number}) = \text{page frame number}$ - **page frame number** (PFN) (which is the physical page number) - page frame - dirty bit - $\# \text{pages} =\# \text{page-table entries} = \frac{\text{virtual memory size}}{\text{page size}}$ - $\text{page size} = 2^{\text{offset bits}}$ - $\text{virtual memory size} = 2^{\text{virtual address bits}}$ (set by the ISA) - $\text{virtual address bits}= \text{VPN bits} + \text{offset bits}$ - $\text{virtual address} = [\text{VPN}, \text{page offset}]$ - $\text{VPN}= \left\lfloor \frac{\text{virtual address}}{\text{page size}} \right\rfloor$ - $\text{page offset} =\text{virtual address} - \text{VPN} \times \text{page size}$ - $\text{physical memory address} = (\text{page frame number}, \text{page offset})$ - $\text{physical address} = \text{PFN} \times \text{page size} + \text{page offset}$ - $\# \text{page frames} = \frac{\text{physical memory size}}{\text{page size}}$ - $\text{physical memory size} = 2^{\text{physical address bits}}$ (set by the actual RAM installed) - $\text{physical address bits}= \text{PFN bits} + \text{offset bits}$ - page table entry (PTE) contains: - page frame number - present/absent bit - 1 = in memory - 0 = on disk (then CPU generates a **page fault** exception) - protection bits - read/write/execute permissions - reference bit - modified bit - caching disabled/enabled - translation lookaside buffer (TLB) - hard miss - page walk - page fault - Minor page fault - Major page fault - segmentation fault - multilevel page table - inverted page table (IPT) - $\mathrm{IPT}(\text{physical frame}) = \text{(process id, virtual page number)}$ - demand paging # Linux - address space: - text segement - data segment - initialized data - uninitialized data, which is called the **block starting symbol** (abbreviated to `.bss` or `bss`. origin: **BSS** from **Block Started by Symbol**) - initialized to zero after loading - stack