Boss lesson · Unit 04
More memory than you have
Virtual addresses, pages, faults and swap
What you practise
- Virtual addresses, pages and page tables, page faults, swap, why two processes can use the same address, what "out of memory" really means
Try a question from this lesson
Pick one
Two different programs, running at the same time, each print the address of a variable. Both print 0x7ffd1000, yet they hold different values. How?
Correct answer
Each process has its own private set of addresses
Why
The addresses a program sees are not real hardware addresses. Each process gets its own numbering, and the OS maps the same number in two processes to two different places in RAM.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Virtual addresses
Every process sees a private row of addresses: its virtual memory. Memory is handled in pages of 4,096 bytes.
On each access the CPU looks up the page in the process's page table, which the kernel fills in, to find the real frame of RAM.
process A physical RAM
page 0 --------> frame 7
page 1 --------> frame 2
process B
page 0 --------> frame 5Concept
Page faults
A page table entry can say "not in RAM". Touching such a page makes the CPU stop and call the kernel: a page fault.
The kernel finds a free frame, fills it (from the program file, or from swap space on disk), updates the table and reruns the instruction. The program notices nothing but the delay.
10 more exercises in the app
- 4× type the answer
- 1× fill the blanks
- 3× multiple choice
- 1× order the lines
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.