Spring 2017 :: CSE 506
Virtual Memory & Process Address Space
Nima Honarmand
& Process Address Space Nima Honarmand Spring 2017 :: CSE 506 - - PowerPoint PPT Presentation
Spring 2017 :: CSE 506 Virtual Memory & Process Address Space Nima Honarmand Spring 2017 :: CSE 506 Virtual Memory (VM) Recap Primary purpose? Isolate each process to its own address space Components Address translation
Spring 2017 :: CSE 506
Nima Honarmand
Spring 2017 :: CSE 506
present, NX → OS to CPU communication
→ CPU to OS communication
→ OS to OS communication
Spring 2017 :: CSE 506
in Computer Science
process tries to access it
Spring 2017 :: CSE 506
point in copying all the address space on fork()
Spring 2017 :: CSE 506
instructions, rather than having to call read()/write() every time
demand
sharing
Spring 2017 :: CSE 506
virtual memory
network
Partitioned Global Address Space (PGAS) model
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
keep a lot of information about the Process Address Space Layout
→ We need a side data structure to store this information
Spring 2017 :: CSE 506
its heap and stack
Virtual Address Space (4GB) 0xffffffff hello libc.so heap stk
Spring 2017 :: CSE 506
vm_area_struct, or vma
Spring 2017 :: CSE 506
Process Address Space 0xffffffff vma /bin/ls star t end nex t vma anon (data) vma libc.so
mm_struct (process)
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
red-black tree
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
from the OS, or delete mappings
map itself
Spring 2017 :: CSE 506
prot, int flags, int fd, off_t offset);
goes (as long as it doesn’t clobber something else)?
Spring 2017 :: CSE 506
necessarily allocate physical memory or setup page table entries
needed?
Spring 2017 :: CSE 506
process; identical except for the return value
int pid = fork(); if (pid == 0) { // child code } else if (pid > 0) { // parent code } else { // error }
Spring 2017 :: CSE 506
space and copy each page
without using any of these pages
Spring 2017 :: CSE 506
fork
write bit, set COW bit
Spring 2017 :: CSE 506
decrease in virtual address order
Stack “bottom” – 0x13000 0x12600 0x12300 0x11900 Exceeds stack page OS allocates a new page main() foo() bar()
Spring 2017 :: CSE 506
virtual address space if user doesn’t specify an address
Spring 2017 :: CSE 506
Heap Stack
Data Segment Grows Grows
Spring 2017 :: CSE 506
heap
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
file?
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
headers
binary
present
Spring 2017 :: CSE 506
convention)
Spring 2017 :: CSE 506
libraries
libraries
Spring 2017 :: CSE 506
the program binary
program (corresponding to VMAs)
generated by the compiler
to be loaded at one (instead of separately)
Spring 2017 :: CSE 506
is a supported format
Spring 2017 :: CSE 506
external library
references
Spring 2017 :: CSE 506
mov rax, 24(rbx) // rbx points to the // jump table call *rax
the lecture readings for details)
Spring 2017 :: CSE 506
(ld.so), give the linker the actual program as an argument
libraries