cs330 Proj3-1
cs330 Proj3-1
cs330 Proj3-1
Virtual Memory(VM)
Why should we use VM? To use memory larger than physical memory To protect user programs memory area(isolation)
Each programs cannot access others memory
Virtual Memory(VM)
Virtual Memory(VM)
OS make an illusion of using large pages Each processes think they have 4GB own memory VM makes it possible Maps from user memory to physical memory If there is excess memory usage, evict it to secondary storage
Virtual Memory(VM)
Page Mapping
Page A continuous region of virtual memory processing Usually 4KB (12-bit offset) in length Frame in physical memory
What to do?
Current Pintos VM 2-level page table is already implemented
pagedir.c, pte.h *pagedir in struct thread
But incomplete page table management Nothing is done when page fault occurs(just failure) Cannot use virtual memory larger than physical memory You should implement... Supplement page table to manage swap
Hash structure is useful
Stack growth
These flags are useful for finding victim and evicting pages device/disk.c Low level disk read/write functions(using sector number) lib/kernel/hash.c, lib/kernel/bitmap
11
Translate from VA to PA
Store this mapping information in also hash table What is virtual address and what is physical address in Pintos? How can we catch the moment that page is allocated?
13
palloc.c
palloc_get_multiple, palloc_free_multiple
14
Modify PTE(original page table) and (your) page table Replace new page(if needed) Related functions :
disk.c
disk_get, disk_read, disk_write
15
16
Modify PTE(original page table) and (your) page table Be careful for thrashing
Why? When does thrashing occur?
Related functions :
exception.c
page_fault
17
18
Creating swap-disk
pintos-mkdisk swap.dsk n
n is size of disk (MB)
Pintos --swap-disk=n
19
3) Stack Growth
Current Pintos Implementation The stack consists of only a single page(4KB)
This is set as stack_setup() in process.c
If program tried to use stack larger than 4KB, page fault occurs Your Mission Make stack grow up on demand Just allocate a new page contains faulted address for stack
20
3) Stack Growth
How can we know that faulted address is for stack or not? This page fault is caused by stack growth? Or caused by accessing just invalid page near to stack? This problem is very tricky!! Recognizing algorithm is up to you f->esp is useful Add algorithm to page fault handler
21
Tip
-ul option is very useful Limit the size of user pool Easy test for swap in/out ex> pintos -ul=16
22
Etc.
This project should be built on top of project 2. Test programs from project 2 should work with project 3 We wont provide project 2 source code for you. You should complete project 2 before project 3 You must pass 15 tests + userprog tests tests/vm/pt-bad-addr, tests/vm/pt-bad-read tests/vm/pt-write-code, tests/vm/pt-write-code2 tests/vm/page-linear, tests/vm/page-parallel tests/vm/page-merge-seq, tests/vm/page-merge-par tests/vm/page-merge-stk, tests/vm/page-shuffle tests/vm/pt-grow-stack, tests/vm/stk-sc tests/vm/pt-big-stk-obj, tests/vm/pt-grow-pusha tests/vm/pt-grow-bad
23
Etc.
There is no file in VM directory You should create from nothing!! Fortunately, there is some hint in pintos document
24
Etc.
We recommend you to use the course board to ask question!! So, other team can share your question!!
25
Submission
Due 11/4 (Mon) 23:59
Note that therell be a blackout at 11/3