CSO Final - Chapter 9 Virtual Memory
What happens when a process tries to write to a page in a private copy-on-write area?
Creates a new copy of page in physical memory & updates PTE to point to new copy
What does the block header contain?
block size & allocated bit
What does TLB stand for?
translation lookaside buffer
Why is dynamic memory allocation useful?
when the program does not know the sizes of certain data structures until the program runs
What is an allocator's throughput?
# of requests that it completes per unit time
How many page tables & addresses spaces are there?
1 for each process
What does a block consist of?
1-word header, payload (& possibly padding)
What happens if the allocator is unable to find a fit for the requested block?
1st try to create larger free blocks by coalescing, then ask kernel for more heap memory by calling sbrk()
How many permission bits are there in a PTE & what do they do?
3; SUP indicates if the process should run in the kernel, read/write bits control access to r/w
What is the difference between physical addressing & virtual addressing?
?
What is the payload?
?
How does demand paging & separate virtual address space simplify linking?
A separate address space allows each process to use the same format regardless where code & data are in memory
Which placement policy uses the best memory utilization?
Best > next > first
What is a page fault?
DRAM cache miss
What does the valid bit in a PTE do?
Determines whether the page is currently cached in DRAM (p. 807)
T/F If a process maps a private object into an area of its virtual address space, then the writes are visible to other processes.
F
T/F Pages reside next to each other in physical memory
F (p. 812)
How does demand paging & separate virtual address space simplify memory allocation?
If the program needs more heap space, requests kernel & maps additional pages anywhere in physical memory
How does demand paging & separate virtual address space simplify sharing?
OS creates page table that map the corresponding virtual pages to disjoint physical pages
T/F If a process maps a shared object into an area of its virtual address space, then the writes are visible to other processes.
T
T/F fork() creates an exact copy of the virtual memory when fork was called
T
T/F shared objects copies are stored once in physical memory
T (even though the object is mapped into multiple shared areas - p. 835)
What happens to the boundary tags during coalescing?
adding the sizes of the 2 blocks to the header
What is a garbage collector?
allocator that automatically reclaims heap-allocated storage when the program no longer needs it
What determines the amount of virtual memory?
amount of swap space on disk (p. 845)
What does the mmap() do?
asks the kernel to create a new virtual memory area
What does the swap space hold?
bounds the total amount of virtual pages that can be allocated by the currently running processes
What is the heap in the context of an allocator?
collection of various-size blocks
What is an explicit free list?
doubly linked list that keeps track of only free blocks
What is best fit?
examines every free block & chooses the free block w/ smallest size it fits
What do explicit allocators require the application to do?
explicitly free any allocated blocks
What are the 3 most common placement policies?
first fit, next fit, best fit
What is an implicit free list?
free blocks are linked implicitly by the size fields in headers
cons of explicit free list
free blocks must be large enough to contain all necessary pointers (+ header & footer)
What does the allocated bit do?
indicates whether the block is allocated or free
Cons of best fit
lots of searching of heap to find best spot
What is a dynamic memory allocator?
maintains an area of a process' virtual memory aka the heap
What is a page table?
maps virtual pages to physical pages, array of PTE
What is coalescing?
merging adjacent free blocks
What is immediate coalescing?
merging any adjacent blocks each time block is freed
cons of segregated list
more expensive to coalesce lists
What is a segregated list?
multiple free lists organized by size
In 64-bit mode, malloc returns an address of what size?
multiple of 16
In 32-bit mode, malloc returns an address of what size?
multiple of 8
What is internal fragmentation?
occurs when an allocated block is larger than the payload
What is external fragmentation?
occurs when there is enough free memory to satisfy an allocate request, but no single free block is large enough to handle request
What is fragmentation?
occurs when unused memory is not available to satisfy allocate requests
Simple segregated storage stuff.....
p. 864
segregated fits...
p. 864
buddy system...
p. 865
mark&sweep collectors....
p. 867
What is a PTE?
page table entry
What determines external fragmentation?
pattern of previous & future requests (p. 846)
What are the 3 steps of free block organization?
placement, splitting, coalescing
How does demand paging & separate virtual address space simplify loading?
points to the .text & .data section, makes as invalid (aka un-cached) & points their page table entries to the right locations (p. 813)
How does locality work with virtual memory?
principle of locality promises that virtual memory will work on a smaller set of active pages (the working set)
Pros/cons first fit
pro: large free blocks @ end cons: leaves splinters of small free blocks @ beginning (increases search time)
Pros & cons of implicit free list
pros: simplicity cons: linear search of free list
What objects can be mapped by memory mapping?
regular file or an anonymous file
What do implicit allocators require the application to do?
require the allocator to detect when an allocated block is no longer being used & frees it (aka garbage collector)
What is first fit?
searches list from beginning & chooses first free block that fits
What is next fit?
searches where the previous search left off
What is a TLB?
small, virtually addressed cache where each line holds a block of a single PTE
What is the aggregate payload?
sum of the payloads of the currently allocated blocks
What happens once a virtual page is initialized?
swapped back & forth between the swap file maintained by the kernel
What happens when the CPU generates a virtual address?
the MMU (memory management unit) will translate the virtual address into a physical address
What is swapping?
transferring a page between disk & memory
How does the allocator traverse an implicit free list?
traversing all blocks in heap linearly
What does virtual memory do?
treats the main memory as a cache, simplifies memory management by providing each process w/ uniform address space, protects the address space from corruption by other processes
What does a PTE contain?
valid bit, n-bit address field
What is deferred coalescing?
waiting to coalesce until allocator needs to
What is demand paging?
waiting until the last moment to swap in a page