CSC 2405: Computer Systems II

Similar documents
Basic Computer Hardware

Computer Systems II. First Two Major Computer System Evolution Steps

Part I Overview Chapter 1: Introduction

Lecture 1 Introduction (Chapter 1 of Textbook)

CS370 Operating Systems

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

Common Computer-System and OS Structures

CS370 Operating Systems

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

Introduction. CS3026 Operating Systems Lecture 01

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

Operating System Review

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

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

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

Architectural Support for OS

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

Architectural Support for Operating Systems

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

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

Computer System Architecture. CMPT 300 Operating Systems I. Summer Segment 3: Computer System Architecture. Melissa O Neill

Chapter 1 Computer System Overview

Today: Computer System Overview (Stallings, chapter ) Next: Operating System Overview (Stallings, chapter ,

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

Computer-System Structures

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

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

Chapter 1: Introduction

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

for Operating Systems Computer Systems Laboratory Sungkyunkwan University

Part I Introduction Hardware and OS Review

操作系统概念 13. I/O Systems

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Lecture 2 - Fundamental Concepts

Chapter 13: I/O Systems

Unit 2 : Computer and Operating System Structure

CSC 553 Operating Systems

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

Chapter 1 Computer System Overview

Lecture 15: I/O Devices & Drivers

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

Chapter 13: I/O Systems

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

Chapter 12: I/O Systems

Chapter 13: I/O Systems

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

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Computer-System Architecture

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

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

Lecture 2: September 9

CPS 210: Operating Systems

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

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

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo

European University of Lefke. Instructor: Dr. Arif SARI

CS510 Operating System Foundations. Jonathan Walpole

18-447: Computer Architecture Lecture 16: Virtual Memory

Systems Programming and Computer Architecture ( ) Timothy Roscoe

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

CS510 Operating System Foundations. Jonathan Walpole

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

Lecture 4: Memory Management & The Programming Interface

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet:

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

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

Chapter 13: I/O Systems

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

Operating Systems: Principles and Practice. Mark Zbikowski Gary Kimura (kudos to Tom Anderson)

OS: An Overview. ICS332 Operating Systems

Device-Functionality Progression

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

Chapter 13: I/O Systems

Silberschatz and Galvin Chapter 12

Chapter 13: I/O Systems

OPERATING SYSTEMS & Network OVERVIEW. 1: OS & Network Overview

Module 12: I/O Systems

Operating Systems 2010/2011

CSCI 4717 Computer Architecture

Chapter 13: I/O Systems

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

Lecture 2: Architectural Support for OSes

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

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

Interconnecting Components

Overview of Operating Systems

Computer-System Organization (cont.)

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Operating Systems Overview. Chapter 2

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

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

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

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

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

Overview of Operating Systems

Introduction to Computer Systems and Operating Systems

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

Module 12: I/O Systems

Transcription:

CSC 2405: Computer Systems II Dr. Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Spring 2016 Course Goals: Look under the hood Help you learn what happens under the hood of computer systems Two downward tours: 2400: Language levels tour High-level language (C) assembly language machine language (IA-32) 2405: Service levels tour High-level language (C) standard libraries operating system (Unix) 1

Structure of Course (Part I) Computer Systems Overview Processes Creating, executing, scheduling processes Then study process cooperation Communication through pipes, messages, sockets Implement a smart Unix shell Midterm Structure of Course (Part II) Threads Sharing global data, synchronizing with semaphores Networking and Communication TCP/IP, DNS, HTTP, Sockets Implement a multi-threaded server Memory Management File Systems Security and Protection Final Exam 2

Course Resources Online textbook Arpaci-Dusseau s Operating Systems: Three Easy Pieces Lots of online resources Class website http://www.csc.villanova.edu/~mdamian/csc2405/ Class Work Programming projects (C and Unix) Implement your own Unix shell Implement a multi-threaded server You will gain experience with writing larger and more complex programs than in Systems I Several smaller assignments One midterm, one final exam Checkpoint Quizzes How are you doing? 3

Grading Assignments (40%) On time (no late submission) First assignment is available now Midterm (30%) Final Exam (30%) No makeup assignments or exams Lecture attendance is mandatory Help Resources Instructor Dr. Mirela Damian, mirela.damian@villanova.edu Office167A in the Mendel Science Building Teaching Assistant VenkateswaraReddy Kunduru, vkunduru@villanova.edu Programming assistants Mendel 292, http://csc.villanova.edu/support/cschelpdesk Peer Tutors Mendel 292, http://www.csc.villanova.edu/~map/help/ 4

Key to Success Start early to allow time for debugging. Ready to Begin? 5

Review of Program Execution CPU Instruction Pointer Control Data BUS Executable Disk Memory Review of CPU Cycle CPU Instruction Pointer Memory Executable BUS Fetch Cycle Decode Cycle Execute Cycle START START Fetch Next Instruction Decode Execute Instruction Instruction Execute Execute Instruction Instruction HALT Villanova University 6

Typical Computer System One or more CPUs, shared memory, I/O devices Timing Problem: I/O devices much slower than the CPU - Billions of times slower What should the CPU do while the I/O completes? I/O Device Controllers Special purpose processors that carry I/O operations on behalf of the CPU - Each controller is in charge of a particular device type - Each controller has registers, local buffer - I/O is from the device to local buffer of controller CPU and I/O devices execute concurrently 7

I/O Operation Example c = getchar(); What happens? CPU Keyboard local buffer Keyboard Controller Memory c Input / Output (I/O) To start an I/O operation, the CPU tells the controller: - The chunk size be transferred (eg, one character) - Goes off to do something else The device controller: - Checks registers to determine what to do (read, write) - Transfers data to/from device from/to local buffer - Informs the CPU when transfer is complete HOW? Villanova University 8

Here is an analogy... Teacher each student is is CPU I/O device Inefficient solution: Polling ask CPU device 1 ready? device 2 ready?... device n ready? 9

Turn the situation upside down CPU device 1 device 2... device n 10

The analogy continues... Student with a question raises hand Teacher (tries to) answer question is is device ready sends interrupt request CPU handles interrupt HOW? CPU passes control to the device driver to process the interrupt (in our example, copy the character from the keyboard controller s buffer into memory) I/O Device Driver A device driver is a program that understands and communicates with a particular device controller - To start an I/O operation, the driver loads data into controller registers - Controller transfers data from device to LOCAL buffer - Controller informs driver via INTERRUPT that it is done Device drivers are part of the Operating system (OS) 11

Where Does the OS Fit? Applications System Calls: read(), open(), write(), mkdir(), kill()... Operating System Virtualization Device Driver Commands Villanova Interrupt University Handling Interrupts Hardware may trigger interrupts at any time by sending a signal to the CPU by way of system bus When the CPU is interrupted - Stops what it is doing - Transfers control to a fixed memory location pointing to the Interrupt Vector (OS structure) The Interrupt Vector - Contains the addresses of all the service routines 12

Interrupt Vector A table of pointers (addresses) Contains addresses of interrupt service routines Indexed by a unique exception number - Given with the interrupt request Exception numbers 0 1 2 n-1 Interrupt Vector... code for exception handler 0 code for exception handler 1 code for exception handler 2... code for exception handler n-1 Handling Interrupts Interrupt architecture - Saves the address of the interrupted instruction prior to transferring control to the interrupt service routine - Restores saved address upon returning from interrupt Interrupt handler - Saves registers that are to be modified onto the stack - Services request (eg, copy data from local buffer in memory) - Restores registers from the stack Interrupted program resumes execution 13

Interrupt-Driven I/O Summary Hardware Interrupts Interrupts are a critical part of a computer system - They allow a program to be interrupted, so the computer may deal with an urgent event Must be handled quickly CPU Checks for Interrupts every??? Fetch Cycle Decode Cycle Execute Cycle Interrupt Check Interrupts disabled START START Fetch Instruction Decode Instruction After every machine instruction! Execute Execute Instruction Interrupts Enabled Check Check for for Interrupt: Interrupt: Process Process Interrupt Interrupt HALT START 14

Software Interrupts Caused by events that occur as a result of executing an instruction: - Traps Intentional Examples: system calls, breakpoint traps Returns control to next instruction - Faults Unintentional but possibly recoverable Examples: page faults (recoverable), protection faults (unrecoverable) Either re-executes faulting ( current ) instruction or aborts Important Points Programs can t directly access the hardware; the operating system provides a simple and powerful interface - manages underlying physical resources - provides a standard library of system calls To start an I/O, CPU invokes the device driver to tell the device controller what to do - The controller carries the I/O operation - The CPU continues with other tasks - CPU and I/O execute in parallel Hardware may trigger interrupts at any time - When the CPU is interrupted, it executes the interrupt handler, then resumes execution of interrupted program The Operating System is Interrupt-Driven 15

Direct Memory Access Used to avoid programmed I/O (one byte at a time) for large data movement Bypasses CPU to transfer data directly between I/O device and memory To start an I/O operation, the CPU tells the DMA controller: The chunk size to be transferred (eg, 4096 bytes of data) The memory address where the chunk ought to be stored Direct Memory Access The DMA controller Accesses the device Transfers the chunk from/to device to/from system MEMORY Interrupts CPU when transfer is complete Benefits The CPU is only involved at the start and end of transfer Interrupts are now less frequent Hence, CPU can do a lot of work between interrupts 16

Six Steps to Perform DMA Transfer Major Evolution Steps of Computer Systems 17

At First (1945 1955) In the beginning, there was no operating system - Program binaries were loaded using switches - Interface included blinking lights (cool!) System Evolution: Step 1 Very simple operating system (1955 1965) - Library of common subroutines (read, write, etc.) - Single programming (one application at a time) User Program Free memory!!! Operating system Program P. read. system call read begin Start I/O Wait for I/O to complete End I/O end Problem I/O devices much, much slower than the CPU - Q: What to do while we wait for the I/O device? - A: Run more processes! When one blocks, switch to another 18

System Evolution: Step 2 Multiprogramming (1965 1980) - Multiple running processes - When one process (job) blocks, switch to another Operating System Process 1 Process 2 B Virtualizing Memory: memory partitions Process A 3 Multiprogramming Example Process 1 Process 2 Combined 19

Multiprogramming Issues Operating System Process 1 Process 2 B Virtualizing Memory: memory partitions Process A 3 Processes (jobs) share the memory - What if a process starts scribbling in memory? Processes share the CPU - What if a program has infinite loops? Multiprogramming Issue 1 Processes (jobs) share the memory - What if a process starts scribbling in memory? Solution: Memory protection Operating System Process 1 Process 2 B Process A 3 - Add two registers that determine the range of legal addresses - A program cannot access memory outside this range Operating System Process 1 Process 2 Job 2 can legally access all addresses from 300040 through 420940 Process 3 Process 4 20

Multiprogramming Issue 1 But what about the Operating System? Operating System Process 1 Process 2 B Solution: Two execution modes Process A 3 - user mode and system (supervisor, monitor) mode - OS executes in system mode, user programs in user mode - Attempts to execute privileged instructions while in user mode results in a trap (to be discussed later) Multiprogramming Issue 2 Processes (jobs) share the CPU - What if a program has infinite loops? Process C Process B Process A Solution: Timer Interrupts - The OS sets the internal clock to generate an interrupt at some specified future time. - This interrupt time is the process quantum. - When the timer interrupt occurs, the CPU switches to another process. This prevents the system being held up by processes in infinite loops. 21

Recall: CPU Cycle with Interrupts Fetch Cycle Decode Cycle Execute Cycle Interrupt Check Interrupts disabled START START Fetch Instruction Decode Instruction Execute Execute Instruction Check Check for for Interrupt: Interrupt: Process Process Interrupt Interrupt Interrupts Enabled HALT START Multiprogramming with Timer Interrupts Timer Interrupt Memory A A B C B Timer Interrupt C C B A Time Multiprogramming is also called pseudoparallelism since one has the illusion of a parallel processor. Different from real parallelism in which two or more processes are actually running at once on two different processors. 22

System Evolution: Step 3 Over time: - Hardware became cheaper, humans expensive - How to maximize hardware use? Solution: Interactive time sharing - Use cheap terminals to allow multiple users use the system - Does machine now run N times slower? Usually not! - Key idea: take stuff from an idle guy and give it to a busy guy OS gives users the illusion of having their own computers Timesharing Idea OS gives users the illusion of having their own computers What to do when illusion breaks? - What if users are gluttons? evil? - Or just too numerous? Solution: OS adds more protection Notice: as we try to utilize resources, complexity grows 23

System Evolution: Step 4 Personal computers - Computers are cheap, so give everyone a computer Computer systems now include - Multiprogramming - Memory protection When humans are expensive, do not waste their time by letting programs crash each other - Other features we ll introduce later Multiprocessing: dual- or multi-core CPU cores on a single chip - each CPU has its own registers and local cache - memory is shared - true parallelism 24

Symmetric Multiprocessing Each CPU core in its own chip - CPUs share memory - Good for load balancing - All modern OS include support for SMP Single Instruction Multiple Data (SIMD) Memory Instructions Processing Core Processing Core Processing Core Processing Core Processing Core A single instruction executes across multiple data streams simultaneously - Graphics Processing Units (GPU) have thousands of smaller cores that process data in parallel - Vector processing architecture (e.g., Cray platforms) 25

Distributed Memory System Each CPU has its own private memory - Inter-process communication more difficult (via message passing) Clustered Systems Multiple systems working together - Loosely-coupled computers - Usually share storage via a storage-area network - High availability: if one node fails, service continues computer interconnect computer interconnect computer storage area network 26

Interconnecting Different Systems How do we coordinate among multiple systems? - Network them together - Security becomes important What does this all mean for the OS? - Operating systems become more sophisticated Summary Main computer system components: - CPU, Memory, I/O Devices - Managed by the operating system Operating System is like a virtual machine - Virtualizes memory, CPU, I/O devices I/O device controllers - Special processors, carry I/) on behalf of the CPU - Use local buffers for I/O transfer Interrupts - Interrupt-driven I/O vs. Direct Memory Access (DMA) - Software interrupts (traps, faults) Villanova University 27