CS124 Lec 20
CS124 Lec 20
MANAGEMENT
CS124 – Operating Systems
Winter 2013-2014, Lecture 20
Last Time: Memory Descriptors
• Last time, began discussing how the kernel manages
virtual memory
task_struct mm_struct vm_area_struct Process Virtual Memory
vm_end
mm pgd vm_start
vm_prot
mmap
vm_flags
Shared Libraries
vm_next
vm_end
• Example: kernels frequently vm_start
Swap Slots
• Storage used for page swapping is divided into slots
• Each slot can hold one virtual page
• Required operations:
• Find a free slot to store a page in, and save the page to the slot
• Load a page from a slot, and possibly release the slot for reuse
• Linux uses a swap map to describe slots in a swap area
• An array of counters specifying how many processes are using
each corresponding swap slot
Swap Map:
• 0 means the slot is available for use
1 3 0 1 32768 0
• >1 means slot is shared by multiple
processes (e.g. a shared library) Swap Area:
• 32768 means the slot contains
bad sectors and cannot be used
18
• Given 4KiB pages, each swap area can hold up to 224 pages, or
64GiB of swap space
• With up to 128 swap areas, can have up to 8TiB of swap space
• This slot identifier is stored into the page table entry of a
swapped-out virtual page
• Page fault handler can easily use this to reload a page into memory
19
Page 5 OPT: 4 2 3 5
Next Time
• Continue discussion of page replacement policies
• How can we approximate the optimal replacement policy?