William Stallings Computer Organization and Architecture

Similar documents
Chapter 7 Memory Management

Chapter 7 Memory Management

Operating Systems, 6 th ed. Test Bank Chapter 7

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

Chapter 2: OS Overview

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

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

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

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

OPERATING SYSTEM - MEMORY MANAGEMENT

Virtual vs Physical Addresses

OPERATING SYSTEM OVERVIEW

OPERATING SYSTEM - VIRTUAL MEMORY

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

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct)

Introduction. What is an Operating System?

CS161: Operating Systems

W4118: segmentation and paging. Instructor: Junfeng Yang

Computer-System Architecture

OPERATING SYSTEMS MEMORY MANAGEMENT

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Memory management. Chapter 4: Memory Management. Memory hierarchy. In an ideal world. Basic memory management. Fixed partitions: multiple programs

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet.

COS 318: Operating Systems. Virtual Memory and Address Translation

Operating Systems 4 th Class

Chapter 11 I/O Management and Disk Scheduling

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Chapter 3. Operating Systems

System Virtual Machines

Lecture 17: Virtual Memory II. Goals of virtual memory

Computers: Tools for an Information Age

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

The Xen of Virtualization

Convenience: An OS makes a computer more convenient to use. Efficiency: An OS allows the computer system resources to be used in an efficient manner.

Chapter 1 Computer System Overview

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

Operating Systems CSE 410, Spring File Management. Stephen Wagner Michigan State University

CS5460: Operating Systems

Virtual Memory. Virtual Memory. Paging. CSE 380 Computer Operating Systems. Paging (1)

Chapter 12 File Management

Chapter 3 Operating-System Structures

Operating System Tutorial

1. Computer System Structure and Components

Multiprogramming. IT 3123 Hardware and Software Concepts. Program Dispatching. Multiprogramming. Program Dispatching. Program Dispatching

Outline: Operating Systems

An Implementation Of Multiprocessor Linux

& Data Processing 2. Exercise 3: Memory Management. Dipl.-Ing. Bogdan Marin. Universität Duisburg-Essen

Peter J. Denning, Naval Postgraduate School, Monterey, California

Secondary Storage. Any modern computer system will incorporate (at least) two levels of storage: magnetic disk/optical devices/tape systems

Operating Systems. Virtual Memory

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

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Memory Management under Linux: Issues in Linux VM development

Chapter 11 I/O Management and Disk Scheduling

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

CS0206 OPERATING SYSTEMS Prerequisite CS0201, CS0203

Chapter 12. Paging an Virtual Memory Systems

General Purpose Operating System Support for Multiple Page Sizes

Chapter 12 File Management

Chapter 5 Cloud Resource Virtualization

Chapter 6, The Operating System Machine Level

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Virtual Machines. COMP 3361: Operating Systems I Winter

Processes and Non-Preemptive Scheduling. Otto J. Anshus

The Microsoft Windows Hypervisor High Level Architecture

Components of a Computer System

Overview and History of Operating Systems

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

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Chapter 12 File Management

Chapter 12 File Management. Roadmap

Chapter 1: Introduction. What is an Operating System?

Types Of Operating Systems

Operating system Dr. Shroouq J.

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 3. Operating Systems N/H/MWF@12

Virtualization. Pradipta De

Analysis and Comparison of CPU Scheduling Algorithms

Windows Server Performance Monitoring

Timing of a Disk I/O Transfer

Chapter 2 System Structures

Record Storage and Primary File Organization

Performance Comparison of RTOS

Operating Systems. Lecture 03. February 11, 2013

This Unit: Virtual Memory. CIS 501 Computer Architecture. Readings. A Computer System: Hardware

Board Notes on Virtual Memory

Two Parts. Filesystem Interface. Filesystem design. Interface the user sees. Implementing the interface

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

ELEC 377. Operating Systems. Week 1 Class 3

Virtualization. Explain how today s virtualization movement is actually a reinvention

COSC 6374 Parallel Computation. Parallel I/O (I) I/O basics. Concept of a clusters

This tutorial will take you through step by step approach while learning Operating System concepts.

File Management. Chapter 12

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

CPU Scheduling. Core Definitions

Linux Process Scheduling Policy

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

CHAPTER 15: Operating Systems: An Overview

Full and Para Virtualization

Transcription:

William Stallings Computer Organization and Architecture Chapter 8 Operating System Support Rev. 3.2 (2009-10) by Enrico Nardelli 8-1

Objectives and Functions Convenience Making the computer easier to use Efficiency Allowing better use of computer resources Rev. 3.2 (2009-10) by Enrico Nardelli 8-2

Layers and Views of a Computer System Rev. 3.2 (2009-10) by Enrico Nardelli 8-3

Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System access Error detection and response Accounting Rev. 3.2 (2009-10) by Enrico Nardelli 8-4

OS as Resource Manager OS is responsible for managing resources of the computer OS is an unusual control mechanism in two respects: it functions in the same way as a ordinary computer software it frequently relinquishes control and must depend on the processor to allow it to regain control Rev. 3.2 (2009-10) by Enrico Nardelli 8-5

O/S as a Resource Manager Rev. 3.2 (2009-10) by Enrico Nardelli 8-6

Types of Operating System Batch Interactive Single program (Uni-programming) Multiple programs (Multi-tasking) Rev. 3.2 (2009-10) by Enrico Nardelli 8-7

Early Systems Late 1940s to mid 1950s No Operating System Programs interact directly with hardware Two main problems: Scheduling Set-up time Rev. 3.2 (2009-10) by Enrico Nardelli 8-8

Simple Batch Systems Resident Monitor program Users submit jobs to operator Operator batches jobs Monitor controls sequence of events to process batch When one job is finished, control returns to Monitor which reads next job Monitor handles scheduling Rev. 3.2 (2009-10) by Enrico Nardelli 8-9

Job Control Language Instructions to Monitor Usually denoted by $ e.g. $JOB $FTN... $LOAD $RUN... $END Some Fortran instructions Some data Rev. 3.2 (2009-10) by Enrico Nardelli 8-10

Desirable Hardware Features Memory protection To protect the Monitor Timer To prevent a job monopolizing the system Privileged instructions Only executed by Monitor e.g. I/O Interrupts Allows for relinquishing and regaining control Rev. 3.2 (2009-10) by Enrico Nardelli 8-11

Overhead Two sacrifices: some main memory is used by the monitor some CPU time is consumed by the monitor Rev. 3.2 (2009-10) by Enrico Nardelli 8-12

Multi-programmed Batch Systems I/O devices very slow When one program is waiting for I/O, another can use the CPU Rev. 3.2 (2009-10) by Enrico Nardelli 8-13

Single Program Rev. 3.2 (2009-10) by Enrico Nardelli 8-14

Multi-Programming with Two Programs Rev. 3.2 (2009-10) by Enrico Nardelli 8-15

Multi-Programming with Three Programs Rev. 3.2 (2009-10) by Enrico Nardelli 8-16

Time Sharing Systems Multi-programming allows to have many programs running at the same time but multi-user interactivity requires more In each given amount of time (small!) pay attention to every user Users share the time of the computer, each actually consuming only a little slice Rev. 3.2 (2009-10) by Enrico Nardelli 8-17

Concept of process Several definitions including: a program in execution the animated spirit of a program the entity to which a processor is assigned Rev. 3.2 (2009-10) by Enrico Nardelli 8-18

Scheduling Key to multi-programming Long term scheduling Medium term scheduling Short term scheduling I/O management Rev. 3.2 (2009-10) by Enrico Nardelli 8-19

Long Term Scheduling Determines which programs are accepted for processing i.e. controls the degree of multi-programming Currently, simply accept programs for processing i.e. transform a program into a process Once accepted, a program becomes a process, to be managed by the short term scheduler or it becomes a swapped out job for the medium term scheduler Rev. 3.2 (2009-10) by Enrico Nardelli 8-20

Medium Term Scheduling Determines which process can be entered in the central memory (i.e., swapped in) Part of the swapping function (later ) Usually based on the need to manage multiprogramming If no virtual memory, memory management is also an issue Rev. 3.2 (2009-10) by Enrico Nardelli 8-21

Short Term Scheduler Dispatcher Fine grained decisions of which process to execute next i.e. which process actually gets to use the processor in the next time slot Rev. 3.2 (2009-10) by Enrico Nardelli 8-22

Process States Long Term Sched. Medium Term Sched. Short Term Sched. Rev. 3.2 (2009-10) by Enrico Nardelli 8-23

Process Control Block Identifier State Priority Program counter Process Memory pointers Context data I/O status Accounting information Rev. 3.2 (2009-10) by Enrico Nardelli 8-24

A simple example Operating System Service handler scheduler Interrupt handler A running CPU Operating System Service handler scheduler Interrupt handler A waiting CPU Operating System Service handler scheduler Interrupt handler A waiting B ready Other partitions B ready Other partitions B running Other partitions CPU Rev. 3.2 (2009-10) by Enrico Nardelli 8-25

Key Elements of O/S Rev. 3.2 (2009-10) by Enrico Nardelli 8-26

Process Scheduling Medium-Term Queue Long-Term Queue Short-Term Queue CPU End I/O I/O Queue I/O I/O Queue Rev. 3.2 (2009-10) by Enrico Nardelli 8-27

Memory Management Uni-program Memory split into two One for Operating System (monitor) One for currently executing program Multi-program User part is sub-divided and shared among active processes Requires memory management capabilities Rev. 3.2 (2009-10) by Enrico Nardelli 8-28

Swapping Problem: I/O is so slow compared with CPU that even in multi-programming system, CPU can be idle most of the time Solutions: Increase main memory Expensive Leads to larger programs Swapping Rev. 3.2 (2009-10) by Enrico Nardelli 8-29

What is Swapping? Long term queue of processes stored on disk Processes swapped in as space becomes available As a process completes it is moved out of main memory If none of the processes in memory are ready (i.e. all I/O blocked) Swap out a blocked process to medium-term queue Swap in a ready process or a new process But swapping is an I/O process... Rev. 3.2 (2009-10) by Enrico Nardelli 8-30

Swapping disk storage medium-term queue main memory Operating System completed jobs long-term queue Rev. 3.2 (2009-10) by Enrico Nardelli 8-31

Partitioning Splitting memory into sections to allocate to processes (including Operating System) Fixed-size partitions First solution: all partitions of equal size, but it wastes a lot of memory Better solution: partitions of unequal size. Process is fitted into smallest hole that will take it (best fit) Still some wasted memory Leads to variable sized partitions Rev. 3.2 (2009-10) by Enrico Nardelli 8-32

Fixed-size Partitioning Rev. 3.2 (2009-10) by Enrico Nardelli 8-33

Variable Sized Partitions (1) Allocate exactly the required memory to a process This leads to a hole at the end of memory, too small to use Only one small hole - less waste When all processes are blocked, swap out a process and bring in another New process may be smaller than swapped out process Another hole Rev. 3.2 (2009-10) by Enrico Nardelli 8-34

Variable Sized Partitions (2) Eventually have lots of holes (fragmentation) Solutions: Coalesce - Join adjacent holes into one large hole Compact - From time to time go through memory and move all hole into one free block (c.f. disk defragmentation) Rev. 3.2 (2009-10) by Enrico Nardelli 8-35

Effect of Dynamic Partitioning Rev. 3.2 (2009-10) by Enrico Nardelli 8-36

Relocation No guarantee that process will load into the same place in memory Instructions contain addresses Locations of data Addresses for instructions (branching) Logical address - relative to beginning of program Physical address - actual location in memory (this time) Automatic conversion using base address Hardware feature supporting an OS requirement Rev. 3.2 (2009-10) by Enrico Nardelli 8-37

Paging Split memory into equal sized, small chunks - page frames Split programs (processes) into equal sized small chunks - pages Allocate the required number page frames to a process Operating System maintains list of free frames A process does not require contiguous page frames Use page table to keep track Rev. 3.2 (2009-10) by Enrico Nardelli 8-38

Rev. 3.2 (2009-10) by Enrico Nardelli 8-39

Logical and Physical Addresses - Paging Rev. 3.2 (2009-10) by Enrico Nardelli 8-40

Virtual Memory Demand paging Do not require all pages of a process in memory Bring in pages as required Page fault Required page is not in memory Operating System must swap in required page May need to swap out a page to make space Select page to throw out based on recent history Rev. 3.2 (2009-10) by Enrico Nardelli 8-41

Bonus We do not need all of a process in memory for it to run We can swap in pages as required So - we can now run processes that are bigger than total memory available! Main memory is called real memory User/programmer sees much bigger memory - virtual memory Rev. 3.2 (2009-10) by Enrico Nardelli 8-42

Thrashing Too many processes in too little memory Operating System spends all its time swapping Little or no real work is done Disk light is on all the time Solutions Good page replacement algorithms Fit more memory Reduce number of processes running Rev. 3.2 (2009-10) by Enrico Nardelli 8-43

Some details about paging Where is the page table (PT) stored? in the main memory: two registers: Page-table base register (PTBR) Page-table length register (PTLR) for each address we have 2 memoy accesses Usually a cache is used: translation lookaside buffer (TLB) What can we do if the PT is too big? two-level paging: paging of the PT And if there are too many processes? inverted page table Rev. 3.2 (2009-10) by Enrico Nardelli 8-44

Idea: an entry for each memory frame search is expensive!!! inverted page table Rev. 3.2 (2009-10) by Enrico Nardelli 8-45

Page Table Structure (hash!) Rev. 3.2 (2009-10) by Enrico Nardelli 8-46

Segmentation Paging is not (usually) visible to the programmer Segmentation is visible to the programmer Usually different segments allocated to program and data May be a number of program and data segments Rev. 3.2 (2009-10) by Enrico Nardelli 8-47

Advantages of Segmentation Simplifies handling of growing data structures Allows programs to be altered and recompiled independently, without re-linking and re-loading Lends itself to sharing among processes Lends itself to protection Some systems combine segmentation with paging Rev. 3.2 (2009-10) by Enrico Nardelli 8-48