Chapter 1 Computer System Overview

Similar documents
Chapter 1 Computer System Overview

1. Computer System Structure and Components

Computer-System Architecture

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

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

CSC 2405: Computer Systems II

Operating Systems 4 th Class

Traditional IBM Mainframe Operating Principles

Chapter 2: OS Overview

Exception and Interrupt Handling in ARM

CS161: Operating Systems

Computer Organization & Architecture Lecture #19

Input / Output and I/O Strategies

Microprocessor & Assembly Language

Chapter 11 I/O Management and Disk Scheduling

Central Processing Unit

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

Introduction. What is an Operating System?

361 Computer Architecture Lecture 14: Cache Memory

CHAPTER 7: The CPU and Memory

Operating Systems. Lecture 03. February 11, 2013

Operating Systems Overview

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

Have both hardware and software. Want to hide the details from the programmer (user).

Computer Systems Structure Input/Output

Operating system Dr. Shroouq J.

Outline: Operating Systems

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

MICROPROCESSOR AND MICROCOMPUTER BASICS

Linux Process Scheduling Policy

Chapter 2: Computer-System Structures. Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General System Architecture

SYSTEM ecos Embedded Configurable Operating System

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Chapter 11 I/O Management and Disk Scheduling

find model parameters, to validate models, and to develop inputs for models. c 1994 Raj Jain 7.1

Devices and Device Controllers

Process Description and Control william stallings, maurizio pizzonia - sistemi operativi

Lecture 6: Interrupts. CSC 469H1F Fall 2006 Angela Demke Brown

Operating System Overview. Otto J. Anshus

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Operating Systems. Virtual Memory

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

An Introduction to the ARM 7 Architecture

Central Processing Unit (CPU)

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Lecture 1 Operating System Overview

OPERATING SYSTEM - VIRTUAL MEMORY

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Chapter 11: Input/Output Organisation. Lesson 06: Programmed IO

CS 61C: Great Ideas in Computer Architecture Virtual Memory Cont.

LSN 2 Computer Processors

COS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware

Overview of Operating Systems Instructor: Dr. Tongping Liu

Operating System Tutorial

Physical Data Organization

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Keil C51 Cross Compiler

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 5 INPUT/OUTPUT UNIT JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

A3 Computer Architecture

The PC Boot Process - Windows XP.

Chapter 1: Introduction. Chapter 1: Introduction. Operating System Concepts, 7th Edition. Objectives

PART B QUESTIONS AND ANSWERS UNIT I

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Chapter 1: Introduction. What is an Operating System?

(Refer Slide Time: 00:01:16 min)

Hardware Assisted Virtualization

UNIT 4 Software Development Flow

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Chapter 3 Operating-System Structures

How To Understand And Understand An Operating System In C Programming

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

Operating System Components

Chapter 12 File Management

Chapter 12 File Management. Roadmap

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Record Storage and Primary File Organization

Read this before starting!

Chapter 13 Embedded Operating Systems

COMPUTER SCIENCE AND ENGINEERING - Microprocessor Systems - Mitchell Aaron Thornton

CPS104 Computer Organization and Programming Lecture 18: Input-Output. Robert Wagner

Virtual vs Physical Addresses

Hardware accelerated Virtualization in the ARM Cortex Processors

Chapter 6, The Operating System Machine Level

Intel DPDK Boosts Server Appliance Performance White Paper

An Implementation Of Multiprocessor Linux

The continuum of data management techniques for explicitly managed systems

Hello, and welcome to this presentation of the STM32 SDMMC controller module. It covers the main features of the controller which is used to connect

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

S7 for Windows S7-300/400

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Communication Protocol

Homework # 2. Solutions. 4.1 What are the differences among sequential access, direct access, and random access?

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

National CR16C Family On-Chip Emulation. Contents. Technical Notes V

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

Transcription:

Operating Systems: Internals and Design Principles Chapter 1 Computer System Overview Seventh Edition By William Stallings

Objectives of Chapter To provide a grand tour of the major computer system components: Describe the basic elements of computer system and their interrelationship Explain the steps taken by a processor to execute an instruction Understand the concept of interrupts and how and why a processor uses interrupts. Describe the levels of a computer memory hierarchy Discuss the concept of locality and analyze the performance of multilevel memory hierarchy

What is an operating system? A program that acts as an intermediary between a users/applications and the computer hardware A program that controls and manages the execution of application programs issued by user A program that manages the hardware User/ User/ User/ Application Application Application OS HW CPU, Memory, Devices

Operating System Tasks Exploits the hardware resources of one or more processors (cores) Manages main/secondary memory and I/O devices Dynamically allocate the shared system resources to the executing programs Resources in this area is concerned with the management and scheduling of memory, processes, and other devices. Provides a set of services (system calls) to system users

Operating System Golas Operating system functionalities/goals Start/terminate/control executing user programs Make the computer system convenient to use Efficiency: use the computer hardware in an efficient manner Control and coordinate use of hardware Perform I/O; setup devices Allocate resources Use hardware efficiently Implement common services

Place of OS in Computer System Kernel: running all the time; having most of the functionality of OS 5

Computer System Organization and Operation 7

Basic Elements Processor Main Memory I/O Modules System Bus

Computer System Organization Computer-system operation One or more CPUs, device controllers connect through common bus providing access to shared memory Concurrent execution of CPUs and devices competing for memory cycles Network cable Network adapter Bus

Top-Level View of computer components MAR: Specifies the address in memory for the read or write MBR: contains the data to be written in to memory or read from memory I/O AR: Specifies a particular I/O device

Processor Registers User-visible registers Enable programmer to minimize main-memory references by optimizing register use Control and status registers Used by processor to control operating of the processor Used by operating-system routines to control the execution of programs

User-Visible Registers Available to all programs - application programs and system programs Types of registers Data Address Index Segment pointer Stack pointer

Control and Status Registers Program Counter (PC) Contains the address of an instruction to be fetched Instruction Register (IR) Contains the instruction most recently fetched Program Status Word (PSW) condition codes Interrupt enable/disable Supervisor/user mode

Processor Controls the operation of the computer Performs the data processing functions Referred to as the Central Processing Unit (CPU)

Main Memory Volatile Contents of the memory is lost when the computer is shut down Referred to as real memory or primary memory Why we have two different types of memories?

I/O Modules Moves data between the computer and external environments such as: Storage (e.g. hard drive) communications equipment terminals

System Bus Provides communication among processors, main memory, and I/O modules What happens if two devices send data into the Bus at the same time? Who controls the access to the BUS? What is a priority? Who determines this priority? Is there any rules or algorithm?

Operating System OS decides who should use the resources. It resolves the conflict if several application are running concurrently in the system if those applications make several conflicting request for the resources. OS decides between those conflicting requests considering efficiency (maximum utilization of resources) and fairness.

Instruction Execution 19

Instruction Execution What is a program: A program consists of a set of instructions stored in memory Program execution (Instruction Processing): Two steps: processor reads (fetches) instructions from memory one at a time processor executes each instruction

Basic Instruction Cycle The processing required for a single instruction is called an instruction cycle.

Instruction Fetch and Execute The processor fetches the instruction from memory Program counter (PC) holds address of the instruction to be fetched next PC is incremented after each fetch

Instruction Register (IR) The instruction contains bits that specify the action the processor is to take. Fetched instruction is placed (loaded) into Instruction Register (IR) Processor interprets the instruction and performs required action Types of instructions: Processor-memory Processor-I/O Data processing Control

Types of Instructions Types of instructions Processor-memory transfer data between processor and memory Processor-I/O data transferred to or from a peripheral device Data processing arithmetic or logic operation on data Control alter sequence of execution

Example of Program Execution load 940 add 941 store 941

Announcements Exercise #1 is already on Piazza! Please be active on Piazza and share/discuss your thoughts. Due date: Next Monday Please submit your solutions via Handin. HW#1 will be out today! I will be having Office Hours Friday 2-3 p.m.

Overview 27

Computer System Overview Network cable Network adapter Bus

Operating Systems A program that acts as an intermediary between a user of a computer and the computer hardware. Operating system goals: Execute user programs and make solving user problems easier Make the computer system convenient to us Use the computer hardware in an efficient manner

What Operating Systems Do Operating system is is a resource allocator: Manages all resources Decides between conflicting requests for efficient and fair resource use Operating system is a program controller: Controls execution of programs to prevent errors and improper use of the computer

Interrupts 31

I/O Devices Interaction I/O devices and the CPU can execute concurrently Each device controller has a local buffer Data movement (I/O) between device and local buffer (by device) Data movement between memory and local buffer (by CPU) Device controller informs CPU that it has finished its current operation or it has something How we can inform CPU? by causing an interrupt

Interrupts Definition: Interrupts are signals sent to the CPU by I/O devices. They tell the CPU to stop its current activities and execute the appropriate part of the operating system (handler). A suspension of a process caused by an event external to that process and performed in such a way that the process can be resumed Why Interrupts? Isn t it expensive to stop a process, switch to another process, and then resume the suspended process?

Goal of Interrupts Provided to improve processor utilization (processing efficiency) most I/O devices are slower than the processor processor must pause to wait for device wasteful use of the processor Allows the processor to execute other instructions while an I/O operation is in progress

Common Classes of Interrupts Program: 1- Arithmetic overflow 2- Division by zero 3- Execute illegal instruction 4- Reference outside user s memory space interrupt happens as a result of executing an instruction.

Hardware v.s Software Interrupts classify interrupts from another perspective Hardware may trigger an interrupt at any time by sending a signal to the CPU Software may trigger an interrupt by executing a special operation called a system call

Hardware Interrupts When interrupt occurs, hardware does the following: CPU is interrupted at that time application code or kernel code might be running registers and the program counter saved in RAM to preserve CPU state CPU starts running the respective Interrupt Service Routing (ISR) (kernel routine) ISR is found through interrupt vector (table containing addresses of ISRs)

Software Interrupts Running application software may generate interrupts as well. They are called software interrupts (also called traps) 1. exceptions (caused by errors) 2. system calls (service request) An operating system (kernel) is interrupt-driven (event driven)

Instruction Cycle With Interrupts - It is clear that there is some overhead involved in this process. - Extra instructions must be executed (in the interrupt handler) to determine the nature of the interrupt and to decide on the appropriate action.

Interrupts There is an overhead in using interrupts. CUP stops the running of the current process, runs the handler and then resumes the suspended process. does it worth? How interrupts improve the efficiency?

Sequence of the code Flow of Control Without No Interrupts Service

Flow of Control with Interrupt Services The CPU is never idle. Interrupts improve CPU utilization Sequence of the code

Transfer of Control via Interrupts What happens to a current user program? execution is resumed interrupt processing is completed - The user program does not have to contain any special code to accommodate interrupts. - The processor (CPU) and the OS are responsible for suspending the user program and then resuming it at the same point. What is the interrupt handler?

Interrupt Handler A program that determines nature of the interrupt and performs whatever actions are needed (Determines which types of interrupts has occurred) Control is transferred to this program Generally part of the operating system CPU registe RAM The OS preserves the state of the CPU by storing registers and the program counter. [Application in cpu] - interrupt - [service routine in cpu]

Simple Interrupt Processing

Interrupt-Driven OS Applications or System Programs running in CPU software interrupt / trap (due to system service requests or errors) Kernel Code hardware interrupt Devices disk, keyboard, timer, network adapter When OS supports interrupts: 1) implement specific interrupt handler for different type 2) implement module for suspending the current application and resume it

Multiple Interrupts An interrupt occurs while another interrupt is being processed A program may be receiving data from a communications line and printing results at the same time: - The printer will generate an interrupt every time that it completes a print operation. - The communication line controller will generate an interrupt every time a unit of data arrives Two approaches: Disable interrupts while an interrupt is being processed (sequential) Prioritize interrupts: use a priority scheme (nested)

Multiple Interrupts: Sequential Order Disable interrupts so processor can complete task Interrupts remain pending until the processor enables interrupts After interrupt handler routine completes, the processor checks for additional interrupts Question: any drawback?

Multiple Interrupts: Priorities Higher priority interrupts cause lower-priority interrupts to wait Example: when input arrives from communication line, it needs to be absorbed quickly to make room for more input

Example Time Sequence of Multiple Interrupts

I/O Techniques 51

I/O Communication Structure printf( Hello World!\n ); Application programs can request I/O (read from a device or write to a device) via the help of OS The request is done by calling a System Call (OS routine) System call routine in OS performs the I/O via the help of device driver in OS. After issuing a system call, an application may wait for the call to finish (blocking call) or may continue to do something else (non-blocking call) Application System Call Routines Device Driver Device Controller Device The I/O module informs the OS when the task is done!

I/O Communication Techniques When the processor encounters an instruction relating to I/O, it executes that instruction by issuing a command to the appropriate I/O module Three techniques are possible for I/O operations: Programmed I/O Interrupt-Driven I/O Direct Memory Access (DMA)

Programmed I/O The I/O module performs the requested action (not the processor) then sets the appropriate bits in the I/O status register The I/O module takes NO further action to alert the CPU. The processor periodically checks the status of the I/O module until it determines the instruction is complete With programmed I/O the performance level of the entire system is severely degraded No interrupts occur

Interrupt-Driven I/O Processor issues an I/O command to a module and then goes on to do some other useful work The I/O module will then interrupt the processor to request service when it is ready to exchange data with the processor The processor executes the data transfer and then resumes its former processing More efficient than Programmed I/O but still requires active intervention of the processor to transfer data between memory and an I/O module

Interrupt-Driven I/O Processor is interrupted when I/O module ready to exchange data Processor is free to do other work No needless waiting Consumes a lot of processor time because every word read or written passes through the processor

Interrupt-Driven I/O Drawbacks I/O Transfer rate is limited by the speed with which the processor can test and service a device The processor is tied up in managing an I/O transfer a number of instructions must be executed for each I/O transfer

Direct Memory Access (DMA) Performed by a separate module on the system bus or incorporated into an I/O module Processor is involved only at the beginning and end of the transfer An interrupt is sent when the task is complete When the processor wishes to read or write data it issues a command to the DMA module containing: whether a read or write is requested the address of the I/O device involved the starting location in memory to read/write the number of words to be read/

Direct Memory Access Structure With DMA, device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention SO I/O exchanges occur directly with memory Processor grants I/O module authority to read from or write to memory Relieves the processor responsibility for the exchange Processor is free to do other things Transfers the block of data directly to and from memory without going through the processor Only one interrupt is generated per block, rather than the one interrupt per byte CPU Main Memory Device Controller DMA Controller Transfer

Memory Hierarchy and Caching 60

Memory Structure Main memory memory that the CPU can access directly CPU Main Memory Secondary storage extension of main memory that provides large nonvolatile memory capacity Disk Controller secondary storage Spinning Disk

Trade-offs Memory considerations: how much? how fast? how expensive? ===> as much as possible ===> to keep up with the CPU ===> reasonable considering other two Trade-off: capacity access time cost Question? what would be a good memory configuration?

Memory Hierarchy Why Memory systems organized in hierarchy? Memory must be able to keep up with the processor Cost of memory must be reasonable in relationship to the other components

The Memory Hierarchy Going down the hierarchy: decreasing cost per bit increasing capacity increasing access time Major constrains in memory Speed Expense Cost Volatility Amount decreasing frequency of access to the memory by the processor

Memory Relationships There is a trade-off among the three key characteristics of memory, namely capacity, access time, and cost. Faster access time = greater cost per bit Greater capacity = smaller cost per bit Greater capacity = slower access speed

Caching Caching copying information into faster storage system; main memory can be viewed as a last cache for secondary storage Results from tradeoff between size and speed performed at many levels in a computer (in hardware, operating system, software) Cache is checked first for an item cached small, fast Disk Cache Registers caching large, slow Main Memory Cache Memory Hardware cache L1, L2, etc Main Memory Main Memory Hard Disk

Why Caching? Processor must access memory at least once per instruction cycle Processor execution is limited by memory cycle time Mismatch between processor and main memory speeds processor speed has consistently increased more rapidly than memory access speed main memory should be built with the same technology as that of the processor Expensive strategy Exploit the principle of locality with a small, fast memory between CPU and main memory: Cache idea

Cache Memory small, fast memory - Increase the speed of memory - Processor speed is faster than memory

Cache Principles Contains a copy of a portion of main memory Processor first checks cache If not found, a block of memory is read into cache Because of locality of reference, it is likely that many of the future memory references will be to other bytes in the block

Cache Read Operation

Principle of Locality Memory references by the processor tend to cluster Data is organized so that the percentage of accesses to each successively lower level is substantially less than that of the level above Can be applied across more than two levels of memory

Types of Locality Processor access instructions/data sequentially... Spatial locality: tendency of execution to involve a number of memory locations that are clustered Temporal locality: tendency for a processor to access memory locations that have been used recently

Locality When an iteration (for) loop is executed... A. Spatial locality: tendency of execution to involve a number of memory locations that are clustered B. Temporal locality: tendency for a processor to access memory locations that have been used recently

How to Exploit Locality? Spatial locality: use larger cache and pre-fetching Temporal locality: keep recently used instruction/ data in cache and exploit cache hierarchy

Key elements are: Cache Design cache size block size mapping function replacement algorithm write policy number of cache levels

Cache and Block Size Cache Size Block Size Small caches have significant impact on performance The unit of data exchanged between cache and main memory Hit means the information was found in the cache Larger block size yields more hits until probability of using newly fetched data becomes less than the probability of reusing data that has been moved out of cache

Mapping Function When a new block of data is read in to the cache which cache location the block will occupy? Two constraints affect design: When one block is read in, another may have to be replaced The more flexible the mapping function, the more complex is the circuitry required to search the cache

Summary Basic Elements processor, main memory, I/O modules, system bus GPUs, SIMD, DSPs, SoC Instruction execution processor-memory, processor-i/o, data processing, control Interrupt/Interrupt Processing Memory Hierarchy Cache/cache principles and designs

Computer System Architecture