CSE 451: Operating Systems Winter Module 2 Architectural Support for Operating Systems

Similar documents
Even coarse architectural trends impact tremendously the design of systems

Even coarse architectural trends impact tremendously the design of systems. Even coarse architectural trends impact tremendously the design of systems

Even coarse architectural trends impact tremendously the design of systems

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

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

Architectural Support for Operating Systems

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

Architectural Support for Operating Systems

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Hardware OS & OS- Application interface

CSE 451: Operating Systems Spring Module 12 Secondary Storage

Architectural Support for OS

Lecture 2: Architectural Support for OSes

for Operating Systems Computer Systems Laboratory Sungkyunkwan University

Architectural Support for Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

CSE 153 Design of Operating Systems

Anne Bracy CS 3410 Computer Science Cornell University

Common Computer-System and OS Structures

Lecture 2: September 9

Topic 18: Virtual Memory

CSE 153 Design of Operating Systems Fall 18

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

What s in a process?

I/O Systems. Jo, Heeseung

CSC 2405: Computer Systems II

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

OS structure. Process management. Major OS components. CSE 451: Operating Systems Spring Module 3 Operating System Components and Structure

Uniprocessor Computer Architecture Example: Cray T3E

CS 5460/6460 Operating Systems

Lec 22: Interrupts. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

Basic Computer Hardware

Goals of memory management

virtual memory Page 1 CSE 361S Disk Disk

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs

CS162 Operating Systems and Systems Programming Lecture 14. Caching (Finished), Demand Paging

Anne Bracy CS 3410 Computer Science Cornell University

Interrupts & System Calls

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation

CS370 Operating Systems

CS330: Operating System and Lab. (Spring 2006) I/O Systems

CS5460: Operating Systems

Topic 18 (updated): Virtual Memory

Review: Hardware user/kernel boundary

CS510 Operating System Foundations. Jonathan Walpole

What s in a traditional process? Concurrency/Parallelism. What s needed? CSE 451: Operating Systems Autumn 2012

Operating Systems ECE344

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Computer Architecture and OS. EECS678 Lecture 2

CSE 451: Operating Systems Spring Module 12 Secondary Storage. Steve Gribble

CS162 Operating Systems and Systems Programming Lecture 14. Caching and Demand Paging

10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4

CPS104 Computer Organization and Programming Lecture 17: Interrupts and Exceptions. Interrupts Exceptions and Traps. Visualizing an Interrupt

Machines and Virtualization. Systems and Networks Jeff Chase Spring 2006

OPERATING SYSTEMS CS136

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

CS370 Operating Systems

Computer System Overview

Chap.6 Limited Direct Execution. Dongkun Shin, SKKU

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

Architectural Support. Processes. OS Structure. Threads. Scheduling. CSE 451: Operating Systems Spring Module 28 Course Review

Virtual Memory Oct. 29, 2002

Computer Architecture. Lecture 8: Virtual Memory

ELEC 377 Operating Systems. Week 1 Class 2

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

Systems Architecture II

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

The Kernel Abstraction

Introduction to Operating Systems. Chapter Chapter

How What When Why CSC3501 FALL07 CSC3501 FALL07. Louisiana State University 1- Introduction - 1. Louisiana State University 1- Introduction - 2

COMP I/O, interrupts, exceptions April 3, 2016

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

Memory Protection. Machines and Virtualization. Architectural Foundations of OS Kernels. Memory and the CPU. Introduction to Virtual Addressing

Architectural Support for Operating Systems

Chapter 5 Input/Output. I/O Devices

Syscalls, exceptions, and interrupts, oh my!

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to Operating. Chapter Chapter

CSE 451: Operating Systems Winter Secondary Storage. Steve Gribble. Secondary storage

CISC 360. Virtual Memory Dec. 4, 2008

19: I/O. Mark Handley. Direct Memory Access (DMA)

ECE331: Hardware Organization and Design

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institute of Technology, Delhi

OS: An Overview. ICS332 Operating Systems

Four Components of a Computer System

Introduction to Operating Systems. Chapter Chapter

CS162 Operating Systems and Systems Programming Lecture 13. Caches and TLBs. Page 1

Unit 2 : Computer and Operating System Structure

5.b Principles of I/O Hardware CPU-I/O communication

CSE 560 Computer Systems Architecture

Threads. Raju Pandey Department of Computer Sciences University of California, Davis Spring 2011

Last Time. Think carefully about whether you use a heap Look carefully for stack overflow Especially when you have multiple threads

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Transcription:

CSE 451: Operating Systems Winter 2017 Module 2 Architectural Support for Operating Systems Mark Zbikowski mzbik@cs.washington.edu 476 Allen Center 2013 Gribble, Lazowska, Levy, Zahorjan 1

Even coarse architectural trends impact tremendously the design of systems Processing power doubling every 18 months 60% improvement each year factor of 100 every decade 1980: 1 MHz Apple II+ = $2,000 (~$5,000 today) 1980 also 1 MIPS VAX-11/780 = $120,000 (~$300,000 today) 2006: 3.0GHz Pentium D = $800 2013: 2.7GHz Quad Core = $369 2017: 2.66GHz Quad Core = $45 2013 Gribble, Lazowska, Levy, Zahorjan 2

Power Consumption http://www.intel.com/pressroom/kits/core2duo/pdf/epi-trends-final2.pdf 2013 Gribble, Lazowska, Levy, Zahorjan 3

Primary Memory / Disk Capacity 2013 Gribble, Lazowska, Levy, Zahorjan 4

Primary memory cost 1972: 1MB = $1,000,000 1982: 512KW (~ 1.5Mb) = $50,000 2017: 64GB = $379(!!!) 2013 Gribble, Lazowska, Levy, Zahorjan 5

Disk cost: Only a few years ago, we purchased disks by the megabyte (and it hurt!) Today, 1 GB (a billion bytes) costs $1 $0.50 $0.07 from Amazon (except you have to buy in increments of 40 80 250 GB) => 1 TB costs $1K $500 $20, 1 PB costs $1M $500K $20K 2013 Gribble, Lazowska, Levy, Zahorjan 6

Aside: Where does it all go? Facetiously: What Gordon giveth, Bill taketh away Realistically: our expectations for what the system will do increase relentlessly e.g., GUI Software is like a gas it expands to fill the available space Nathan Myhrvold (1960-) Microsoft Stock Price 2013 Gribble, Lazowska, Levy, Zahorjan 7

Primary Memory Bandwidth 2013 Gribble, Lazowska, Levy, Zahorjan 8

Optical bandwidth today Doubling every 9 months 150% improvement each year Factor of 10,000 every decade 10x as fast as disk capacity! 100x as fast as processor performance!! What are some of the implications of these trends? Just one example: We have always designed systems so that they spend processing power in order to save scarce storage and bandwidth! 2013 Gribble, Lazowska, Levy, Zahorjan 9

Storage Latency: How Far Away is the Data? Andromeda 10 9 Tape /Optical Robot 2,000 Years 10 6 Disk Pluto 2 Years 100 Memory Olympia 1.5 hr 10 2 1 On Board Cache On Chip Cache Registers This Building This Room My Head 10 min 1 min 2012 2004 Gribble, Jim Gray, Lazowska, Microsoft Levy, Corporation Zahorjan 102

A Current Trend: Solid State Disks http://www.embeddedstar.com/articles/2005/2/article20050207-4.html 2013 Gribble, Lazowska, Levy, Zahorjan 11

Lower-level architecture affects the OS even more dramatically The operating system supports sharing and protection multiple applications can run concurrently, sharing resources a buggy or malicious application can t nail other applications or the system There are many approaches to achieving this The architecture determines which approaches are viable (reasonably efficient, or even possible) includes instruction set (synchronization, I/O, ) also hardware components like MMU or DMA controllers 2013 Gribble, Lazowska, Levy, Zahorjan 12

Architectural support can vastly simplify (or complicate!) OS tasks e.g.: early PC operating systems (DOS, MacOS) lacked support for virtual memory, in part because at that time PCs lacked necessary hardware support Apollo workstation used two CPUs as a bandaid for nonrestartable instructions! Until very recently, Intel-based PCs still lacked support for 64-bit addressing (which has been available for a decade on other platforms: MIPS, Alpha, IBM, etc ) Changed driven by AMD s 64-bit architecture 2013 Gribble, Lazowska, Levy, Zahorjan 13

Architectural features affecting OS s These features were built primarily to support OS s: timer (clock) operation synchronization instructions (e.g., atomic test-and-set) memory protection I/O control operations interrupts and exceptions protected modes of execution (kernel vs. user) privileged instructions system calls (and software interrupts) virtualization architectures Intel: http://www.intel.com/technology/itj/2006/v10i3/1- hardware/7-architecture-usage.htm AMD: http://sites.amd.com/us/business/it-solutions/usagemodels/virtualization/pages/amd-v.aspx 2013 Gribble, Lazowska, Levy, Zahorjan 14

Privileged instructions some instructions are restricted to the OS known as privileged instructions e.g., only the OS can: directly access I/O devices (disks, network cards) why? manipulate memory state management page table pointers, TLB loads, etc. why? manipulate special mode bits interrupt priority level why? 2013 Gribble, Lazowska, Levy, Zahorjan 15

OS protection So how does the processor know if a privileged instruction should be executed? the architecture must support at least two modes of operation: kernel mode and user mode VAX, x86 support 4 protection modes mode is set by status bit in a protected processor register user programs execute in user mode OS executes in kernel (privileged) mode (OS == kernel) Privileged instructions can only be executed in kernel (privileged) mode what happens if code running in user mode attempts to execute a privileged instruction? 2013 Gribble, Lazowska, Levy, Zahorjan 16

Crossing protection boundaries So how do user programs do something privileged? e.g., how can you write to a disk if you can t execute an I/O instructions? User programs must call an OS procedure that is, get the OS to do it for them OS defines a set of system calls User-mode program executes system call instruction Syscall instruction Like a protected procedure call 2013 Gribble, Lazowska, Levy, Zahorjan 17

The syscall instruction atomically: Saves the current PC Sets the execution mode to privileged Sets the PC to a handler address With that, it s a lot like a local procedure call Caller puts arguments in a place callee expects (registers or stack) One of the args is a syscall number, indicating which OS function to invoke Callee (OS) saves caller s state (registers, other control state) so it can use the CPU OS function code runs OS must verify caller s arguments (e.g., pointers) OS returns using a special instruction Automatically sets PC to return address and sets execution mode to user 2013 Gribble, Lazowska, Levy, Zahorjan 18

A kernel crossing illustrated Firefox: read(int filedescriptor, void *buffer, int numbytes) user mode kernel mode Save user PC PC = trap handler address Enter kernel mode trap handler Save app state Verify syscall number Find sys_read( ) handler in vector table PC = saved PC Enter user mode sys_read( ) kernel routine ERET instruction Verify args Initiate read Choose next process to run Setup return values Restore app state 2013 Gribble, Lazowska, Levy, Zahorjan 19

System call issues What would be wrong if a syscall worked like a regular subroutine call, with the caller specifying the next PC? What would happen if kernel didn t save state? Why must the kernel verify arguments? How can you reference kernel objects as arguments to or results from system calls? 2013 Gribble, Lazowska, Levy, Zahorjan 20

Exception Handling and Protection All entries to the OS occur via the mechanism just shown Acquiring privileged mode and branching to the trap handler are inseparable Terminology: Interrupt: asynchronous; caused by an external device Exception: synchronous; unexpected problem with instruction Trap: synchronous; intended transition to OS due to an instruction Privileged instructions and resources are the basis for most everything: memory protection, protected I/O, limiting user resource consumption, 2013 Gribble, Lazowska, Levy, Zahorjan 21

Memory protection OS must protect user programs from each other maliciousness, ineptitude OS must also protect itself from user programs integrity and security what about protecting user programs from OS? Simplest scheme: base and limit registers are these protected? Prog A Prog B Prog C base reg limit reg base and limit registers are loaded by OS before starting program 2013 Gribble, Lazowska, Levy, Zahorjan 22

More sophisticated memory protection coming later in the course paging, segmentation, virtual memory page tables, page table pointers translation lookaside buffers (TLBs) page fault handling 2013 Gribble, Lazowska, Levy, Zahorjan 23

Issues: I/O control how does the OS start an I/O? special I/O instructions memory-mapped I/O how does the OS notice an I/O has finished? polling Interrupts how does the OS exchange data with an I/O device? Programmed I/O (PIO) Direct Memory Access (DMA) 2013 Gribble, Lazowska, Levy, Zahorjan 24

Asynchronous I/O Interrupts are the basis for asynchronous I/O device performs an operation asynchronously to CPU device sends an interrupt signal on bus when done in memory, a vector table contains list of addresses of kernel routines to handle various interrupt types who populates the vector table, and when? CPU switches to address indicated by vector index specified by interrupt signal What s the advantage of asynchronous I/O? 2013 Gribble, Lazowska, Levy, Zahorjan 25

Timers How can the OS prevent runaway user programs from hogging the CPU (infinite loops?) use a hardware timer that generates a periodic interrupt before it transfers to a user program, the OS loads the timer with a time to interrupt quantum how big should it be set? when timer fires, an interrupt transfers control back to OS at which point OS must decide which program to schedule next very interesting policy question: we ll dedicate a class to it Should access to the timer be privileged? for reading or for writing? 2013 Gribble, Lazowska, Levy, Zahorjan 26

Synchronization Interrupts cause a wrinkle: may occur any time, causing code to execute that interferes with code that was interrupted OS must be able to synchronize concurrent processes Synchronization: guarantee that short instruction sequences (e.g., readmodify-write) execute atomically one method: turn off interrupts before the sequence, execute it, then re-enable interrupts architecture must support disabling interrupts Privileged??? another method: have special complex atomic instructions read-modify-write test-and-set load-linked store-conditional 2013 Gribble, Lazowska, Levy, Zahorjan 27

Concurrent programming Management of concurrency and asynchronous events is biggest difference between systems programming and traditional application programming modern event-oriented application programming is a middle ground And in a multi-core world, more and more apps have internal concurrency Arises from the architecture Can be sugar-coated, but cannot be totally abstracted away Huge intellectual challenge Unlike vulnerabilities due to buffer overruns, which are just sloppy programming 2013 Gribble, Lazowska, Levy, Zahorjan 28

Architectures are still evolving New features are still being introduced to meet modern demands Support for virtual machine monitors Hardware transaction support (to simplify parallel programming) Support for security (encryption, trusted modes) Increasingly sophisticated video / graphics Other stuff that hasn t been invented yet In current technology transistors are free CPU makers are looking for new ways to use transistors to make their chips more desirable Intel s big challenge: finding applications that require new hardware support, so that you will want to upgrade to a new computer to run them 2013 Gribble, Lazowska, Levy, Zahorjan 29

Some questions Why wouldn t you want a user program to be able to access an I/O device (e.g., the disk) directly? OK, so what keeps this from happening? What prevents user programs from directly accessing the disk? So, how does a user program cause disk I/O to occur? What prevents a user program from scribbling on the memory of another user program? What prevents a user program from scribbling on the memory of the operating system? What prevents a user program from running away with the CPU? 2013 Gribble, Lazowska, Levy, Zahorjan 30