1 / 14

CSE451 Section 7: Virtual memory

CSE451 Section 7: Virtual memory. Table of content. Real address space Process creation optimization Debugging: watch point. Real address space. 0x00000000. 0xffffffff. User address space. Kernel space. 0xc0000000 on x86. From Understanding The Linux Virtual Memory Manager.

ford
Télécharger la présentation

CSE451 Section 7: Virtual memory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE451 Section 7:Virtual memory

  2. Table of content • Real address space • Process creation optimization • Debugging: watch point

  3. Real address space 0x00000000 0xffffffff User address space Kernel space 0xc0000000 on x86 From Understanding The Linux Virtual Memory Manager

  4. Kernel address space • Kernel address space • Remain constant in user address space • Why does all processes have the same shape of address space? • Kernel can’t access user address space directly • Why? • Understanding The Linux Virtual Memory Manager • http://www.skynet.ie/~mel/projects/vm/

  5. Optimization • What do you think about memory copy? • Inter Process Communication • Network packet processing • Booting embedded system • Is it really fast?

  6. Process creation • Fork() • Allocate process control block • Copy address space including shared resources • Schedule new process • Let’s analyze real cases

  7. When do we use fork? • Web server • Why? • Usage? • What are shared? • What are not shared? • Shell • Why? • Usage? • What are shared? • What are not shared?

  8. Optimize fork – Web server • Most of address space is shared • Program code • Configuration of web server • Heap • May contain useful data • What is not shared? • Stack & Heap • Do we need to copy entire address space?

  9. Copy-on-write • Principle of laziness • Do action when it is REALLY required • Do copy when the data is really changed • Effect on fork? • Code: never be copied • Heap & stack: copy only changed portion • Much faster, eh? • Linux fork() implements copy-on-write

  10. How is it implemented? P1 P2 CODE1 CODE1 CODE2 CODE2 CODE1 HEAP1 HEAP1 HEAP4 HEAP2 HEAP2 HEAP2’ HEAP2 HEAP3 HEAP3 HEAP4 HEAP4 STACK2 HEAP3 STACK2’ CODE2 HEAP2’ STACK2 STACK2’ STACK2 STACK1 STACK1 STACK1 HEAP1 Fork Call function A’ Write HEAP2

  11. More copy-on-write • Packet processing: Router • Can be seen as a chain of filters • http://pdos.csail.mit.edu/click/ • Copy a packet whenever it passes a filter? • Ethernet: 1500Byte frame size • 10Mbps ~ 1.25MB/s • Sample NAT/firewall enabled configuration has 37 filters • 30MB memory copies per second • 300MB when 100Mbps • 3GB when 1Gbps • This is just pure overhead! • Copy on write! • Comparison does not change the content • Other applications?

  12. Optimize fork – shell • What is shared? • NOTHING! • exec() will overwrite entire address space • Copy? • Noooooo! • Do not copy page table • Suspend parents until child calls exec() • exec() builds a new address space from the scratch • vfork does this

  13. Implementing thread? • Linux 2.6 thread implementation • NPTL: Native POSIX Thread Library • 1:1 threading model • Process/thread creation is integrated in clone() • NPTL design paper • http://people.redhat.com/drepper/nptl-design.pdf

  14. Debugging: watch point • Watch point • Stop execution whenever the value of interesting variable has been changed • Naïve approach • The variable is in page P • Let P as unmapped • Accessing P will cause page fault • Intercept page fault and temporarily map the page • Single instruction step over • If it touches, watched area, TRAP debugger

More Related