8.1 Background. Base and Limit Registers. Chapter 8: Memory-Management Management Strategies. Objectives

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

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

OPERATING SYSTEM - MEMORY MANAGEMENT

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

Chapter 7 Memory Management

OPERATING SYSTEMS MEMORY MANAGEMENT

Chapter 7 Memory Management

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

Operating Systems, 6 th ed. Test Bank Chapter 7

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

Virtual vs Physical Addresses

Chapter 11: File System Implementation. Chapter 11: File System Implementation. Objectives. File-System Structure

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

Chapter 11: File System Implementation. Operating System Concepts with Java 8 th Edition

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

Devices and Device Controllers

Outline: Operating Systems

Operating System Tutorial

OPERATING SYSTEM - VIRTUAL MEMORY

CS5460: Operating Systems

Computer Science 4302 Operating Systems. Student Learning Outcomes

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

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

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

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.

Computer-System Architecture

Disk Space Management Methods

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

OS OBJECTIVE QUESTIONS

Chapter 11: File System Implementation. Operating System Concepts 8 th Edition

CHAPTER 17: File Management

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

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

Chapter 12. Paging an Virtual Memory Systems

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Segmentation Segmentation: Generalized Base/Bounds

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

Operating Systems 4 th Class

COS 318: Operating Systems. Virtual Memory and Address Translation

Operating System Overview. Otto J. Anshus

Operating system Dr. Shroouq J.

Chapter 3 Operating-System Structures

Virtual Machines. COMP 3361: Operating Systems I Winter

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Non-Volatile Memory Programming on the Agilent 3070

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

Obj: Sec 1.0, to describe the relationship between hardware and software HW: Read p.2 9. Do Now: Name 3 parts of the computer.

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

University of Dublin Trinity College. Storage Hardware.

How To Understand And Understand An Operating System In C Programming

Chapter 11 I/O Management and Disk Scheduling

Computer Architecture

EZManage V4.0 Release Notes. Document revision 1.08 ( )

Lecture 17: Virtual Memory II. Goals of virtual memory

CS420: Operating Systems OS Services & System Calls

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

1 File Management. 1.1 Naming. COMP 242 Class Notes Section 6: File Management

A Comparative Study of CPU Scheduling Algorithms

Operating Systems. Virtual Memory

Operating System Structures

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Computer Systems Structure Input/Output

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

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

How To Write A Page Table

COMPUTER SCIENCE AND ENGINEERING - Microprocessor Systems - Mitchell Aaron Thornton

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

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

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

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

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

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

Operating Systems. Design and Implementation. Andrew S. Tanenbaum Melanie Rieback Arno Bakker. Vrije Universiteit Amsterdam

Outline. Operating Systems Design and Implementation. Chap 1 - Overview. What is an OS? 28/10/2014. Introduction

File Systems Management and Examples

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

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

Record Storage and Primary File Organization

K Hinds Page No. 1. Lecture 3 ASCII

Chapter 1 8 Essay Question Review

Oracle9i Release 2 Database Architecture on Windows. An Oracle Technical White Paper April 2003

The Classical Architecture. Storage 1 / 36

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

An Implementation Of Multiprocessor Linux

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

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Chapter 3: Operating-System Structures. Common System Components

CPU Scheduling. Core Definitions

Recommended hardware system configurations for ANSYS users

Chapter 2 System Structures

Example of Standard API

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

Keil C51 Cross Compiler

CS3600 SYSTEMS AND NETWORKS

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

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

Virtual Machines. Virtualization

Operating Systems. Lecture 03. February 11, 2013

Transcription:

Chapter 8: Memory-Management Management Strategies Objectives To provide a detailed description of various ways of organizing memory hardware To discuss various memory-management techniques, including paging and segmentation To provide a detailed description of the Intel Pentium, which supports both pure segmentation and segmentation with paging Memory-Management Management Strategies 8.1 Background 8.2 Swapping 8.3 Contiguous Memory Allocation 8.4 Paging 8.5 Structure of the Page Table 8.6 Segmentation 8.7 Example: The Intel Pentium 8.1 Silberschatz, Galvin and Gagne 2005 8.2 Silberschatz, Galvin and Gagne 2005 8.1 Background Base and Limit Registers Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are the only storage CPU can access directly Register access in one CPU clock (or less) Main memory can take many cycles Cache sits between main memory and CPU registers Protection of memory required to ensure correct operation Please refresh the Instruction Execution Cycle A pair of base and limit registers define the logical address space size 8.3 Silberschatz, Galvin and Gagne 2005 8.4 Silberschatz, Galvin and Gagne 2005

HW address protection with base and limit registers Binding of Instructions and Data to Memory physical Conceptually ( 概念上 ) 8.5 Silberschatz, Galvin and Gagne 2005 mostly used Address binding of instructions and data to memory addresses can happen at three different stages Compile time: If memory location known beforehand, absolute code can be generated; must recompile code if starting location changes Load time: Must generate relocatable code if memory location is not known at compile time Execution time: Binding delayed until run time if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers) 8.6 Silberschatz, Galvin and Gagne 2005 Multistep Processing of a User Program Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is central to proper memory management Logical address generated by the CPU; also referred to as virtual address Physical address address seen by the memory unit Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme 8.7 Silberschatz, Galvin and Gagne 2005 8.8 Silberschatz, Galvin and Gagne 2005

Memory-Management Management Unit (MMU( MMU) Example: Assembly Program (supplemented) Hardware device that maps virtual to physical address In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory The user program deals with logical addresses; it never sees the real physical addresses 8.9 Silberschatz, Galvin and Gagne 2005 8.10 Silberschatz, Galvin and Gagne 2005 Example: Machine Code Dynamic relocation using a relocation register MS-D used four relocation registers in loading and running processes. Why four, instead of one??? 8.11 Silberschatz, Galvin and Gagne 2005 8.12 Silberschatz, Galvin and Gagne 2005

Dynamic Loading Routine is not loaded until it is called Better memory-space utilization; unused routine is never loaded Useful when large amounts of code are needed to handle infrequently occurring cases No special support from the operating system is required. It is implemented through program design Dynamic Linking Linking postponed until execution time Small piece of code, called stub, used to locate the appropriate memory-resident library routine Stub replaces itself with the address of the routine, and executes the routine Operating system needed to check if routine is in processes memory address Dynamic linking is particularly useful for libraries with several versions Only programs compiled with the new library version are affected by the incompatible changes incorporated in it. Other programs will continue using the older library. This system is also known as shared libraries 8.13 Silberschatz, Galvin and Gagne 2005 8.14 Silberschatz, Galvin and Gagne 2005 8.2 Swapping Swapping A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution Backing store fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images Roll out, roll in swapping variant used for prioritybased scheduling algorithms; lower-priority process is swapped out so higher-priority process can be loaded and executed Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped Modified versions of swapping are found on many systems (i.e., UNIX, Linux, and Windows) System maintains a ready queue of ready-to-run processes which have memory images on disk Context-switch time in such a swapping system is fairly high, see example in p. 323 8.15 Silberschatz, Galvin and Gagne 2005 8.16 Silberschatz, Galvin and Gagne 2005

Schematic View of Swapping 8.3 Contiguous Allocation Modification of swapping: only enabled when many processes are using a threshold amount of memory I/O problem: if I/O is asynchronously accessing the user memory for I/O buffers, then the process cannot be swapped. > Latch job in memory while it is involved in I/O > Do I/O only into buffers Main memory usually into two partitions: Resident operating system, usually held in low memory with interrupt vector User processes then held in high memory Relocation registers used to protect user processes from each other, and from changing operating-system code and data Base register contains value of smallest physical address Limit register contains range of logical addresses each logical address must be less than the limit register MMU maps logical address dynamically 8.17 Silberschatz, Galvin and Gagne 2005 8.18 Silberschatz, Galvin and Gagne 2005 HW support for relocation and limit registers logical limit register < + relocation register physical address Fixed-sized partition Contiguous Allocation Multiple-partition allocation Hole block of available memory; holes of various size are scattered throughout memory When a process arrives, it is allocated memory from a hole large enough to accommodate it Operating system maintains information about: a) allocated partitions b) free partitions (hole) process 9 process 9 process 8 process 10 In reality 8.19 Silberschatz, Galvin and Gagne 2005 8.20 Silberschatz, Galvin and Gagne 2005

Dynamic Storage-Allocation Problem How to satisfy a request of size n from a list of free holes First-fit: Allocate the first hole that is big enough Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size Produces the smallest leftover hole Worst-fit: Allocate the largest hole; must also search entire list Produces the largest leftover hole First-fit and best-fit better than worst-fit in terms of speed and storage utilization. First-fit is normally faster. Fragmentation External Fragmentation total memory space exists to satisfy a request, but it is not contiguous Statistical analysis of first fit reveals a 50-percent rule property Internal Fragmentation allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used Reduce external fragmentation by compaction Shuffle memory contents to place all free memory together in one large block Compaction is possible only if relocation is dynamic, and is done at execution time I/O problem Latch job in memory while it is involved in I/O Do I/O only into buffers 8.21 Silberschatz, Galvin and Gagne 2005 8.22 Silberschatz, Galvin and Gagne 2005 8.4 Paging Address Translation Scheme Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is available Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8,192 bytes) Divide logical memory into blocks of same size called pages Keep track of all free frames To run a program of size n pages, need to find n free frames and load program Set up a page table to translate logical to physical addresses Internal fragmentation Address generated by CPU is divided into: Page number (p) used as an index into a page table which contains base address of each page in physical memory Page offset (d) combined with base address to define the physical memory address that is sent to the memory unit page number p m - n page offset For given logical address space 2 m and page size 2 n d n 8.23 Silberschatz, Galvin and Gagne 2005 8.24 Silberschatz, Galvin and Gagne 2005

Paging Hardware Paging Model of Logical and Physical Memory 8.25 Silberschatz, Galvin and Gagne 2005 8.26 Silberschatz, Galvin and Gagne 2005 Paging Example Free Frames 32-byte memory and 4-byte pages before allocation after allocation 8.27 Silberschatz, Galvin and Gagne 2005 8.28 Silberschatz, Galvin and Gagne 2005