Project 3' Virtual Memory - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Project 3' Virtual Memory

Description:

Page fault causes system corruption. Important! Must Read a following PDF document carefully. ... Codes. Virtual address (pages) vaddr idx. paddr. Physical ... – PowerPoint PPT presentation

Number of Views:165
Avg rating:3.0/5.0
Slides: 17
Provided by: yjl2
Category:

less

Transcript and Presenter's Notes

Title: Project 3' Virtual Memory


1
Project 3. Virtual Memory
2
Virtual Memory
  • To address the limitation of physical memory size
  • To provide isolation between processes
  • Current pintos system
  • Incomplete page table management
  • Page fault causes system corruption

3
Important!
  • Must Read a following PDF document carefully.
  • http//www.scs.stanford.edu/07au-cs140/pintos/pint
    os.pdf
  • Chapter 4.
  • Appendix A.
  • A.5 Memory Allocation
  • A.6 Virtual Addresses
  • A.7 Page Table
  • A.8 Hash Table

4
Terminology
  • Page
  • A continuous region of virtual memory 4KB
  • Frame
  • A continuous region of physical memory 4KB
  • Page Table (page directory)
  • A data structure that the CPU uses to translate a
    virtual address to a physical address. (from a
    page to a frame)
  • Pintos provides abstract interfaces to page table
    in pagedir.c
  • (uint32_t )pagedir in struct thread
  • Swap Slot
  • A continuous page-size region of disk space on
    the swap disk

5
Overview
  • Pintos

User
User Process
User Process
User Process

System calls
Kernel
Scheduler

Driver
Driver
Driver
Kernel threads

Console
Disk
6
Overview
  • Pintos Project 1. Threads

User
User Process
User Process
User Process

System calls
Kernel
Scheduler

Driver
Driver
Driver
Kernel threads

Console
Disk
7
Overview
  • Pintos Project 2. User Programs

User
User Process
User Process
User Process

System calls
Kernel
Scheduler

Driver
Driver
Driver
Kernel threads

Console
Disk
8
Review - Project 2. User Programs
  • exec(a.out)
  • Start a new kernel thread running a.out
  • process_execute() ? thread_create()
  • Load a.out into the thread and start it running
    (a user process)
  • execute_thread

Frame table
idx
Flags
Kernel space
stack
a.out - ELF
header
User space
vaddr idx
paddr

loading


Codes Data
data

Page directory (page table)
Codes

Physical address (frames)
Virtual address (pages)
9
Tasks
  • Project 3.Virtual Memory
  • Swapping, Handling page faults, lazy loading

!
Frame table
idx
Flags
Kernel space
stack
a.out - ELF
header
!
vaddr idx
paddr

Lazy loading


Codes Data
data

Page directory (page table)
!
Codes

Physical address (frames)
Swapping
Virtual address (pages)
!
Swap table
Supplement page table
idx
Flags
vaddr idx
Flags
!
Swap disk
10
Tasks
  • Paging - Swap, Lazy loading
  • frame table allocator
  • Page table management
  • Supplement page table
  • Swap management
  • Stack growth, Memory mapped files

11
Frame table allocator
  • Current pintos system
  • Threads/palloc.c
  • Functions to allocate pages
  • palloc_get_page, palloc_get_multiple
  • Functions to free pages
  • palloc_free_page, palloc_free_multiple
  • Appendix A.5.1
  • User pool/Kernel pool
  • It is possible to modify palloc.c
  • only parts related to user pool
  • Synchronization (parallelism)
  • Eviction algorithm
  • LRU

Frame table
idx
Flags

Physical address (frames)
12
Page table management
  • Mapping a virtual address to a physical address
  • When Swap, lazy loading, page fault occur,
  • To get a page_table of each threads
  • uint32_t pagedir in struct thread
  • Map/Unmap function
  • pagedir_set_page (uint32 t pd, void upage, void
    kpage, bool writable)
  • pagedir_clear_page (uint32 t pd, void upage)
  • Some functions to check accessed and dirty bits
    of pages.
  • pagedir_is_dirty (uint32 t pd, const void page)
  • pagedir_is_accessed (uint32 t pd, const void
    page)
  • pagedir_set_dirty (uint32 t pd, const void
    page, bool value)
  • pagedir_set_accessed (uint32 t pd, const void
    page, bool value)
  • Appendix A.7.2, A.7.3

vaddr idx
paddr


Page directory (page table)
13
Supplement page table
  • When page faults occur,
  • To locate the page faulted.
  • Lazy loading, a swap slot, an all-zero page.
  • Hash table

Kernel space
stack
data

Codes

Virtual address (pages)
Supplement page table
vaddr idx
Flags
14
Swap management
Swap table
  • When eviction occurs,
  • swap pages evicted to swap disk.
  • Interface hd11 (interface in devices/disk.h)
  • struct disk disk_get(int chan_no, int dev_no)
  • disk_sector_t disk_size (struct disk )
  • void disk_read(struct disk, disk_sector_t,
    void)
  • void disk_write(struct disk, disk_sector_t,
    void)
  • Pintos --swap-diskn
  • Swap disk management
  • Slots information (occupied or not)
  • bitmap

idx
Flags
Swap disk
15
Submission
  • Due date
  • 12/21 (?) ??
  • Submission
  • yjlee AT camars.kaist.ac.kr
  • Archive of pintos/src directory
  • Design documents
  • TA
  • ??? (x5578) ??? 4417?

16
Reference
  • http//www.scs.stanford.edu/07au-cs140/pintos/pint
    os.pdf
  • Chapter 4. Project 3 Virtual Memory
  • Appendix A
  • A.5 Memory Allocation
  • A.6 Virtual Address
  • A.7 Page Table
  • A.8 Hash Table
Write a Comment
User Comments (0)
About PowerShow.com