Virtual Memory

Julie OhΒ·2025λ…„ 7μ›” 31일

Operating system

λͺ©λ‘ 보기
13/14

🧠 Swapping

: A memory management technique where inactive processes are temporarily moved to the hard disk to free up space in RAM, and new or active proccesses are loaded into memory

🧩 Memory Allocation Strategies

Load processes of different size sequentially into memory
1) First fit
2) best fit
3) worst fit

🧨 External Fragmentation

: occurs when free memory is devided into samll, non-contiguous blocks due to loading and removing proccesses of different size

πŸ›  Solution β€” Compaction

S1. Compaction: Move processes in memory closer together and combine free spaces into a single contiguous block.

πŸ’‘ Virtual Memory

: a memory technique that provides the illusion of larger and contiguous memory space for each process, even though the physical memory may be fragmented or limited.

  • Allows programs larger than the available physical memory to run
  • Achieved through paging and swapping

πŸ“¦ Paging

: Divides both logical memory(process) and physical memory(RAM) into fixed size blocks:

  • Pages: fixed-size blocks of logical memory
  • Frames: fixed-size blocks of physical memory(same size as page)
    From the process's point of view, code, data, heap, and stack are laid out contiguously, but physically they may b escattered.

πŸ”„ Page Swapping
Instead of swapping the entire process, the system loads or swaps only the necessary pages

  • Reduce memory usage
  • Makes it posslbe to run a process larger than the physical RAM

πŸ“„ Page Table

: A structure that maps each logical page number to its corrseponding physical frame number.

  • Each process has its own page table
  • page table is stored in PCB


🧱 Page Table Entry (PTE) Fields:

  • Valid Bit: whether the page is on memory or disk memory
    1 > page is on memory
    0 > page is not on memory

    when valid bit 0, if CPU tries to access to the page, then exception(page fault) occurs

  • Protection bit:
    0 > only read
    1 > read and write
    OR
    r, w, x
  • Reference bit: CPU has read or written the page
    1 > read or write
    0 > no accessed by CPU
  • Modified bit: whether CPU write the data in thie page

πŸ“ Page Table Base Register (PTBR)

  • Stores the memory address of the current process's page table
    : If process A is running, then PTBR points the paging table of process A

⚑ TLB (Translation Lookaside Buffer)

: A small, fast cache inside the MMU that stores recent page table entries

A Memory Management Unit (MMU) is a hardware component that translates virtual memory addresses (used by the CPU) into physical memory addresses (used by the RAM)

πŸ” Logical to Physical Address Translation

Copy on write

: Used during process creation (fork()) to share pages between parent and child until one modifies the page
ex) Fork()
Initially, both processes point to the same physical frame (read-only)

However, if parent or child write something on the page, then create a new frame and the page is reassigned to that frame

0개의 λŒ“κΈ€