U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.

Slides:



Advertisements
Similar presentations
Chapter 6 Limited Direct Execution
Advertisements

CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Operating Systems CMPSCI 377 Lecture 11: Memory Management
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
1 CSE451 Operating Systems Winter 2009 Module 2 Architectural Support Mark Zbikowski Gary Kimura.
OS Spring’03 Introduction Operating Systems Spring 2003.
Hardware Support for Operating Systems Sunny Gleason Vivek Uppal COM S 414
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Operating Systems CS208. What is Operating System? It is a program. It is the first piece of software to run after the system boots. It coordinates the.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Chapter 2 The OS, the Computer, and User Programs Copyright © 2008.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Protection and the Kernel: Mode, Space, and Context.
Introduction and Overview Questions answered in this lecture: What is an operating system? How have operating systems evolved? Why study operating systems?
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Introduction to Operating Systems Chapter 1. cs431 -cotter2 Lecture Objectives Understand the relationship between computing hardware, operating system,
Thanks to Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2 Computer-System Structures n Computer System Operation n I/O Structure.
2: Computer-System Structures
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Chapter 2: Computer-System Structures 2.1 Computer System Operation 2.5 Hardware Protection 2.6 Network Structure.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
Chapter 1: Introduction and History  Where does the operating system fit in a computing system?  What does the operating system achieve?  What are the.
Operating Systems CSE 411 Introduction and Overview Sept Lecture 2 Instructor: Bhuvan Urgaonkar.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Lecture Topics: 10/29 Architectural support for operating systems –timers –kernel mode –system calls –protected instructions.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
OSes: 2. Structs 1 Operating Systems v Objective –to give a (selective) overview of computer system architectures Certificate Program in Software Development.
Operating Systems: Summary INF1060: Introduction to Operating Systems and Data Communication.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Introduction to Operating Systems Concepts
Chapter 2: Computer-System Structures
Operating Systems CMPSC 473
Computer-System Architecture
Module 2: Computer-System Structures
Lecture Topics: 11/1 General Operating System Concepts Processes
Architectural Support for OS
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Operating Systems Structure
Presentation transcript:

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture 2: OS & Architecture

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 Last Class: Introduction Operating system = interface between user & architecture OS history: Change is only constant User-level Applications Operating System Hardware virtual machine interface physical machine interface

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 3 Today: OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 Modern OS Functionality Provides support for: Concurrency I/O Device Management Memory Management Files Distributed Systems & Networks

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 5 Concurrency Supports multiple activities, apparently occurring simultaneously Multiple users: Several users work as if each has private machine Multiple processes/threads: One on CPU at a time Multiple active concurrently

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 6 Modern OS Functionality, Cont. I/O CPU works while waiting on slow I/O devices Memory Management Coordinates allocation of RAM Moves data between disk & main memory Files Coordinates how disk space is used Distributed Systems & Networks Lets group of PC’s to work together on distributed h/w

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 7 Operating Systems = Governments Close analogy of operating systems to utopian political systems Libertarianism Socialism Communism

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 8 OS as Utopian Governments Libertarianism: Infinite RAM, CPU Protects users from each other

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 9 OS as Utopian Governments Socialism: Safe & secure communication Protects everyone Fair allocation of resources

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 10 OS as Utopian Governments Communism: To each according to his needs Centralized control Allocates resources efficiently (in theory…) Impossible or too slow without hardware support

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 11 Canonical System Hardware CPU: Processor to perform actual computations I/O devices: terminal, disks, video, printer… Memory: data & programs System Bus: Communication channel between above

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 12 Services & Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 13 Protection OS protects users from each other Users cannot read or write other user’s memory Name OS’s that do and don’t do this! Protects self from users Safe from errant or malicious users Privileged instructions (e.g., halt machine) Code & data protected

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 14 Kernel Mode: Privileged Instructions CPU provides “kernel” mode restricted to OS Inaccessible to ordinary users Kernel = core of operating system Privileged instructions & registers: Direct access to I/O Modify page table pointers, TLB Enable & disable interrupts Halt the machine, etc. Indicated by status bit in protected CPU register

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 Protecting Memory: Base and Limit Registers Hardware support to protect memory regions Loaded by OS before starting program CPU checks each reference Instruction & data addresses Ensures reference in range

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 16 Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 17 Interrupts Polling = “are we there yet?” “no!” (repeat…) Inefficient use of resources Annoys the CPU Interrupt = silence, then: “we’re there” I/O device has own processor When finished, device sends interrupt on bus CPU “handles” interrupt

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 18 CPU Interrupt Handling Handling interrupts: relatively expensive CPU must: Save hardware state Registers, program counter Disable interrupts (why?) Invoke via in-memory interrupt vector (like trap vector, soon) Enable interrupts Restore hardware state Continue execution of interrupted process

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 19 Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 20 Traps Special conditions detected by architecture E.g.: page fault, write to read-only page, overflow, system call On detecting trap, hardware must: Save process state (PC, stack, etc.) Transfer control to trap handler (in OS) CPU indexes trap vector by trap number Jumps to address Restore process state and resume

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 21 Memory Traps Special case: trigger trap on write to protected memory area Widely used in operating systems: Debugging Distributed virtual memory Approximating LRU Garbage collection Copy-on-write Pay performance penalty only when needed

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 22 Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 23 Memory-Mapped I/O Direct access to I/O controller through memory Reserve area of memory for communication with device (“DMA”) Video RAM: CPU writes frame buffer Video card displays it Fast and convenient

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 24 Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 25 Synchronization How can OS synchronize concurrent processes? E.g., multiple threads, processes & interrupts, DMA CPU must provide mechanism for atomicity Series of instructions that execute as one or not at all

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 26 Synchronization: How-To One approach: Disable interrupts Perform action Enable interrupts Advantages: Requires no hardware support Conceptually simple Disadvantages: Could cause starvation

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 27 Synchronization: How-To, II Modern approach: atomic instructions Small set of instructions that cannot be interrupted Examples: Test-and-set (“TST”) if word contains given value, set to new value Compare-and-swap (“CAS”) if word equals value, swap old value with new Intel: LOCK prefix (XCHG, ADD, DEC, etc.) Used to implement locks

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 28 Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 29 Virtual Memory Provides illusion of complete access to RAM All addresses translated from physical addresses into virtual addresses OS loads pages from disk as needed Keeps track of which pages are in memory (“in core”) and which are on disk Many benefits, including: Allows users to run programs without loading entire program into RAM May not fit in entirety (think MS Office)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 30 Translation Lookaside Buffer First virtual memory systems performed address translation in software On every memory access! (s..l..o..w..) Modern CPUs contain hardware to do this: the TLB Hash-based scheme Maps virtual addresses to physical addresses Fast, fully-associative cache Today’s workloads are often “TLB-miss dominated”

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 31 Hardware Support OS ServiceHardware Support ProtectionKernel/User Mode Protected Instructions Base & Limit Registers InterruptsInterrupt Vectors System CallsTrap Instructions I/OInterrupts, Memory-Mapping SynchronizationAtomic Instructions Virtual MemoryTranslation Lookaside Buffers SchedulingTimer

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 32 Scheduling & Timers OS needs timers for: Time of day CPU scheduling Fairness: limited quantum (e.g., 100ms) for each task When quantum expires, switch processes Uses interrupt vector

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 33 Summary OS relies on hardware for many services Protection Interrupts System Calls Synchronization Virtual memory Timers Otherwise impossible or impractically slow in software