* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download COS 318: Operating Systems Overview Kai Li and Andy Bavier
Survey
Document related concepts
Berkeley Software Distribution wikipedia , lookup
Distributed operating system wikipedia , lookup
Copland (operating system) wikipedia , lookup
Plan 9 from Bell Labs wikipedia , lookup
Windows NT startup process wikipedia , lookup
Process management (computing) wikipedia , lookup
Burroughs MCP wikipedia , lookup
Library (computing) wikipedia , lookup
Spring (operating system) wikipedia , lookup
Transcript
COS 318: Operating Systems Overview Kai Li and Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall13/cos318/ Logistics u Precepts: l u Design review: l u Sun 9/29 at 11:55pm Reminder: l u Mon 9/23: 11am- - 7:40pm, 010 Friends center Project 1 due: l u Tue: 7:30pm-8:30pm, 105 CS building Subscribe to the cos318 mailing list! To do: l Lab partner? Enrollment? 2 Who am I? A builder: practical, hands-on u A philosopher? u Search for beauty J u Operating systems spans the spectrum u Abstract Simple, powerful ideas Concrete Making things work 3 Today Overview of OS structure u Overview of OS components u 4 Hardware of A Typical Computer CPU Memory ... CPU Chipset I/O bus ROM Network 5 Computing machinery Analytical Engine (~1850) Charles Babbage ENIAC (~1946) Eckert & Mauchly, UPenn Johnniac (~1953) von Neumann, IAS A Typical Computer System CPU .. . Memory Application CPU Operating System BIOS ROM OS Apps Data Network 7 Hardware Interrupts Raised by external events u Interrupt handler is in the kernel u Switch to another process l Overlap I/O with CPU l … l u Eventually resume the interrupted process 0: 1: … Interrupt handler i: i+1: … N: 8 Typical Unix OS Structure Application Libraries User level Kernel level Portable OS Layer Machine-dependent layer 9 Typical Unix OS Structure Application User function calls written by programmers and compiled by programmers. Libraries Portable OS Layer Machine-dependent layer 10 Typical Unix OS Structure Application Libraries • Written by elves • Objects pre-compiled • Defined in headers • Input to linker • Invoked like functions • May be “resolved” when program is loaded Portable OS Layer Machine-dependent layer 11 Elves 12 Pipeline of Creating An Executable File foo.c gcc foo.s as foo.o bar.c gcc bar.s as bar.o libc.a u u u u u ld a.out … gcc can compile, assemble, and link together Compiler (part of gcc) compiles a program into assembly Assembler compiles assembly code into relocatable object file Linker links object files into an executable For more information: l l Read man page of elf, ld, and nm Read the document of ELF 13 Execution (Run An Application) u On Unix, “loader” does the job Read an executable file l Layout the code, data, heap and stack l Dynamically link to shared libraries l Prepare for the OS kernel to run the application l E.g., on Linux, “man ld-linux” l *.o, *.a ld a.out loader Application Shared library 14 What’s An Application? u Four segments Code/Text – instructions l Data – initialized global variables l Stack l Heap l u Why? Separate code and data l Stack and heap go towards each other l Stack 2n -1 Heap Initialized data Code 0 15 Responsibilities u Stack l l l u Heap l l l u Layout by compiler Allocate/deallocate by process creation (fork) and termination Names are relative to stack pointer and entirely local Linker and loader say the starting address Allocate/deallocate by library calls such as malloc() and free() Application program use the library calls to manage Global data/code l l l l Compiler allocate statically Compiler emit names and symbolic references Linker translate references and relocate addresses Loader finally lay them out in memory 16 Typical Unix OS Structure Application Libraries Portable OS Layer “Guts” of system calls Machine-dependent layer 17 OS Service Examples u Examples that are not provided at user level System calls: file open, close, read and write l Control the CPU so that users won’t get stuck by running l • while ( 1 ) ; l Protection: • Keep user programs from crashing OS • Keep user programs from crashing each other u System calls are typically traps or exceptions l l System calls are implemented in the kernel When finishing the service, a system returns to the user code 18 Typical Unix OS Structure Application Libraries Portable OS Layer • Bootstrap • System initialization • Interrupt and exception • I/O device driver • Memory management • Mode switching • Processor management Machine-dependent layer 19 Software “Onion” Layers Applications Libraries User and Kernel boundary OS Services Device Kernel HW Driver 20 Today Overview of OS structure u Overview of OS components u 21 Processor Management u Goals Overlap between I/O and computation l Time sharing l Multiple CPU allocations l u CPU I/O CPU I/O CPU CPU Issues Do not waste CPU resources l Synchronization and mutual exclusion l Fairness and deadlock free l CPU CPU I/O CPU CPU 22 Memory Management u Goals Support programs to run l Allocation and management l Transfers from and to secondary storage Register: 1x l u Issues Efficiency & convenience l Fairness l Protection l L1 cache: 2-4x L2 cache: ~10x L3 cache: ~50x DRAM: ~200-500x Disks: ~30M x Archive storage: >1000M x 23 I/O Device Management u Goals Interactions between devices and applications l Ability to plug in new devices l u Issues Efficiency l Fairness l Protection and sharing l User 1 ... User n Library support Driver Driver I/O device I/O device ... 24 File System u Goals: l l u User 1 ... User n A typical file system l l l u Manage disk blocks Map between files and disk blocks Open a file with authentication Read/write data in files Close a file File system services File ... File Issues l l l l Reliability Safety Efficiency Manageability 25 Window Systems u Goals Interacting with a user l Interfaces to examine and manage apps and the system l u Issues Direct inputs from keyboard and mouse l Display output from applications and systems l Division of labor l • All in the kernel (Windows) • All at user level • Split between user and kernel (Unix) 26 Bootstrap u u u u u u u Power up a computer Processor reset l Set to known state l Jump to ROM code (BIOS is in ROM) Load in the boot loader from stable storage Jump to the boot loader Load the rest of the operating system Initialize and run Question: Can BIOS be on disk? Boot loader Boot loader OS sector 1 OS sector 2 . . . OS sector n 27 Ways to Develop An Operating System A hardware simulator u A virtual machine u A good kernel debugger u When OS crashes, always goes to the debugger l Debugging over the network l u Smart people 1972 1998 28 Summary Interrupts u User level vs. kernel level u OS services u Processor l Memory l I/O devices l File system l Window system l u Booting the OS 29