- Outline:
- Lab2 has 3 parts:
- Physical page allocator.
- Virtual page management.
- Kernel page mapping installation.
- Preparation:
- Intel 80386 reference manual: Chap5, Chap6.
- xv6: Chap 1.
- JOS: test cases code: check_*()
- Understand xv6 how to create temporary memory management to touch memory after 1MB.
- Build the map about Segment and Page translation on x86 in mind.
- Part 1: Physical page allocator
- boot_alloc():
- Divide physical memory into each 4KB pages.
- It should account for booting memory overhead from NVRAM's status until now.
- kernel image.
- allocation data structure.
- mem_init():
- Here, just allocate the kernel page directory and set its attributes.
- physical page allocation
- page_init():
- Calculate the free list.
- Set up data structure.
- Don't touch the reserved memory! But the reserve memory should be accounted.
- page_alloc():
- Just allocate one physical page.
- ALLOC_ZERO handling.
- page_free:
- Just free one physical page.
- Read code carefully to sync the thought between Judge code and lab code
- check_page_free_list()
- check_page_alloc()
- GitHub Link
- Part 2: Virtual page management.
- pgdir_walk()
- Ask yourself: If i am a x86 cpu, how could I find the corresponding page?
- If the new pte doesn't belong to any page table, then just allocate the new page table.
- Return virtual address of PTE slot!
- Consult the xv6 code.
- virtual page allocation
- page_insert()
- Use pgdir_walk to find corresponding pte.
- One physical page to map N virtual pages
- pp->ref is N.
- Remember permission assignment.
- Return page table entry.
- page_remove()
- Decrease the count.
- Be zero, then free the physical page by page_free.
- Clear the pte!
- page_lookup()
- Return the corresponding virtual page's page structure.
- by pgdir_walk and pa2page.
- Read code carefully to sync the thought between Judge code and lab code
- check_page()
- GitHub Link:
- Part 3: kernel page mapping and installation.
- boot_map_region()
- Map the memory block into pages.
- some extern symbols are already the virtual address in C language!
- PADDR usage.
- bootstack ,bootstacktop
- Naming like virtual address, but it is extren variable in C to be Virtual address.
- Read code carefully to sync the thought between Judge code and lab code
- check_kern_pgdir()
- check_page_installed_pgdir()
- GitHub Link:
- Discussion:
- If __ALL_COUNT__ defined
- When each PTE referenced, then It increases corresponding page table/directory's count.
- Sample: __ALL_COUNT__ defined
- page_table 3
- page 1 1
- page 2 1
- page 3 1
- Sample
__ALL_COUNT__ not defined
- page_table 1
- page 1 1
- page 2 1
- page 3 1
- GitHub Link
Sunday, April 29, 2012
Lab2 Memory Management
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
歡迎正面積極的討論。