Opera;ng Systems CMPSCI 377 Tim Richards University of MassachuseIs Amherst 1 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Today’s Class § Organiza)onal mee)ng – Course organiza)on & outline – Policies – Prerequisites & course sign-up § Intro to Opera)ng systems UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 2 Work § Read Chapter 1 § W01 Quiz on Moodle § Homework 1 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 3 Organiza;onal Informa;on § Course web page – Visit hJp://umass-cs-377.github.io – Moodle 377 page: to turn in assignments, discussion forums etc – Piazza § Contact info – richards@cs.umass.edu § Primary TA: Teddy Sudol tsudol@cs.umass.edu § Secondary TA: Tianbo Gu tbgu@cs.umass.edu § Discussion sec)on (Wednesdays 11:15-12:05) UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 3 Prerequisites and Syllabus § CMPSCI 230: computer Systems Principles § Textbook: Opera)ng System Concepts (Silberschatz,Galvin,Gagne) 9th ed § Course requirements – Several homeworks plus several in-class assignments (10%) – Weekly quizzes (10%) – Several lab/programming assignments (40%) – 3 exams (40%) – two midterms and a final § Late policies and chea)ng – Automa)c 48 hour late extension UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Course Organiza;on: Misc § Accounts in the Ed-lab: 30+ Linux-based PCs § Discussion sec)on to help you with Lab assignments and course concepts § Office hours: – Instructor: W 10:00 - 11:00a, CS 258 or by app – TA Office hrs and loca)on: Teddy - M 11:00-1p, CS 207 (star)ng next week) Tianbo - F 11:00-1p, CS 207 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Course Requirements § Note: Percentages are subject to revision. § Programming projects: 40% – Strict late policy! § In-class exams: 40% § Homework & Classwork: 10% § Quizzes: 10% UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 6 Exams § 3 Exams: 2 Midterms and 1 final exam § Midterm exam 1 – Feb 18, 2016 (in class) § Midterm exam 2 – Mar 24, 2016 (in class) § Final exam – Apr 29, 10:30a-12:30p, ILC S211 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 8 Labs § 3-4 Projects – Focus on topics covered in the class § Projects will use C/C++ (and some Java) § May work in groups of 2 § EdLab Accounts or use your own machine UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 7 Plagiarism § Chea)ng includes: – “Borrowing” code from someone • This includes reading previous solu)ons – – – – – Giving code to someone (even next year) Copying code from anyone (including the net) Hiring someone to write your code Submiong someone else’s code as your own Looking at anyone else’s code UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 8 Cell Phone and Laptop Policy class use policy: Don’t! Cell phones should be off or on silent alert Tex)ng is strictly prohibited in class Laptops and tablets may be used in class: No email, browsing, facebook, twiJer during class lectures § Laptops allowed in the discussion sec)on § § § § UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 9 Course Outline & Topics § § § § § Introduc)on Processes and Threads Memory Management Storage and File Systems Distributed Systems UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 10 What’s An Opera;ng System? § Defini)on has changed over years – Originally, very bare bones – Now, includes more and more § Opera)ng System (OS) – Interface between the user and the architecture – Implements a virtual machine that is – (hopefully) easier to program than raw hardware. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 11 OS: Tradi;onal View § Interface between user and architecture – Hides architectural details § Implements virtual machine: – Easier to program than raw hardware § Illusionist – Bigger, faster, reliable § Government – Divides resources – “Taxes” = overhead User-level Applications virtual machine interface Operating System physical machine interface Hardware UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 13 New Developments in OS § Opera)ng systems: ac)ve field of research – Demands on OS’s growing – New applica)on spaces (Web, Grid, Cloud) – Rapidly evolving hardware § Advent of open-source opera)ng systems – Linux etc. – You can contribute to and develop OS’s! – Excellent research platorm UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 14 OS Most Notable Features • Services: The OS provides standard services (the interface) which the hardware implements. – Examples: the file system, virtual memory, networking, CPU scheduling, and time-sharing • Coordination: The OS coordinates multiple applications and users to achieve fairness and efficiency (throughput). – Examples: concurrency, memory protection, networking, and security. • Goal: Design an OS so that the machine is convenient to use (a software engineering problem) and efficient (a system and engineering problem). UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Why Study Opera;ng Systems? • Abstraction: How to get the OS to give users an illusion of infinite memory, CPUs, resources, world wide computing, etc. • System Design: How to make tradeoffs between – performance and the convenience of OS abstractions, – performance and the simplicity of OS design, and – putting functionality in hardware or software. • Basic Understanding: The OS provides the services that allow application programs to work at all. • System Intersection Point: The OS is the point where hardware and software meet. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Why Study Opera;ng Systems? Not many opera)ng systems are under development, so you are unlikely to get a job building an OS. However, understanding opera)ng systems will enable you to use your computer more effec)vely. They also serve as an excellent example of system design issues whose results and ideas you will apply elsewhere. § Background: To understand this course you must have a solid basic understanding of hardware (CPU instruc)on sets, memory hierarchies, I/O systems, etc.) and solid programming skills (complex data structures, classes as an encapsula)on mechanism, etc.) – Obviously, you cannot understand the implica)ons of how components intersect without understanding the components. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Build Large Computer Systems § OS as an example of large system design § Goals: Fast, reliable, large scale § To build these systems, you need to know – Each computer: • • • • • Architectural details that maJer C and C++ (niJy griJy & more) Memory management & locality Concurrency & scheduling Disks, network, file systems – Across cluster: • Server architectures • Distributed compu)ng, file systems UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 18 History of Opera;ng Systems § And now, for some historical context – From mainframes to web-based systems in nine slides UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 19 1. Single-User Computers § Hardware: expensive; humans: cheap § One user at a )me on console – Interac)ng with as program runs § Computer executes one func)on at a )me – No overlap: computa)on & I/O § User must be at console to debug § Mul)ple users = inefficient use of machine UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 20 2. Batch Processing § Execute mul)ple “jobs” in batch: – – – – Load program Run Print results, dump machine state Repeat § Users submit jobs (on cards or tape) § Human schedules jobs § Opera)ng system loads & runs jobs § More efficient use of machine UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 21 3. Overlap I/O and Computa;on § Before: machine waits for I/O to complete § New approach: – Allow CPU to execute while wai)ng – Add buffering • Data fills “buffer” and then output – and interrupt handling • I/O events trigger a signal (“interrupt”) § More efficient use of machine – s)ll one job at a )me UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 22 4. Mul;programming § Several programs to run simultaneously – Run one job un)l I/O – Run another job, etc. § OS manages interac)ons – Which jobs to run (schedule) – Protects program’s memory from others – Decides which to resume when CPU available UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 23 OS Complexity § Increased func)onality & complexity § First OS failures – Mul)cs (GE & MIT): announced 1963, released 1969 – OS/360 released with 1000 known bugs § Need to treat OS design scien)fically § Managing complexity becomes key to… UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 24 The Renaissance (1970’s) § Hardware: cheap; humans: expensive § Users share system via terminals § The UNIX era – Mul)cs: • army of programmers, six years – UNIX: • three guys, two years • “Shell”: composable commands • No dis)nc)on between programs & data § But: response )me & thrashing UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 25 Industrial Revolu;on (1980’s) § Hardware very cheap; § humans expensive § Widespread use of PCs – IBM PC: 1981, Macintosh: 1984 § Simple OS (DOS, MacOS) – No mul)programming, concurrency, memory protec)on, virtual memory, … – Later: networking, file-sharing, remote prin)ng… – GUI added to OS (“WIMP”) UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 26 The Modern Era (1990’s-now) § Hardware cheap; processing demands increasing § “Real” opera)ng systems on PC’s – NT (1991); Mac OS X; Linux § Different modali)es: – Real-)me: Strict or loose deadlines – Sensor/Embedded: Many small computers – Parallel: Mul)ple processors, one machine – Distributed: Mul)ple networked processors • Think P2P, the Web, Google, cloud UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 27 Architectural Trends § Big Changes – In 50 years, almost every computer component now 9 orders of magnitude faster, larger, cheaper 1983 1999 0.5 500 $100,000 $500 memory 1 MB 1 GB network 10 Mbit/s 1 Gb/s 1 GB 1 Tbyte examples Millions of Instructions Per Second MIPS cost/MIPS disk UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 28 History Lesson This degree of change has no counterpart in any other area of business. Examples: § Transporta)on -- over the last 200 years, we have gone from horseback (10 miles/hour) to the Concorde (1000 miles/hour) 2 orders of magnitude. § Communica)on -- at the inven)on of the telephone (voice), TV (video) and fax (text \& pictures), communica)on went from the speed of transporta)on to nearly the speed of light - 7 orders of magnitude. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science Orders of Magnitude § 10^0 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 30 Orders of Magnitude § 10^1 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 31 Orders of Magnitude § 10^2 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 32 Orders of Magnitude § 10^3 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 33 Orders of Magnitude § 10^4 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 34 Orders of Magnitude § 10^5 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 35 Orders of Magnitude § 10^6 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 36 Orders of Magnitude § 10^7 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 37 Orders of Magnitude § 10^8 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 38 Orders of Magnitude § 10^9 UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 39 Coming Soon § Moore’s Law – running out of steam § New “features” coming – Mul)ple cores – Unreliable memory – Serious power/heat constraints § Other tradeoffs possible – Compu)ng power for reliability… UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 40 What’s an OS? Bill Gates says… UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 12 What is important to you? § From your perspec)ve, think about the following: – What is an opera)ng system? – What is the most important aspect of an opera)ng system (according to your defini)on) and why? § Take a moment to think about this… § Then, write a short paragraph answering these ques)ons. 8-digit spire ID and name at the top please. Hand in at end of class. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 43 Perspec;ves § We look at opera)ng systems from… § The User View – Ease of use (mostly) – Performance (some) § The System View – Resource Alloca)on – Program Execu)on UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 44 OS Defini;on § An OS covers many roles and func)ons. § They are ubiquitous in our every day lives – sure: laptops, desktops, phones, etc. – but: cars, toasters, refrigerator, homes, medical equipment, etc. § Defini;on? – In general, we have no adequate defini)on of an opera)ng system. – They exist because they offer some reasonable way to solve the problem of crea)ng a usable “compu)ng system”. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 45 So, what is an OS? § Huge Range – Big (Windows, Mac OSX, Your Car) – Small (Wearable Computers) § We will follow this common def. of an OS: – A program that constantly executes: kernel – Libraries that help the kernel: middleware – Programs that help the OS: system programs UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 46 Computer System Organiza;on UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 47 Computer System Organiza;on Kernel UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 48 Bootstrap Program § How does an OS come to life? § The Bootstrap Program – A small program typically stored in computer hardware (ROM) – Ini)alizes computer hardware – Knows where to “find” the instruc)ons for the opera)ng system kernel, loads part of it into memory, and hands over control. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 49 System Processes § OS Startup – Kernel is loaded into memory – Begins execu)on – Starts system processes (daemons) these run in the “background” § Then, we wait… – The OS waits for an event to occur – When an event occurs, the OS will step in to handle the event. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 50 Events! § How do we know when an event happens? – An interrupt is triggered! – This originates from either hardware or so~ware § Hardware – May trigger an interrupt at any )me by sending a single to the CPU (via system bus) § Sohware – May trigger an interrupt with a system call UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 51 Interrupt Timeline UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 52 Interrupt Timeline Process makes I/O Request UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 53 Interrupt Timeline Sends trap to indicate completion. UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 54 Interrupt Timeline Process suspends. Transfers I/O to memory UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 55 Interrupt Timeline Process resumes execution UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 56 Interrupt Timeline Another I/O request UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 57 Interrupt Timeline Transfer done, signals completion UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 58 Interrupt Timeline Process suspends, Handles I/O UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 59 Interrupt Timeline Execution resumes UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 60 Mul;programming § Modern Opera)ng Systems – Allow mul)ple programs/processes to execute concurrently. – Interrupts are key to )me sharing between processes. – Events are core to an OS opera)on. § The Web – Also event driven! – Is the web an opera)ng system? UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 61 Next Time § OS and Computer Architecture UNIVERSITY OF MASSACHUSETTS AMHERST • College of Informa;on and Computer Science 62