tasks memory management
play

Tasks & Memory Management October 30, 2007 Contents Task - PDF document

Faculty of Computer Science Institute for System Architecture, Operating Systems Group Tasks & Memory Management October 30, 2007 Contents Task creation Address space setup Page-fault handling Pager Hierarchical


  1. Faculty of Computer Science Institute for System Architecture, Operating Systems Group Tasks & Memory Management October 30, 2007 Contents • Task creation • Address space setup – Page-fault handling – Pager – Hierarchical address spaces • Virtual memory management – Region Mapper • Dataspaces TU Dresden, 30.10.07 Slide 2

  2. So far… • BIOS started, loaded and executed boot sector • GRUB loaded kernel and boot modules • Bootstrap interpreted binary modules and set up kernel structures (Kernel Info Page) • Kernel started by Bootstrap • Root task and Sigma0 (initial address space) started by kernel  Next step: start application tasks Sigma0 Root Task Root Pager Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 3 Task Creation l4_task_new System call: l4_taskid_t l4_task_new ( l4_taskid_t destination, /* destination task id */ l4_umword_t mcp_or_new_chief, /* maximum controlled priority * or new chief */ l4_umword_t esp, /* stack pointer of first thread */ l4_umword_t eip, /* instruction pointer of first * thread */ l4_threadid_t pager /* pager of first thread */ ); TU Dresden, 30.10.07 Slide 4

  3. Task Creation 4GB Kernel Area 3GB esp eip 0 l4_task_new(…, esp, eip, rmgr_pager) Sigma0 Root Task Root Pager Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 5 Task Creation 4GB Task needs to access code / data Kernel Area / stack / … to execute application 3GB esp Stack eip Code Data 0 Sigma0 Root Task Root Pager Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 6

  4. Task Creation 4GB CPU tries to fetch instruction at Kernel Area eip 3GB  Page-fault exception esp eip 0 Sigma0 Root Task Root Pager Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 7 Page-Fault Handling • Page-fault exception is caught by kernel page-fault Application’s address space handler • No management of user memory in kernel • Invoke user-level memory eip management  Pager Kernel Page-Fault Handler Fiasco Microkernel TU Dresden, 30.10.07 Slide 8

  5. Pager • Thread which is invoked on page fault • Each thread has a (potentially different) pager assigned Application’s address space Pager’s address space Pager Memory Pager Code Kernel Page-Fault Handler Fiasco Microkernel TU Dresden, 30.10.07 Slide 9 Pager Invocation • Communication with pager thread  IPC • Kernel page-fault handler sets up IPC to pager • Pager sees faulting thread as sender of IPC Application’s address space Pager’s address space Pager Memory Pager Code call(…,fault address, fault eip,…) Kernel Page-Fault Handler Fiasco Microkernel TU Dresden, 30.10.07 Slide 10

  6. Page-Fault IPC Short IPC (register-only transfer): faulting EIP (32) dw1 (EBX) fault address / 4 (30) dw0 (EDX) w ~ w = 0 read page fault w = 1 write page fault Pager should reply with Flexpage IPC: write grant Pager’s address space flexpage page address (20) ~ (4) size (6) send base  Maps one or more pages from pager address space to application address space TU Dresden, 30.10.07 Slide 11 Page-Fault Handling • Pager maps pages of his own address space into the client address space Application’s address space Pager’s address space Pager Memory Pager Code send(app_id,fpage(..),…) Kernel Page-Fault Handler Fiasco Microkernel TU Dresden, 30.10.07 Slide 12

  7. Page Mapping • Entry in virtual memory points to page frame in phys. memory  Map creates an entry in the receiver’s address space pointing to the same page frame  Only valid entries in pager’s address space can be mapped to clients Application’s address space Pager’s address space send(…, fpage, ..) Virtual Memory Virtual Memory Memory Kernel Page Frames Fiasco Microkernel TU Dresden, 30.10.07 Slide 13 Page Mapping • Special case: grant pages  Removes mapping in sender's address space Application’s address space Pager’s address space send(…, fpage, ..) Virtual Memory Virtual Memory Memory Kernel Page Frames Fiasco Microkernel TU Dresden, 30.10.07 Slide 14

  8. Page Mapping • Unmap removes entries to a page frame (fpage is specified in the invoker's address space)  Kernel needs to keep track, which page frames are mapped in which address space  Mapping Database Application’s address space Pager’s address space unmap(fpage) Virtual Memory Virtual Memory Memory Kernel Page Frames Fiasco Microkernel TU Dresden, 30.10.07 Slide 15 Flexpage IPC in Detail • Flexpages describe areas in address spaces (size aligned) • Flexpage size 2 size , smallest is hardware page (4KByte on IA32) • Both source pages and target area of a map IPC are flexpages l4_ipc_receive(…) Sender’s Receiver’s Address Space Address Space page address (20) ~ (4) size (6) wg Receive Window page address (20) ~ (4) size (6) wg send base (32) l4_ipc_send(…) TU Dresden, 30.10.07 Slide 16

  9. Flexpage IPC in Detail send base Send flexpage is smaller than the receive window – Target position in receive window is derived from page alignment and send base l4_ipc_send(…) l4_ipc_receive(…) page address (20) ~ (4) size (6) page address (20) ~ (4) size (6) w g w g send base (32) TU Dresden, 30.10.07 Slide 17 Flexpage IPC in Detail send base Send flexpage is larger than receive window – Source position in send flexpage is derived from page alignment and send base  send base is a hot spot for mapping IPC  Actual send base depends on information about the receiver l4_ipc_send(…) l4_ipc_receive(…) page address (20) ~ (4) size (6) page address (20) ~ (4) size (6) w g w g send base (32) TU Dresden, 30.10.07 Slide 18

  10. Page-Fault IPC in Detail • Kernel Page-Fault handler sets receive window to whole address space  Pager can map more than just the page where the page fault happened to the client Application's Pager’s Address Space Address Space page address (20) ~ (4) 12 send base  pf address 0 ~ 32 Page-Fault Receive Window Kernel Page-Fault Handler Fiasco Microkernel TU Dresden, 30.10.07 Slide 19 Task Creation  Roottask is the pager of applications loaded as grub modules  Roottask requests memory from Sigma0, which initially owns all memory Application’s address space Root Task’s address space Memory esp App Code Section eip App Data Section Roottask l4_task_new(…) Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 20

  11. Task Creation • Pages are mapped as they are needed  Demand Paging Application’s address space Root Task’s address space Memory Stack App Code Section Code App Data Section Data Roottask Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 21 Breakpoint • Task Creation / Basic Page-Fault Handling – Roottask starts tasks for all boot modules  Can start basic L4Env services • Flexpage IPC TU Dresden, 30.10.07 Slide 22

  12. Hierarchical Pager • Initial pager can only implement basic memory management  No knowledge about application requirements – Different requirements at the same time  No services available to implement more advanced memory management – No disk driver  Build more advanced pagers on top of the initial pager  Pager hierarchies TU Dresden, 30.10.07 Slide 23 Hierarchical Pager Application Application Pager 3 Disk Driver Pager 1 Pager 2 Phys. Memory 1-to-1 mapped Initial Address Space Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 24

  13. Hierarchical Pager Real World Example • L4Linux implements Linux paging policy • DROPS pager implements Real-Time paging policy (no swapping etc.) Real-Time Applications L4Linux Applications L4Linux Applications Real-Time Applications Linux Swap Linux Paging L4Linux Kernel Server DROPS Pager Phys. Memory 1-to-1 mapped Initial Address Space Kernel Fiasco Microkernel TU Dresden, 30.10.07 Slide 25 Virtual Memory Management • Pager must specify send base  Pager needs to know client’s address space layout – ok if only one pager manages the address space (e.g. L4Linux) • Possible conflicts if more than one pager manages an address space: Application Application Pager 3 Disk Driver Pager 1 Pager 2 Phys. Memory Initial Address Space Kernel  Virtual memory must be managed independently of pagers TU Dresden, 30.10.07 Slide 26

  14. Region Map • Per-address space map that keeps track which part of the address space is managed by which pager: Address space Region Map VM Region Pager Pager 1 <start, end> Pager 1 <start, end> Pager 2 <start, end> Pager 2 Pager 2 Pager 2 TU Dresden, 30.10.07 Slide 27 Region Mapper • Intermediate pager which identifies which pager should handle a page fault • Can reside in the application’s address space or in an external task  Region Mapper is pager of all other threads of a task VM Region Pager Application Pager 1 <start, end> Pager 1 Region Mapper Pager 2 <start, end> <start, end> Pager 2 Pager 1 Pager Memory Pager 2 call( region mapper, pf addr, Pager Code Pager 2 pf eip, …) Kernel Page-Fault Handler Fiasco Microkernel TU Dresden, 30.10.07 Slide 28

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend