DOC PREVIEW
Princeton COS 318 - Overview

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

COS 318: Operating Systems Overview Kai Li Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/)2 Logistics  Precepts:  Tue, Wed: TBD, 105 CS building  Design review:  9/28 during 6-10pm, 010 Friends center  Project 1 due:  10/5 at 11:59pm  Reminder:  Subscribe to the cos318 mailing list today!3 Today  Overview of OS structure  Overview of OS components4 Hardware of A Typical Computer CPU Chipset Memory I/O bus CPU . . . Network ROMComputing machinery Analytical Engine (~1850) Charles Babbage ENIAC (~1946) Eckert & Mauchly, UPenn Johnniac (~1953) von Neumann, IAS6 A Typical Computer System Memory CPU CPU . . . OS Apps Data Network Application Operating System ROM BIOS7 Interrupts  Raised by external events  Interrupt handler is in the kernel  Switch to another process  Overlap I/O with CPU  …  Eventually resume the interrupted process 0: 1: … i: i+1: … N: Interrupt handler8 Typical Unix OS Structure Application Libraries Machine-dependent layer User level Kernel level Portable OS Layer9 Typical Unix OS Structure Application Libraries Machine-dependent layer Portable OS Layer User function calls written by programmers and compiled by programmers.10 Typical Unix OS Structure Application Libraries Machine-dependent layer Portable OS Layer • Written by elves • Objects pre-compiled • Defined in headers • Input to linker • Invoked like functions • May be “resolved” when program is loaded11 Pipeline of Creating An Executable File  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:  Read man page of a.out, elf, ld, and nm  Read the document of ELF foo.c gcc as foo.s foo.o ld bar.c gcc as bar.s bar.o libc.a … a.out12 Execution (Run An Application)  On Unix, “loader” does the job  Read an executable file  Layout the code, data, heap and stack  Dynamically link to shared libraries  Prepare for the OS kernel to run the application a.out loader *.o, *.a ld Application Shared library13 What’s An Application?  Four segments  Code/Text – instructions  Data – initialized global variables  Stack  Heap  Why?  Separate code and data  Stack and heap go towards each other Stack Heap Initialized data Code 2n -1 014 Responsibilities  Stack  Layout by compiler  Allocate/deallocate by process creation (fork) and termination  Names are relative off of stack pointer and entirely local  Heap  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  Compiler allocate statically  Compiler emit names and symbolic references  Linker translate references and relocate addresses  Loader finally lay them out in memory15 Typical Unix OS Structure Application Libraries Machine-dependent layer Portable OS Layer “Guts” of system calls16 OS Service Examples  Examples that are not provided at user level  System calls: file open, close, read and write  Control the CPU so that users won’t stuck by running • while ( 1 ) ;  Protection: • Keep user programs from crashing OS • Keep user programs from crashing each other  System calls are typically traps or exceptions  System calls are implemented in the kernel  When finishing the service, a system returns to the user code17 Typical Unix OS Structure Application Libraries Machine-dependent layer Portable OS Layer • Bootstrap • System initialization • Interrupt and exception • I/O device driver • Memory management • Mode switching • Processor management18 Applications Software “Onion” Layers Libraries OS Services Device Driver Kernel User and Kernel boundary HW19 Processor Management  Goals  Overlap between I/O and computation  Time sharing  Multiple CPU allocations  Issues  Do not waste CPU resources  Synchronization and mutual exclusion  Fairness and deadlock free CPU I/O CPU CPU CPU CPU I/O CPU CPU CPU I/O20 Memory Management  Goals  Support programs to run  Allocation and management  Transfers from and to secondary storage  Issues  Efficiency & convenience  Fairness  Protection Register: 1x L1 cache: 2-4x L2 cache: ~10x L3 cache: ~50x DRAM: ~200-500x Disks: ~30M x Archive storage: >1000M x21 I/O Device Management  Goals  Interactions between devices and applications  Ability to plug in new devices  Issues  Efficiency  Fairness  Protection and sharing User 1 User n . . . Library support I/O device I/O device . . . Driver Driver22 File System  Goals:  Manage disk blocks  Map between files and disk blocks  A typical file system  Open a file with authentication  Read/write data in files  Close a file  Issues  Reliability  Safety  Efficiency  Manageability User 1 User n . . . File system services File File . . .23 Window Systems  Goals  Interacting with a user  Interfaces to examine and manage apps and the system  Issues  Direct inputs from keyboard and mouse  Display output from applications and systems  Labor of division • All in the kernel (Windows) • All at user level • Split between user and kernel (Unix)24 Bootstrap  Power up a computer  Processor reset  Set to known state  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 OS sector 1 OS sector 2 OS sector n . . . Boot loader25 Ways to Develop An Operating System  A hardware simulator  A virtual machine  A good kernel debugger  When OS crashes, always goes to the debugger  Debugging over the network  Hire some


View Full Document

Princeton COS 318 - Overview

Documents in this Course
Deadlocks

Deadlocks

25 pages

lectute 2

lectute 2

28 pages

Lecturel

Lecturel

24 pages

Real mode

Real mode

49 pages

Lecture 2

Lecture 2

54 pages

lecture 5

lecture 5

27 pages

Load more
Download Overview
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Overview and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Overview 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?