COS 318: Operating Systems

Similar documents
COS 318: Operating Systems. Overview. Jaswinder Pal Singh Computer Science Department Princeton University

COS 318: Operating Systems

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University

9/19/18. COS 318: Operating Systems. Overview. Important Times. Hardware of A Typical Computer. Today CPU. I/O bus. Network

COS 318: Operating Systems. Introduction

Operating System Overview

Introduction and Overview

Topics. Operating System I. What is an Operating System? Let s Get Started! What is an Operating System? OS History.

Topics. Operating System. What is an Operating System? Let s Get Started! What is an Operating System? Where in the Book are we?

Fundamental Concepts and History

Misc. Third Generation Batch Multiprogramming. Fourth Generation Time Sharing. Last Time Evolution of OSs

Architectural Support for Operating Systems

CS 153 Design of Operating Systems

Computer System Overview

Operating Systems Course 2 nd semester 2016/2017 Chapter 1: Introduction

Introduction to OS. Introduction MOS Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

CSC Operating Systems Fall Lecture - I Introduction. Tevfik Ko!ar. Louisiana State University. August 25 th, Contact Information

Hardware OS & OS- Application interface

Introduction to Computer Systems and Operating Systems

Architecture and OS. To do. q Architecture impact on OS q OS impact on architecture q Next time: OS components and structure

CS450/550 Operating Systems

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Introduction. What is an Operating System? A Modern Computer System. Computer System Components. What is an Operating System?

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Basic Concepts & OS History

Course Content. 07-Feb-17 Faculty of Computer Science & Engineering 1 BK TP.HCM

Lec 13: Linking and Memory. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

INTRODUCTION TO OPERATING SYSTEMS. Jo, Heeseung

Reserves time on a paper sign-up sheet. Programmer runs his own program. Relays or vacuum tube hardware. Plug board or punch card input.

CS370 Operating Systems

Four Components of a Computer System

Operating System Review

OS - Introduction Ezio Bartocci Institute for Computer Engineering

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

Operating Systems: Internals and Design Principles. Chapter 2 Operating System Overview Seventh Edition By William Stallings

Protection and System Calls. Otto J. Anshus

Introduction to Operating Systems. Jo, Heeseung

Timers 1 / 46. Jiffies. Potent and Evil Magic

Operating System Concepts Rab Nawaz Khan Jadoon

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

7/20/2008. What Operating Systems Do Computer-System Organization

Chapter 1: Introduction

Introduction to OS (cs1550)

Lecture 1 Introduction (Chapter 1 of Textbook)

Chapter 5 - Input / Output

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Introduction to Computer Systems

Chapter 1: Introduction. Chapter 1: Introduction

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Chapter 2: Computer-System Structures. Hmm this looks like a Computer System?

Uniprocessor Computer Architecture Example: Cray T3E

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Chapter 1: Introduction

18-447: Computer Architecture Lecture 16: Virtual Memory

Operating Systems Fundamentals. What is an Operating System? Focus. Computer System Components. Chapter 1: Introduction

NETW3005 Operating Systems Lecture 1: Introduction and history of O/Ss

Operating Systems: Overview and Introduction


Last class: Today: Course administration OS definition, some history. Background on Computer Architecture

OPERATING SYSTEM. Functions of Operating System:

CSC 453 Operating Systems

Operating Systems. Lecture Course in Autumn Term 2015 University of Birmingham. Eike Ritter. September 22, 2015

Introduction To Operating System

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Module 1 Introduction/OS Overview

Contents. Today's Topic: Introduction to Operating Systems

Memory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

OPERATING SYSTEMS UNIT - 1

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Operating Systems (2INC0) 2017/18

Chapter Seven Morgan Kaufmann Publishers

OS: An Overview. ICS332 Operating Systems

Principles of Operating Systems CS 446/646

Even coarse architectural trends impact tremendously the design of systems

Chapter 2. OS Overview

Chapter 1: Introduction

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

1. Operating System Concepts

UNIT I OPERATING SYSTEMS OVERVIEW

OPERATING SYSTEMS CS136

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

Computer Overview. A computer item you can physically see or touch. A computer program that tells computer hardware how to operate.

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System?

Introduction to Operating System. Dr. Aarti Singh Professor MMICT&BM MMU

Operating Systems CS 571

Welcome to CSE 4300! Spring 2018

Main Points of the Computer Organization and System Software Module

COSC243 Part 2: Operating Systems

Introduction to Operating Systems

CS370 Operating Systems

Introduction to Computer Systems

European University of Lefke. Instructor: Dr. Arif SARI

Chapter 1: Introduction

CS 126 Lecture S4: Operating Systems

Operating Systems, Fall

Transcription:

COS 318: Operating Systems Lecture 2: Continuation of Introduction Overview of Operating Systems Jaswinder Pal Singh Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/)

Logistics! Precepts: " Wed: 8:30-9:30pm, 105 CS building! Please check times for Design review and Assignment 1 due date on the Web site! Reminder: " Register for the cos318 mailing list today! 2

Today! Overview of OS structure! Overview of OS components 3

Previous Lecture! Course Staff and Logistics! What is an operating system?! Evolution of computing and operating systems! Why study operating systems?! What s in COS 318? 4

Today! Evolution of computing and operating systems! Why study operating systems?! What s in COS 318?! Overview of Operating Systems 5

A Typical Academic Computer (1986 v. 2007) 1986 2007 Ratio CPU clock 4Mhz 4!3Ghz 3000x $/machine $60k $600 1/100x DRAM 1MB 2GB 2000x Disk 50MB 0.5-1TB 10K-20Kx Network BW 10Mbits/sec 1GBits/sec 100x Address bits 32 64 2x Users/machine 10s < 1 >10x $/Performance $60k $600/3000 1/200,000x 6

Exponential Growth in Computing, Comm.! Performance/Price doubles every 18 months! 100x per decade! Progress in next 18 months = ALL previous progress " New storage = sum of all old storage (ever) " New processing = sum of all old processing.! This has led to some broad phases in computing, and correspondingly in the nature of operating systems!courtesy Jim Gray 15 years ago 7

History of Computers and OSes Generations: (1945 55) Vacuum Tubes (1955 65) Transistors and Batch Systems (1965 1980) ICs and Multiprogramming (1980 Present) Personal Computers

Phase 1: The Early Days! Hardware very expensive, humans cheap! When was the first functioning digital computer built?! What was it built from?! How was the machine programmed?! What was the operating system?! The big innovation: punch cards! The really big one: the transistor " Made computers reliable enough to be sold to and operated by customers 9

Phase 2: Transistors and Batch Systems! Hardware still expensive, humans relatively cheap! An early batch system! Programmers bring cards to reader system! Reader system puts jobs on tape

Phase 2: Transistors and Batch Systems! An early batch system! Operator carries input tape to main computer! Main computer computes and puts output on tape! Operator carries output tape to printer system, which prints output

Punch cards and Computer Jobs

Phase 3: ICs and Multiprogramming! Integrated circuits allowed families of computers to be built that were compatible! Single OS to run on all (IBM OS/360): big and bloated! Key innovation: multiprogramming! What happens when a job is waiting on I/O! What if jobs spend a lot of the time waiting on I/O?

Phase 3: ICs and Multiprogramming! Multiple jobs resident in computer s memory! Hardware switches between them (interrupts)! Hardware protects from one another (mem protection)! Computer reads jobs from cards as jobs finish (spooling)! Still batch systems: can t debug online! Solution: time-sharing

Phase 3: ICs and Multiprogramming! Time-sharing:! Users at terminals simultaneously! Computer switches among active jobs /sessions! Shorter, interactive commands serviced faster App1 App2... App2 Time-sharing OS Hardware hardware

Phase 3: ICs and Multiprogramming! The extreme: computer as a utility: MULTICS (late 60s)! Problem: thrashing as no. of users increases! Didn t work then, but idea may be back! Let others administer and manage; I ll just use! ICs led to mini-computers: cheap, small, powerful! Stripped down version of MULTICS, led to UNIX! Two branches (Sys V, BSD), standardized as POSIX! Free follow-ups: Minix (education), Linux (production)

Phase 4: HW Cheaper, Human More Costly! Personal computer " Altos OS, Ethernet, Bitmap display, laser printer " Pop-menu window interface, email, publishing SW, spreadsheet, FTP, Telnet " Eventually >100M units per year! PC operating system " Memory protection " Multiprogramming " Networking 17

Now: > 1 Machines per User! Pervasive computers " " " "! Wearable computers Communication devices Entertainment equipment Computerized vehicle OS are specialized " " Embedded OS Specially configured generalpurpose OS 18

Now: Multiple Processors per Machine! Multiprocessors " SMP: Symmetric MultiProcessor " ccnuma: Cache-Coherent Non-Uniform Memory Access " General-purpose, single-image OS with multiproccesor support! Multicomputers " Supercomputer with many CPUs and highspeed communication " Specialized OS with special messagepassing support! Clusters " A network of PCs " Commodity OS 19

Now: Multiple Cores per Processor! Multicore or Manycore transition " Intel and AMD have released 4-core and soon 6-core CPUs " SUN s Niagara processor has 8-cores " Azul Vega8 now packs 24 cores onto the same chip " Intel has a TFlop-chip with 80 cores " Ambric Am2045: 336-core Array (embedded, and accelerators)! Accelerated need for software support " OS support for many cores; parallel programming of applications 20

Summary: Evolution of Computers 60 s-70 s - Mainframes! Rise of IBM 70 s - 80 s Minicomputers! Rise of Digital Equipment Corporation 80 s - 90 s PCs! Rise of Intel, Microsoft Now Post-PC! Distributed applications 21

Summary: Evolution and Implications for OS Mainframe Mini Micro System $ / Worker $ Goal 10:1 100:1 System utilization 10:1 1:1 Overall cost 1:10-1:100 Productivity Target Capacity Features Ease of Use 22

Today! Evolution of computing and operating systems! Why study operating systems?! What s in COS 318?! Overview of Operating Systems 23

Why Study OS?! OS is a key part of a computer system " It makes our life better (or worse) " It is magic to realize what we want " It gives us power! Learn about concurrency " Parallel programs run on OS " OS runs on parallel hardware: all hw becoming parallel " OS is great way to learn concurrent programming! Understand how a system works " How many procedures does a key stroke invoke? " What happens when program references 0 as a pointer? " Real OS is huge and impossible to read everything, but building a small OS will go a long way 24

Why Study OS?! Important for studying further areas " Networking, distributed systems,! Full employment " New hardware capabilities and organizations " New features " New approaches " E.g. handheld computers, Java, WWW " Engineering tradeoffs, keep changing as the hardware changes from below and the needs of apps from above! Lots of jargon: sound smart (or super-nerdy) 25

Today! Evolution of computing and operating systems! Why study operating systems?! What s in COS 318?! Overview of Operating Systems 26

What Is in COS 318?! Methodology " Lectures with discussions " Readings with topics " A lot of design and rationale, some theory, a fair bit of practice " Six projects to build key aspects of a basic OS! Covered concepts " Operating system structure Processes, threads, system calls and virtual machine monitor " Synchronization Mutex, semaphores and monitors " I/O subsystems Device drivers, IPC, and introduction to networking " Virtual memory Address spaces and paging " Storage system Disks and file system 27

What is COS 318 Like?! Is tt theoretical or practical? " Focus on concepts, but also getting hands dirty in projects " More about engineering tradeoffs, constraints, optimization and imperfection than about optimal results and beautiful mathematics " High rate of change in the field yet lots of inertia in OSes! Is it easy? " No. Fast paced, hard material, a lot of programming! What will enable me to succeed? " Solid C background, pre-reqs, tradeoff thinking " NOT schedule overload 28

Today! Evolution of computing and operating systems! Why study operating systems?! What s in COS 318?! Overview of Operating Systems 29

Hardware of A Typical Computer CPU... CPU Memory Chipset I/O bus ROM Network 30

A Typical Computer System CPU. CPU BIOS ROM Memory Application Operating System OS Apps Data Network 31

Typical Unix OS Structure Application Libraries Portable OS Layer User level Kernel level Machine-dependent layer 32

Typical Unix OS Structure Application User function calls written by programmers and compiled by programmers. Libraries Portable OS Layer Machine-dependent layer 33

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 34

Pipeline of Creating An Executable File foo.c gcc foo.s as foo.o bar.c gcc bar.s as bar.o ld a.out libc.a! 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 35

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 *.o, *.a ld a.out loader Application Shared library 36

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 2 n -1 0 37

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 memory 38

Typical Unix OS Structure Application Libraries Portable OS Layer Guts of system calls Machine-dependent layer 39

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 " Application traps to kernel to invoke a system call " When finishing the service, a system returns to the user code 40

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! A way for CPU to wait for long-latency events (like I/O) to happen 0: 1: i: i+1: N: Interrupt handler 41

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 42

Software Onion Layers User and Kernel boundary Device Applications OS Libraries Kernel Services HW Driver 43

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 I/O CPU CPU CPU I/O CPU CPU 44

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 x 45

I/O Device Management! Goals " Interactions between devices and applications " Ability to plug in new devices! Issues " Efficiency " Fairness " Protection and sharing User 1 Driver I/O device... Library support... User n Driver I/O device 46

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 47

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) 48

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 Boot loader OS sector 1 OS sector 2. OS sector n 49

System Boot! Power on (processor waits until Power Good Signal)! Processor jumps on a PC to address FFFF0h 1M= 1,048,576= 2 20 =FFFFFh+1 FFFFFh=FFFF0h+16 is the end of the (first 1MB of) system memory The original PC using Intel 8088 had 20 address lines :-)! (FFFFFFF0h) is a JMP instruction to the ROM BIOS startup program Maps to FFFFFFF0h= 2 32-16 COS318 Lec 2 50

ROM Bios Startup Program (1)! POST (Power-On Self-Test) If pass then AX:=0; DH:=5 (586: Pentium); Stop booting if fatal errors, and report! Look for video card and execute built-in ROM BIOS code (normally at C000h)! Look for other devices ROM BIOS code IDE/ATA disk ROM BIOS at C8000h (=819,200d)! Display startup screen BIOS information! Execute more tests memory system inventory SCSI disks: must often provide their own BIOS COS318 Lec 2 51

ROM BIOS startup program (2)! Look for logical devices " Label them Serial ports COM 1, 2, 3, 4 Parallel ports LPT 1, 2, 3 " Assign each an I/O address and IRQ! Detect and configure Plug-and-Play (PnP) devices! Display configuration information on screen COS318 Lec 2 52

ROM BIOS startup program (3)! Search for a drive to BOOT from " Floppy or Hard disk Boot at cylinder 0, head 0, sector 1! Load code in boot sector! Execute boot loader! Boot loader loads program to be booted If no OS: "Non-system disk or disk error - Replace and press any key when ready"! Transfer control to loaded program! Is it okay to boot at first sector on the floppy or disk? COS318 Lec 2 53

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 54