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

Similar documents
Computer System Overview

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

Operating System Review

Computer System Overview

CS370 Operating Systems

CS370 Operating Systems

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

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

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int

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

Chapter 1 Computer System Overview

Chapter 1 Computer System Overview

Lecture 1 Introduction (Chapter 1 of Textbook)

ELEC 377 Operating Systems. Week 1 Class 2

Introduction. CS3026 Operating Systems Lecture 01

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

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

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

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

Q.1 Explain Computer s Basic Elements

Chapter 1: Introduction

Chapter 1: Introduction

CSC 553 Operating Systems

CS30002: Operating Systems. Arobinda Gupta Spring 2017

CSC 2405: Computer Systems II

Chapter 1: Introduction

Introduction to Operating Systems. Chapter Chapter

Announcement. Exercise #2 will be out today. Due date is next Monday

OPERATING SYSTEM. PREPARED BY : DHAVAL R. PATEL Page 1. Q.1 Explain Memory

Operating-System Structures

Chapter 1: Introduction. Chapter 1: Introduction

CSCI-375 Operating Systems

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

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

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

Mon Sep 17, 2007 Lecture 3: Process Management

Operating Systems Overview. Chapter 2

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

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

Principles of Operating Systems CS 446/646

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

Operating system Dr. Shroouq J.

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

Computer System Overview. Chapter 1

Basic Computer Hardware

CSC Operating Systems Fall Lecture - I Introduction. Tevfik Ko!ar. Louisiana State University. August 25 th, Contact Information

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

Chapter 2 Computer-System Structure


European University of Lefke. Instructor: Dr. Arif SARI

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

CS 390 Chapter 2 Homework Solutions

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

Part I Overview Chapter 1: Introduction

Lecture 2 - Fundamental Concepts

Introduction to Operating Systems (Part II)

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

CS399 New Beginnings. Jonathan Walpole

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

I/O Management and Disk Scheduling. Chapter 11

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

Chapter 13: I/O Systems

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

CPE300: Digital System Architecture and Design

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III

Unit 2 : Computer and Operating System Structure

Introduction CHAPTER. Review Questions

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

COS 318: Operating Systems. Overview. Jaswinder Pal Singh Computer Science Department Princeton University

Computer System Overview

Memory Organization MEMORY ORGANIZATION. Memory Hierarchy. Main Memory. Auxiliary Memory. Associative Memory. Cache Memory.

Chapter 13: I/O Systems

Operating System Services

CS 333 Introduction to Operating Systems Class 2 OS-Related Hardware & Software The Process Concept

OPERATING SYSTEMS UNIT - 1

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

Introduction to Operating Systems. Chapter Chapter

Input Output (IO) Management

Chapter 12: I/O Systems

Chapter 13: I/O Systems

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

Chapter 1: Introduction

OS: An Overview. ICS332 Operating Systems

CS450/550 Operating Systems

Introduction to Operating. Chapter Chapter

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Introduction to Computer Systems and Operating Systems

DM510 Operating Systems. Jacob Aae Mikkelsen

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Operating System. Operating System Overview. Layers of Computer System. Operating System Objectives. Services Provided by the Operating System

Operating System Overview. Operating System

Memory. Objectives. Introduction. 6.2 Types of Memory

System Call. Preview. System Call. System Call. System Call 9/7/2018

Operating Systemss and Multicore Programming (1DT089)

I/O Devices. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

Architectural Support for Operating Systems

CSC 453 Operating Systems

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

Transcription:

Third Generation Batch Multiprogramming Misc. Problem: but I/O still expensive; can happen in middle of job Idea: have a pool of ready jobs in memory, switch to one when another needs I/O When one job needs I/O, switch to another while the I/O is done OS Role: Need to support multiple jobs How to switch from one job to another? Resources now shared: Need extra functions to share resources (including memory management and CPU scheduling) Unix Session next week any suggestions for time? Still working on room reservations. Will be posted on class homepage Last time: A User-Computer Interface A Resource Manager A Control Program A quick walk-through the development of OSs SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 3 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 1 Fourth Generation Time Sharing Computing becoming cheap + new applications (e.g. interactive) Switch between jobs preemptively (not just at I/O) why? How is this different that Batch Multiprocessing? Batch multiprogramming maximize throughput; Time Sharing minimize response time OS Support: timer to periodically switch among jobs Concurrency management, deadlock avoidance... Future generations: embedded OS ; distributed OS... SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 2 Key improvement: Job queue to eliminate human scheduling inefficiencies OS Role: A resident monitor program loads each job in turn Monitor passes control to job; job branches back when done Problems? I/O Slow; a lot of wasted CPU time Use off-line processing to pipeline across jobs and hide I/O cost Second Generation operator queues jobs in a batch CPU expensive; user at terminal inefficient OS Role: Some common functions started to emerge and be shared First Generation user at terminal Last Time Evolution of OSs SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 4

Today A quick tour of computer organization Operating System Prelimenaries Major components of an OS What services does the OS provide to programs How does the OS start execution Start process management SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 5 A tour of Computer Organization L2 Cache Bus Adpater IDE or SCSI controller System bus (EISA, SDRAM, or RDRAM) DRAM I/O bus (PCI) IDE or SCSI drives DRAM Network Interface Card A Computer System consists of: Processor: the workhorse Memory: holds instructions and data I/O Devices: interface with the world USB adapter/ Bus SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 6 Processor Overview Handling Interrupts The processor consists of: Arithematic Logic Unit (the number cruncher) General Purpose Registers (data/address) Control Registers (PC, IR, etc..) Control unit Your program is compiled into a machine language program The processor executes a sequence of machine instructions Fetch Decode Execute cycle: fetch an instruction from memory (at location pointed to by program counter) into the instruction register Decode the instruction execute the instruction Repeat until the program halts The program counter is automatically incremented to point to the next instruction Processor must also handle interrupts Interrupts are generated by events such as I/O devices completing execution Exceptions (e.g., division by zero, illegal instruction, invalid mem. address) Timers Software traps (most important are system calls) When an interrupt happens, save state and go to an Interrupt Service Routine (ISR) How do we know what is the ISR address to branch to? Polling Vector Interrupt Table What support is needed in hardware? (check for the interrupt, saving control registers) SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 7 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 8

Hardware Protection Odds and Ends Need to ensure that a program does not harm other programs or the OS (intentionally or due to bugs) What support in hardware? Need support for a priviledged mode only the OS runs in priviledged mode I/O operations only issued by the OS Memory Protection how to protect against reading/writing someone elses memory? CPU protection how to make sure the job eventually leaves the CPU? Events: Interrupts, exceptions and traps Multiple Interrupts? Disable interrupts while in interrupt service routine (Sequential processing of interrupts) Allow nested interrupts; stop and allow a higher priority interrupt to be processed Modern OS s are event driven A program communicates with the OS using system calls to request a service I/O devices also interrupt OS SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 11 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 9 The Memory Hierarchy Would like very large, very fast, very cheap memory Problem: fast memory is expensive Solution: Build a Memory Hierarchy a pyramid of different memory levels where each lower level has: Lower cost per bit Larger capacity Slower Response Time How does this work? why does this work? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 10 What is to stop any program from just branching into (or duplicating) the OS code? 1. System call causes a trap to the OS 2. OS determines what service is being asked for and branches there 3. Branch back to the program A program requests services from the OS using system calls User Program read from file (3) System call (1) perform read I/O (2) case read: OS code System Calls SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 12

Example: Cache Memory Why Memory Hierarchy Works CPU word transfer Cache block transfer Main Memory Small, expensive Static RAM (on-chip or off-chip) access time can be 100 times faster than main memory References to memory are not random; they tend to be: spatially localized (if you visit a location, likely to visit neighbors) temporally localized (if you visit a location, likely to visit again soon) Think of the last program your wrote; does this hold true? Hierarchy Works because of this principle of Locality of Reference Example: access time to level 1 is 1; access time to level 2 is 100; Hit ratio (how often you find the item in level 1) is 98% SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 15 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 13 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 16 Cache coherency Write Policy (write-through vs. write-back) Example: suppose memory is 32 words, cache is 4 words. Track the following memory accesses: 0, 3, 8, 7, 8, 2, 3, 2 Find the entry based on the low order m bits Compare tag against rest of address to determine hit or miss To check if a given address is in the cache Low order m bits determine location in cache High order n m bits stored in tag Assume memory address is n bits and cache size 2 m blocks Direct Mapped Cache How Memory Hierarchy Works When a memory access is needed, look for it in the fastest level of memory. If it is there hit, we are done If it is not there miss happens look for the item in the next lower level; Repeat until a hit happens. Bring a block from the level where the hit occurs and update all the levels above it (replacing another block if necessary) Need mechanisms to: (i) find out if an item is in a particular level; (ii) decide where an item may go (mapping policy); (iii) decide what block to replace if we need a new one; and (iv) write policy We will look at an example Caches SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 14

Interrupt Driven I/O Instead of hanging around and checking the I/O device frequently, rely on the I/O device to signal an interrupt when it is done When the interrupt is received, the processor carries out the transfer like before (assuming an input) Infrequent Polling is sometimes used as well Why is this better than Programmed I/O? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 17 The CPU can control the device by writing to its registers or check its status by reading these registers I/O controller registers are usually memory mapped Actual I/O happens between device and the controller buffering space, it is then copied to memory Controller is a small processor with some buffering space An I/O device usually has a controller I/O Devices SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 19 Direct Memory Access (DMA) Communicating with I/O Devices Programmed I/O Direct Memory Access: A separate controller (usually on the system bus) carries out the I/O operation for the CPU The CPU is interrupted when the data transfer is complete Why is this better than Interrupt Driven I/O? What if the processor needs the memory while the DMA is underway? (cycle stealing) One of the primary tasks of an OS is to manage I/O resoruces Programmed I/O (read): Processor issues I/O command to device Keeps checking status until device is done (or failed) Processor copies data from device memory to main memory Inefficient; what can be done? Very efficient, especially for large transfers SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 20 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 18

Discussion What belongs in hardware, what belongs in software? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 21 Operating System Organization As with any large system, separate into modules to manage complexity System Components: Process Management Memory Management Disk Management I/O System Management File Management Protection Networking Command Interpreter (shells; window system) Other? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 22 Process Management What is a process? The animated spirit of a program The unit of resource allocation What does the OS need to worry about? Process creation (and destruction) Process scheduling (suspension/resumption) Provide mechanisms for Process synchronization Inter-process communication SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 23 Memory Management Memory is a linear array of data accessed by address Volatile data is lost on a reboot or failure Instructions and Data for each process are kept in memory Shared between CPU and I/O devices What does the OS need to worry about? Keep track of which part of memory is used and by whom Decide which process to load into memory when space is available Allocate and deallocate space as needed SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 24

Disk (Secondary Storage) Management Because memory is volatile, secondary storage is needed to keep permenant information usually a magenatic disk drive What does the OS need to worry about? Free space management Allocating space Disk scheduling Why are issues different than memory? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 25 I/O Management The OS has to manage the I/O devices efficiently. Furthermore, it should provide a uniform interface for programs to access the devices. What does the I/O system consist of? A buffer/caching system (to hide the gap in speed between I/O and memory) A general device-driver interface (to provide a consistent interface for the processes) Drivers for the specific I/O devices (usually provided by the manufacturer) File Management Files are the abstraction provided to the users to manage non-volatile information users view of secondary storage What does the OS need to worry about? File creation, deletion, and manipulation Directories and directory manipulation Mapping files onto disk File backup SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 27 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 26 Protection Other Components How to define protection/access control policies How to enforce them Usually integrated within the other components Networking/distributed processing what if the resources are replicated Command-line interpreter A systems program that provides an interface between the user and the OS What is a systems program? Accepts a user command, executes it, then waits for the next command A command is usually a request for an OS service (e.g., start a process to execute a given program) Example unix (or DOS) shell, Windows SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 28

Services Provided by the OS System calls The following services are exported to the user (how?) Program execution I/O operations File-system manipulation Communication (same system/with other systems; shared memory vs. message passing) Error detection OS also provides the following services to ensure the OS functions correctly and efficiently (services to the owner of the machine) Resource allocation how to share the resources among the processes Accounting Protection Provides the interface between a running program and the OS how does it compare to a command-lineinterpreter? Generally assisted by an assembly language instruction (trap, or syscall) How are they accessed from programming languages? Implementation wise, a system call is like a procedure call to an OS procedure Passing the parameters? In registers In a table in memory; pass a pointer as the only paramter Use a stack Need a mode switch to the priviledged mode Can you give specific examples of system calls? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 29 SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 30 Mode Switch Cost Recall: mode switch is switch from user to OS when a system call happens/finishes Context switch: mode switch + change the running process Mode switch more costly than procedure call? Yes Have to create a kernel stack Have to map kernel memory to user space (or context switch to a kernel process expensive) Less costly than context switch SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 31 Classes of System Calls Process control (e.g., load process, end process, allocate memory...) File control (e.g., create file or directory, read, close...) Device control (e.g., Request/release device, write, read, mount) Information maintenance (e.g., get or set time, system data, process attributes, file attributes or device attributes) Communication (e.g., create a connection, send/receive messages) Other...220+ system calls in linux 2.6 kernel SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 32

Systems Programs System programs are tools for program development and execution They include programs for File manipulation (e.g., cp, mv, grep, find) Providing status information (e.g., ps, top) File modification (e.g., editors) Programming language support (e.g., compilers, debuggers, assemblers) Program loading and execution Communication (e.g., telnet, ftp, rsh, ssh) Of course, the command line interpreter (tcsh, bash, command.com, etc..) Most users interact with system programs rather than system calls directly How does the OS start running? SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 33 Bootstrap By example PCs When machine is turned on, it runs Power On Self Test (POST), then It looks for a boot sector in the very first sector of the drive A boot sector is marked by 0xAA55 at offset 510 Usually tries the floppy then C: If it is found, the sector is read to memory at location 0x7c00 The machine then branches to this location and runs the code in the boot sector (Master Boot Record Program) The MBR loads up the rest of the OS SUNY-BINGHAMTON CS350 SPRING 08 LEC. #2 34