CS370 Operating Systems

Similar documents
CS370 Operating Systems

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

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

Chapter 1: Introduction

Chapter 1: Introduction

Chapter 1: Introduction. Operating System Concepts 8 th Edition,

Chapter 1: Introduction. Chapter 1: Introduction

European University of Lefke. Instructor: Dr. Arif SARI

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

CS420: Operating Systems

Chapter 1: Introduction

CS420: Operating Systems

DM510 Operating Systems. Jacob Aae Mikkelsen

Lecture 1 Introduction (Chapter 1 of Textbook)

Chapter 1: Introduction. Operating System Concepts 8th Edition,

CSE Opera+ng System Principles

Four Components of a Computer System. Operating System Concepts 7 th Edition, Jan 12, 2005

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

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

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

Chapter 1: Introduction. Operating System Concepts 8th Edition,

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Four Components of a Computer System

Operating System Services

CS3600 SYSTEMS AND NETWORKS

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Introduction to Operating Systems (Part II)

Module 2: Computer-System Structures. Computer-System Architecture

Introduction. TDDI04, K. Arvidsson, IDA, Linköpings universitet Contents. What is an Operating System (OS)?

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

Operating System Concepts 9 th Edit9on

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

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

CPSC 341 OS & Networks. Introduction. Dr. Yingwu Zhu

Introduction. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

Chapter 2: Operating-System Structures. Operating System Concepts 8 th Edition

Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications

Chapter 1: Introduction Dr. Ali Fanian. Operating System Concepts 9 th Edit9on

Operating System Review

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Introduction to Operating Systems

Chapter 13: I/O Systems

The Lesson Plan of OS. The syllabus of OS. Access the lesson plan and syllabus at

Input/Output Systems

Chapter 13: I/O Systems

Instruction Cycle. Computer-System Architecture. Computer-System Operation. Common Functions of Interrupts. Chapter 2: Computer-System Structures

Chapter 13: I/O Systems

Computer-System Architecture

Computer-System Architecture. Common Functions of Interrupts. Computer-System Operation. Interrupt Handling. Chapter 2: Computer-System Structures

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Chapter 13: I/O Systems

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

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

Module 12: I/O Systems

Module 12: I/O Systems

Operating Systems. Overview. Dr Alun Moon. Computing, Engineering and Information Sciences. 27th September 2011

CHAPTER 1 - INTRODUCTION. Jacob Aae Mikk elsen

Computer-System Structures

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

Lecture 13 Input/Output (I/O) Systems (chapter 13)

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

OPERATING SYSTEMS UNIT - 1

Operating Systems Spring 2013, Ort Braude College Electrical Engineering Department

Part I Overview Chapter 1: Introduction

OPERATING SYSTEMS Lecture Notes. Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW.

Module 1: Introduction. What is an Operating System?

Introduction. Chapter Prof. Amr El-Kadi

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

CSC Operating Systems Spring Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. January 17 th, 2007.

Announcements. Operating System Structure. Roadmap. Operating System Structure. Multitasking Example. Tevfik Ko!ar

SRIMAAN COACHING CENTRE-TRB-COMPUTER INSTRUCTORS STUDY MATERIAL CONTACT: III

CSC Operating Systems Fall Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. August 27 th, 2009.

Announcements. Computer System Organization. Roadmap. Major OS Components. Processes. Tevfik Ko!ar. CSC Operating Systems Fall 2009

Lecture 15: I/O Devices & Drivers

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CSC Operating Systems Spring Lecture - XIX Storage and I/O - II. Tevfik Koşar. Louisiana State University.

RAID Structure. RAID Levels. RAID (cont) RAID (0 + 1) and (1 + 0) Tevfik Koşar. Hierarchical Storage Management (HSM)

Module 1: Introduction

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - II OS Structures. University at Buffalo. OS Design and Implementation

OS Design Approaches. Roadmap. System Calls. Tevfik Koşar. Operating System Design and Implementation. CSE 421/521 - Operating Systems Fall 2013

The control of I/O devices is a major concern for OS designers

Dinosaurs? & Dinosaur Wars. Outline & Questions. Evolution of our Textbook. Poll? Questions?

System Call System Program Linker/Loader with Examples Types of computing Environment

Lecture 1 - Operating System Overview

Chapter 13: I/O Systems

Operating system Dr. Shroouq J.

Chapter 13: I/O Systems

I/O SYSTEMS. Sunu Wibirama

Silberschatz and Galvin Chapter 12

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

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

COT 4600 Operating Systems Fall Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM

Transcription:

CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2016 Lecture 2 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1

2 System I/O

System I/O (Chap 13) Central brain 3

I/O Hardware (Cont.) I/O Devices usually have registers where device driver places commands, addresses, and data Data-in register, data-out register, status register, control register Typically 1-4 bytes, or FIFO buffer Devices have addresses, used by Direct I/O instructions Memory-mapped I/O Device data and command registers mapped to processor address space 4

Polling vs Interrupt Polling: handled by software Interrupts: polling is done by hardware 5

For each byte of I/O Polling 1. Read busy bit from status register until 0 2. Host sets read or write bit and if write copies data into data-out register 3. Host sets command-ready bit 4. Controller sets busy bit, executes transfer 5. Controller clears busy bit, error bit, command-ready bit when transfer done Step 1 is busy-wait cycle to wait for I/O from device Reasonable if device is fast But inefficient if device slow CPU switches to other tasks? But if miss a cycle data overwritten / lost 6

Interrupts Polling is slow Interrupts used in practice CPU Interrupt-request line triggered by I/O device Checked by processor after each instruction Interrupt handler receives interrupts Maskable to ignore or delay some interrupts Interrupt vector to dispatch interrupt to correct handler Context switch at start and end Based on priority Some nonmaskable Interrupt chaining if more than one device at same interrupt number 7

8 Interrupt-Driven I/O Cycle

Interrupts (Cont.) Interrupt mechanism also used for exceptions Terminate process, crash system due to hardware error Page fault executes when memory access error OS causes switch to another process System call executes via trap to trigger kernel to execute request 9

Direct Memory Access for movement of a block of data To/from disk, network etc. Requires DMA controller Bypasses CPU to transfer data directly between I/O device and memory OS writes DMA command block into memory Source and destination addresses Read or write mode Count of bytes Writes location of command block to DMA controller Bus mastering of DMA controller grabs bus from CPU Cycle stealing from CPU but still much more efficient When done, interrupts to signal completion 10

Six Step Process to Perform DMA Transfer Interrupt when done 11

Direct Memory Access Structure high-speed I/O devices Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention Only one interrupt is generated per block 12

I/O Subsystem One purpose of OS is to hide peculiarities of hardware devices from the user I/O subsystem responsible for Memory management of I/O including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs) like printer queue General device-driver interface Drivers for specific hardware devices 13

Application I/O Interface I/O system calls encapsulate device behaviors in generic classes Device-driver layer hides differences among I/O controllers from kernel New devices talking already-implemented protocols need no extra work Each OS has its own I/O subsystem structures and device driver frameworks Devices vary in many dimensions Character-stream or block Sequential or random-access Synchronous or asynchronous (or both) Sharable or dedicated Speed of operation read-write, read only, or write only 14

15 A Kernel I/O Structure

16 Storage

Storage Structure Main memory only large storage media that the CPU can access directly Random access Typically volatile (except for ROM) Secondary storage extension of main memory that provides large nonvolatile storage capacity Hard disks (HDD) rigid platters covered with magnetic recording material Disk surface divided into tracks, which are subdivided into sectors The disk controller transfers between the device and the processor Solid-state disks (SSD) faster than hard disks, lower power consumption More expensive, but becoming more popular Tertiary/removable storage External disk, thumb drives, cloud backup etc. Memory for short Disk for short 17

Storage Hierarchy Storage systems organized in hierarchy Speed Cost Volatility Caching copying information into faster storage system; main memory can be viewed as a cache for secondary storage Device Driver for each device controller to manage I/O Provides uniform interface between controller and kernel 18

Storage-Device Hierarchy One or the other 19

Performance of Various Levels of Storage Movement between levels of storage hierarchy can be explicit or implicit Cache managed by hardware. Makes main memory appear much faster. Disks are several orders of magnitude slower. 20

Caching Important principle, performed at many levels in a computer (in hardware, operating system, software) Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache smaller than storage being cached Cache management important design problem Cache size and replacement policy 21

Questions from last time Interrupts: Why? How? I/O implementation: IO devices are much slower Options: Interrupts vs polling Interrupt request line is hardware Interrupt causes transfer of control to Interrupt Service Routine Hence need to save context. Context restored when returning. 22

Questions from last time Block transfer using DMA Controller vs CPU CPU needs to fetch instructions for each word DMAC, once initialized, doesn t need to fetch instructions DMA: direct connection between memory and IO device 23

24 Multiprocessors

Multiprocessors Most systems use a single general-purpose processor Most systems have special-purpose processors as well Multiprocessors systems growing in use and importance Also known as parallel systems, tightly-coupled systems Advantages include: 1. Increased throughput 2. Economy of scale 3. Increased reliability graceful degradation or fault tolerance Two types: 1. Asymmetric Multiprocessing each processor is assigned a specific task. 2. Symmetric Multiprocessing each processor performs all tasks 25

26 Symmetric Multiprocessing Architecture

A Dual-Core Design Multi-chip and multicore Systems containing all chips Chassis containing multiple separate systems 27

28 Operating System Structure

Operating System Structure Multiprogramming needed for efficiency Single user cannot keep CPU and I/O devices busy at all times Multiprogramming organizes jobs (code and data) so CPU always has one to execute A subset of total jobs in system is kept in memory One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Response time should be < 1 second Each user has at least one program executing in memory process If several jobs ready to run at the same time CPU scheduling If processes don t fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory 29

30 Memory Layout for Multiprogrammed System

Operating-System Operations Interrupt driven (hardware and software) Hardware interrupt by one of the devices Software interrupt (exception or trap): Software error (e.g., division by zero) Request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system 31

Operating-System Operations (cont.) Dual-mode operation allows OS to protect itself and other system components called Supervisor mode in LC3 User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user Increasingly CPUs support multi-mode operations i.e. virtual machine manager (VMM) mode for guest VMs 32

Transition from User to Kernel Mode Timer to prevent infinite loop / process hogging resources Timer is set to interrupt the computer after some time period Keep a counter that is decremented by the physical clock. Operating system set the counter (privileged instruction) When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time 33

Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity. Process needs resources to accomplish its task CPU, memory, I/O, files Initialization data Process termination requires reclaim of any reusable resources Single-threaded process has one program counter specifying location of next instruction to execute Process executes instructions sequentially, one at a time, until completion Multi-threaded process has one program counter per thread Typically system has many processes, some user, some operating system running concurrently on one or more CPUs Concurrency by multiplexing the CPUs among the processes / threads 34

Process Management Activities The operating system is responsible for the following activities in connection with process management: Creating and deleting both user and system processes Suspending and resuming processes Providing mechanisms for process synchronization Providing mechanisms for process communication Providing mechanisms for deadlock handling 35

36 Memory & Storage Management

Means main memory here Memory Management To execute a program all (or part) of the instructions must be in memory All (or part) of the data that is needed by the program must be in memory. Memory management determines what is in memory and when Optimizing CPU utilization and computer response to users Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes (or parts thereof) and data to move into and out of memory Allocating and deallocating memory space as needed CPU scheduling 37

Storage Management OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file Each medium is controlled by device (i.e., disk drive, tape drive) Varying properties include access speed, capacity, datatransfer rate, access method (sequential or random) File-System management Files usually organized into directories Access control on most systems to determine who can access what OS activities include Creating and deleting files and directories Primitives to manipulate files and directories Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media 38

Mass-Storage Management Usually disks used to store data that does not fit in main memory or data that must be kept for a long period of time Entire speed of computer operation hinges on disk subsystem and its algorithms OS activities Free-space management Storage allocation Disk scheduling Some storage need not be fast Tertiary storage includes optical storage, magnetic tape Still must be managed by OS or applications Varies between WORM (write-once, read-many-times) and RW (read-write) 39

Performance of Various Levels of Storage Movement between levels of storage hierarchy can be explicit or implicit 40

Migration of data A from Disk to Register Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache Distributed environment situation even more complex Several copies of a datum can exist Various solutions covered in Chapter 17 (will not get to it) 41