Introduction to Operating Systems. Chapter Chapter

Similar documents
Introduction to Operating Systems. Chapter Chapter

Introduction to Operating. Chapter Chapter

Introduction to Operating Systems

Role 1: The Operating System is an Abstract Machine. Learning Outcomes. Introduction to Operating Systems. What is an Operating System?

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

Computer System Overview

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

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

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

Operating System Overview. Operating System

Computer System Overview

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

Introduction. CS3026 Operating Systems Lecture 01

Operating Systems Overview. Chapter 2

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

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

Introduction. COMP3231/9201/3891/9283 (Extended) Operating Systems Kevin Elphinstone

Course Outline. Introduction. Lectures. Why does this fail? Tutorials. Assignments

Lecture 1 Introduction (Chapter 1 of Textbook)

Introduction. COMP3231/9201/3891/9283 (Extended) Operating Systems Kevin Elphinstone

Introduction. COMP3231/9201/3891/9283 (Extended) Operating Systems Kevin Elphinstone

Course Outline Prerequisites COMP2011 Data Organisation Stacks, queues, hash tables, lists, trees, heaps,. Introduction

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

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics

CS370 Operating Systems

Computer System Overview. Chapter 1

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy

Lecture 2: September 9

Chapter 1 Computer System Overview

Common Computer-System and OS Structures

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

Operating System Overview. Chapter 2

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

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

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

Computer System Overview

Chapter 1: Introduction

Q.1 Explain Computer s Basic Elements

Unit 2 : Computer and Operating System Structure

Review: Hardware user/kernel boundary

CS510 Operating System Foundations. Jonathan Walpole

Four Components of a Computer System

Chapter 1: Introduction

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

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program

CS370 Operating Systems

I/O Handling. ECE 650 Systems Programming & Engineering Duke University, Spring Based on Operating Systems Concepts, Silberschatz Chapter 13

Systems Architecture II

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III

Virtual Memory Oct. 29, 2002

Hardware OS & OS- Application interface

Operating System Services

Anne Bracy CS 3410 Computer Science Cornell University

Chapter 1: Introduction. Chapter 1: Introduction

CS399 New Beginnings. Jonathan Walpole

virtual memory Page 1 CSE 361S Disk Disk

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

CS370 Operating Systems

Architectural Support for Operating Systems

Chapter 1: Introduction

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

Chapter 9: Virtual Memory

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

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Operating System Support

Chapter 13: I/O Systems

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Networks and Operating Systems Chapter 11: Introduction to Operating Systems

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

Chapter 8: Virtual Memory. Operating System Concepts

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

CS370 Operating Systems

Operating Systems Overview. Chapter 2

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

CISC 360. Virtual Memory Dec. 4, 2008

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

CS450/550 Operating Systems

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

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

LECTURE 4: LARGE AND FAST: EXPLOITING MEMORY HIERARCHY

Operating Systems Overview

Following are a few basic questions that cover the essentials of OS:

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

Hardware, Modularity, and Virtualization CS 111

I/O Management and Disk Scheduling. Chapter 11

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

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation

OPERATING SYSTEM. Chapter 9: Virtual Memory

Chapter 9: Virtual-Memory

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

CS 333 Introduction to Operating Systems. Class 1 - Introduction to OS-related Hardware and Software

18-447: Computer Architecture Lecture 16: Virtual Memory

Operating System Review

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Operating Systems: Internals and Design Principles, 7/E William Stallings. Chapter 1 Computer System Overview

Transcription:

Introduction to Operating Systems Chapter 1 1.3 Chapter 1.5 1.9

Learning Outcomes High-level understand what is an operating system and the role it plays A high-level understanding of the structure of operating systems, applications, and the relationship between them. Some knowledge of the services provided by operating systems. Exposure to some details of major OS concepts. 2

What is an Operating System? 3

Block Diagram of Haswell Platform Architecture http://www.pcquest.com 4

Viewing the Operating System as an Abstract Machine Extends the basic hardware with added functionality Provides high-level abstractions More programmer friendly Common core for all applications It hides the details of the hardware Makes application code portable 5

Disk Users Memory CPU Network Bandwidth 6

Viewing the Operating System as a Resource Manager Responsible for allocating resources to users and processes Must ensure No Starvation Progress Allocation is according to some desired policy First-come, first-served; Fair share; Weighted fair share; limits (quotas), etc Overall, that the system is efficiently used 7

Structural View: the Operating System as the Privileged Component Applications Applications Applications User Mode Requests (System Calls) Privileged Mode Operating System Hardware 8

Operating System Kernel Portion of the operating system that is running in privileged mode Usually resident in main memory Contains fundamental functionality Whatever is required to implement other services Whatever is required to provide security Contains most-frequently used functions Also called the nucleus or supervisor 9

The Operating System is Privileged Applications should not be able to interfere or bypass the operating system OS can enforce the extended machine OS can enforce its resource allocation policies Prevent applications from interfering with each other Applications Applications Applications User Mode Privileged Mode Operating System Hardware 10

Structure of a Computer System Application System Libraries Application System Libraries User Mode Kernel Mode Device Device Operating System Memory 11

Structure of a Computer System User Mode Application System Libraries Kernel Mode Device Device OS OS interacts via load and store instructions to all memory, CPU and device registers, and interrupts Memory 12

Structure of a Computer System Application Applications interact with themselves and via function calls to library procedures User Mode System Libraries Kernel Mode Device OS Device Memory 13

Structure of a Computer System Application Interaction via System Calls System Libraries User Mode Kernel Mode Device Device OS Memory 14

Privilege-less OS Some Embedded OSs have no privileged component e.g. PalmOS, Mac OS 9, RTEMS Can implement OS functionality, but cannot enforce it. All software runs together No isolation One fault potentially brings down entire system 15

A Note on System Libraries System libraries are just that, libraries of support functions (procedures, subroutines) Only a subset of library functions are actually systems calls strcmp(), memcpy(), are pure library functions manipulate memory within the application, or perform computation open(), close(), read(), write() are system calls they cross the user-kernel boundary, e.g. to read from disk device Implementation mainly focused on passing request to OS and returning result to application System call functions are in the library for convenience try man syscalls on Linux 16

Operating System Software Fundamentally, OS functions the same way as ordinary computer software It is a program that is executed (just like applications) It has more privileges Operating system relinquishes control of the processor to execute other programs Reestablishes control after System calls Interrupts (especially timer interrupts) User Mode Kernel Mode Device Device Application System Libraries OS Memory 17

Major OS Concepts (Overview) Processes Concurrency and deadlocks Memory management Files Scheduling and resource management Information Security and Protection 18

Processes A program in execution An instance of a program running on a computer The entity that can be assigned to and executed on a processor A unit of resource ownership 19

Minimally consist of three segments Text contains the code (instructions) Data Global variables Stack Activation records of procedure Local variables Note: data can dynamically grow up The stack can dynamically grow down Process Memory Stack Gap Data Text 20

Process state Consists of three components An executable program text Associated data needed by the program Data and stack Execution context of the program Registers, program counter, stack pointer Information the operating system needs to manage the process OS-internal bookkeeping, files open, etc 21

Multiple processes creates concurrency issues (a) A potential deadlock. (b) an actual deadlock. 22

Memory Management The view from thirty thousand feet Process isolation Prevent processes from accessing each others data Automatic allocation and management Don t want users to deal with physical memory directly Protection and access control Still want controlled sharing Long-term storage OS services Virtual memory File system 23

Virtual Memory Allows programmers to address memory from a logical point of view Gives apps the illusion of having RAM to themselves Logical addresses are independent of other processes Provides isolation of processes from each other Can overlap execution of one process while swapping in/out others to disk. 24

Virtual Memory Addressing Memory management unit (hardware) translates program memory addresses to main memory addresses. 25

File System Implements long-term store Information stored in named objects called files 26

Example File System 27

Information Protection and Access control Security regulate user access to the system Involves authentication Information flow control regulate flow of data within the system and its delivery to users 28

Scheduling and Resource Fairness Management give equal and fair access to all processes Differential responsiveness discriminate between different classes of jobs Efficiency maximize throughput, minimize response time, and accommodate as many uses as possible 29

Operating System Internal Structure? 30

Classic Operating System Structure The layered approach a) Processor allocation and multiprogramming b) Memory Management c) Devices d) File system e) Users Each layer depends on the inner layers a b c d e 31

Operating System Structure In practice, layering is only a guide Operating Systems have many interdependencies Scheduling on virtual memory Virtual memory (VM) on I/O to disk VM on files (page to file) Files on VM (memory mapped files) And many more 32

The Monolithic Operating System Structure Also called the spaghetti nest approach Everything is tangled up with everything else. Linux, Windows,. 33

The Monolithic Operating However, some reasonable structure usually prevails System Structure Bowman, I. T., Holt, R. C., and Brewster, N. V. 1999. Linux as a case study: its extracted software architecture. In Proceedings of the 21st international Conference on Software Engineering (Los Angeles, California, United States, May 16-22, 1999). ICSE '99. ACM, New York, NY, 555-563. DOI= http://doi.acm.org/10.1145/302405.302691 34

35

Computer Hardware Review Chapter 1.4

Learning Outcomes Understand the basic components of computer hardware CPU, buses, memory, devices controllers, DMA, Interrupts, hard disks Understand the concepts of memory hierarchy and caching, and how they affect performance. 37

Operating Systems Exploit the hardware available Provide a set of high-level services that represent or are implemented by the hardware. Manages the hardware reliably and efficiently Understanding operating systems requires a basic understanding of the underlying hardware 38

Basic Computer Elements 39

Basic Computer Elements CPU Performs computations Load data to/from memory via system bus Device controllers Control operation of their particular device Operate in parallel with CPU Can also load/store to memory (Direct Memory Access, DMA) Control register appear as memory locations to CPU Or I/O ports Signal the CPU with interrupts Memory Controller Responsible for refreshing dynamic RAM Arbitrating access between different devices and CPU 40

The real world is logically similar, but more complex 41

A Simple Model of CPU Computation The fetch-execute cycle 42

A Simple Model of CPU Computation The fetch-execute cycle Load memory contents from address in program counter (PC) The instruction Execute the instruction Increment PC Repeat CPU Registers PC: 0x0300 SP: 0xcbf3 Status R1 Rn 43

A Simple Model of CPU Computation Stack Pointer Status Register Condition codes Positive result Zero result Negative result General Purpose Registers Holds operands of most instructions Enables programmers (compiler) to minimise memory references. CPU Registers PC: 0x0300 SP: 0xcbf3 Status R1 Rn 44

Privileged-mode Operation To protect operating system execution, two or more CPU modes of operation exist Privileged mode (system-, kernel-mode) All instructions and registers are available User-mode Uses safe subset of the instruction set E.g. no disable interrupts instruction Only safe registers are accessible CPU Registers Interrupt Mask Exception Type MMU regs Others PC: 0x0300 SP: 0xcbf3 Status R1 Rn 45

Safe registers and instructions Registers and instructions are safe if Only affect the state of the application itself They cannot be used to uncontrollably interfere with The operating system Other applications They cannot be used to violate a correctly implemented operating system. 46

Example Unsafe Instruction cli instruction on x86 architecture Disables interrupts Example exploit cli /* disable interrupts */ while (true) /* loop forever */; 47

Privileged-mode Operation Memory Address Space The accessibility of addresses within an address space changes depending on operating mode To protect kernel code and data Note: The exact memory ranges are usually configurable, and vary between CPU architectures and/or operating systems. 0xFFFFFFFF 0x80000000 0x00000000 Accessible only to Kernel-mode Accessible to User- and Kernel-mode 48

I/O and Interrupts I/O events (keyboard, mouse, incoming network packets) happen at unpredictable times How does the CPU know when to service an I/O event? 49

Interrupts An interruption of the normal sequence of execution A suspension of processing caused by an event external to that processing, and performed in such a way that the processing can be resumed. Improves processing efficiency Allows the processor to execute other instructions while an I/O operation is in progress Avoids unnecessary completion checking (polling) 50

Interrupt Cycle Processor checks for interrupts If no interrupts, fetch the next instruction If an interrupt is pending, divert to the interrupt handler 51

Interrupt Terminology Program exceptions (sometimes called synchronous interrupts, traps) Arithmetic overflow Division by zero Executing an illegal/privileged instruction Reference outside user s memory space. Asynchronous (external) interrupts (usually just called interrupts) Timer I/O Hardware or power failure 52

Interrupt Handler A software routine that determines the nature of the interrupt and performs whatever actions are needed. Control is transferred to the handler by hardware. The handler is generally part of the operating system. 53

Simple Interrupt User Mode Application Kernel Mode Interrupt Handler 54

Memory Hierarchy Going down the hierarchy Decreasing cost per bit Increasing capacity Increasing access time Decreasing frequency of access to the memory by the processor Hopefully Principle of locality!!!!! 55

Caching as a general technique Given a two-levels data storage: small and fast, versus large and slow, Can speed access to slower data by using intermediate-speed memory as a cache. 56

A hardware approach to improving system performance? CPU Registers Fast Cache Memory (SRAM) Fast Main Memory (DRAM) Slow 57

CPU Cache CPU Registers Word Transfer Cache Memory Block Transfer Main Memory CPU cache is fast memory placed between the CPU and main memory 1 to a few cycles access time compared to RAM access time of tens hundreds of cycles Holds recently used data or instructions to save memory accesses. Matches slow RAM access time to CPU speed if high hit rate Is hardware maintained and (mostly) transparent to software Sizes range from few kb to several MB. Usually a hierarchy of caches (2 5 levels), on- and off-chip. Block transfers can achieve higher transfer bandwidth than single words. Also assumes probability of using newly fetch data is higher than the probability of reusing ejected data. 58

Performance What is the effective access time of memory subsystem? Answer: It depends on the hit rate in the first level. 59

Effective Access Time T T T 1 H T eff 2 eff = = = = = H T access access 1 + (1 time of time of hit rate in memory 1 effective access H ) T 2 memory 1 memory 2 time of system 60

Example Cache memory access time 1ns Main memory access time 10ns Hit rate of 95% Teff = 0.95 10 9 + (1 0.95) (10 9 + 10 10 9 ) = 1.5 10 9 61

Moving-Head Disk Mechanism 62

Example Disk Access Times Disk can read/write data relatively fast 15,000 rpm drive - 80 MB/sec 1 KB block is read in 12 microseconds Access time dominated by time to locate the head over data Rotational latency Half one rotation is 2 milliseconds Seek time Full inside to outside is 8 milliseconds Track to track.5 milliseconds 2 milliseconds is 164KB in lost bandwidth 63

A OS approach to improving system performance? CPU Registers Fast Main Memory (DRAM) Fast Hard disk Slow 64

A Strategy: Avoid Waiting for Disk Access Keep a subset of the disk s data in main memory OS uses main memory as a cache of disk contents 65

Application approach to improving system performance Web browser Fast Hard disk Fast Internet Slow 66

A Strategy: Avoid Waiting for Internet Access Keep a subset of the Internet s data on disk Application uses disk as a cache of the Internet 67