xv6 overview
play

xv6 Overview CS 450 : Operating Systems Michael Saelee - PowerPoint PPT Presentation

xv6 Overview CS 450 : Operating Systems Michael Saelee <lee@iit.edu> Computer Science Science Agenda - Architectural overview - Features & limitations - Hardware dependencies/features Computer Science Science Agenda - Code


  1. xv6 Overview CS 450 : Operating Systems Michael Saelee <lee@iit.edu>

  2. Computer Science Science Agenda - Architectural overview - Features & limitations - Hardware dependencies/features

  3. Computer Science Science Agenda - Code review: - Headers and Process structures - Bootstrap procedure - Scheduling & Context switching - Sleep & Wakeup - Trap / Syscall mechanism

  4. Computer Science Science §Architectural Overview

  5. Computer Science Science xv6 is a monolithic , preemptively-multitasked , multiprocessor-capable , 32-bit , UNIX-like operating system

  6. Computer Science Science some limitations: - max addressable memory: 2GB - few supported devices (e.g., no network) - no support for kernel-level threading

  7. Computer Science Science limited syscall API: System call Description fork() Create process exit() Terminate current process wait() Wait for a child process to exit kill(pid) Terminate process pid getpid() Return current process’s id sleep(n) Sleep for n seconds exec(filename, *argv) Load a file and execute it sbrk(n) Grow process’s memory by n bytes open(filename, flags) Open a file; flags indicate read/write read(fd, buf, n) Read n byes from an open file into buf write(fd, buf, n) Write n bytes to an open file close(fd) Release open file fd dup(fd) Duplicate fd pipe(p) Create a pipe and return fd’s in p chdir(dirname) Change the current directory mkdir(dirname) Create a new directory mknod(name, major, minor) Create a device file fstat(fd) Return info about an open file link(f1, f2) Create another name (f2) for the file f1 unlink(filename) Remove a file

  8. Computer Science Science very limited set of user-level programs: - shell, cat, echo, grep, kill, 
 ln, ls, mkdir, rm, wc - no compiler/debugger/editor - development (kernel/user) takes place on another platform!

  9. Computer Science Science §Hardware Dependencies / Features

  10. Computer Science Science xv6 runs on an x86 (Intel) processor, and relies on many of its hardware features e.g., privilege levels (kernel/user mode), interrupt vector & procedure, segmentation & paging (VM)

  11. Computer Science Science Recall: 2-bit current privilege level (CPL) flag - CPL=3 ➞ “user” mode - CPL=0 ➞ “supervisor/kernel” mode - guards special instructions & hardware - also restricts access to interrupt 
 & VM structures

  12. Computer Science Science CPL is actually part of the %cs register, which specifies the code segment address %cs and %eip (x86 PC) identify an instruction to execute and its privilege level

  13. Computer Science Science but CPL cannot be modified directly! - lower (raise priority) via int instruction - raise (lower priority) via iret instruction

  14. Computer Science Science int instruction (and h.w. interrupt) result in interrupt descriptor table (IDT) lookup - fetches target %cs and %eip (aka “gate”) for corresponding handler - restricts entry points into kernel - install base address of IDT with lidt

  15. Computer Science Science xv6 also relies on x86 segmentation and paging to implement virtual memory

  16. Computer Logical Address Science Science (or Far Pointer) Segment Selector Offset Linear Address Space Linear Address Global Descriptor Physical Dir Table Offset Table (GDT) Address Space Segment Page Table Page Segment Descriptor Page Directory Phy. Addr. Lin. Addr. Entry Entry Segment Base Address Page Paging Segmentation

  17. Segment Linear Address Space Segment Computer Descriptors Registers (or Physical Memory) Science Science Access Limit CS Base Address Stack Access Limit SS Base Address Access Limit DS Base Address Code Access Limit ES Base Address Data Access Limit FS Base Address Data Access Limit GS Base Address Data Access Limit Base Address Access Limit Base Address Data Access Limit Base Address Access Limit Base Address Segment descriptors

  18. Computer Science Science Linear Address Space (or Physical Memory) Segment FFFFFFFFH Code Registers CS Code- and Data-Segment Descriptors Not Present SS DS Access Limit Data and Stack Base Address 0 ES FS GS “Flat” model

  19. Computer Science Science Linear Address 31 22 21 12 11 0 Directory Table Offset 12 4-KByte Page Page Table Physical Address 10 10 Page Directory PTE 20 PDE with PS=0 20 32 CR3 IA-32 paging (4KB pages)

  20. Computer VIrtual address Science Science Physical Address 10 10 12 20 12 Dir T able Offset PPN Offset 20 12 1023 PPN Flags 20 12 1023 1 0 Page T able PPN Flags 1 0 CR3 31 12 11 10 9 8 7 6 5 4 3 2 1 0 A C W Physical Page Number V D A U W P D T L P - Present Page table and page directory W - Writable entries are identical except for U - User the D bit. WT - 1=Write-through, 0=Write-back CD - Cache Disabled A - Accessed D - Dirty (0 in page directory) AVL - Available for system use

  21. Computer Science Science §Demo & Code Review

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