Address binding Multiprogramming and CPU utilization Contiguous memory management Noncontiguous memory management

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

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

OPERATING SYSTEM - MEMORY MANAGEMENT

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

Chapter 7 Memory Management

Chapter 7 Memory Management

Operating Systems, 6 th ed. Test Bank Chapter 7

OPERATING SYSTEMS MEMORY MANAGEMENT

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

CS5460: Operating Systems

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

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

OPERATING SYSTEM - VIRTUAL MEMORY

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.

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

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

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

Virtual vs Physical Addresses

Operating System Tutorial

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

CHAPTER 17: File Management

Computer-System Architecture

Outline: Operating Systems

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

Chapter 12. Paging an Virtual Memory Systems

How To Write A Page Table

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

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

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

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

1. Computer System Structure and Components

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

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

COS 318: Operating Systems. Virtual Memory and Address Translation

Lecture 15. IP address space managed by Internet Assigned Numbers Authority (IANA)

OS OBJECTIVE QUESTIONS

Segmentation Segmentation: Generalized Base/Bounds

Chapter 13 File and Database Systems

Chapter 13 File and Database Systems

Disk Space Management Methods

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

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

Topics in Computer System Performance and Reliability: Storage Systems!

Chapter 3 Operating-System Structures

Memory Management CS 217. Two programs can t control all of memory simultaneously

Recommended hardware system configurations for ANSYS users

Energy Efficient MapReduce

Operating Systems 4 th Class

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

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

Chapter 11 I/O Management and Disk Scheduling

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

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

Unit Storage Structures 1. Storage Structures. Unit 4.3

In-memory Tables Technology overview and solutions

Chapter 12 File Management

Chapter 12 File Management. Roadmap

MS SQL Performance (Tuning) Best Practices:

Lecture 17: Virtual Memory II. Goals of virtual memory

Physical Data Organization

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

Operating Systems. Virtual Memory

TRACE PERFORMANCE TESTING APPROACH. Overview. Approach. Flow. Attributes

Windows Server Performance Monitoring

APP INVENTOR. Test Review

Chapter 2: OS Overview

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

The Classical Architecture. Storage 1 / 36

Non-Volatile Memory Programming on the Agilent 3070

File-System Implementation

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

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Segmentation and Fragmentation

4.2: Multimedia File Systems Traditional File Systems. Multimedia File Systems. Multimedia File Systems. Disk Scheduling

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

361 Computer Architecture Lecture 14: Cache Memory

Optimizing Linux Performance

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

Devices and Device Controllers

Filing Systems. Filing Systems

6. Storage and File Structures

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

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

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

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

We r e going to play Final (exam) Jeopardy! "Answers:" "Questions:" - 1 -

Traditional IBM Mainframe Operating Principles

Operating System Components

Full and Para Virtualization

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

Chapter 1 Computer System Overview

WHITE PAPER Optimizing Virtual Platform Disk Performance

Board Notes on 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

SQL Server Performance Tuning and Optimization

High-Performance Processing of Large Data Sets via Memory Mapping A Case Study in R and C++

OPERATING SYSTEM SERVICES

Transcription:

Lecture Overview Memory management Address binding Multiprogramming and CPU utilization Contiguous memory management Noncontiguous memory management Paging Operating Systems - May 31, 2001 Memory Ideally programmers want memory that is Large Fast Nonvolatile Memory hierarchy Small amount of fast, expensive cache Some medium-speed, medium price main memory Gigabytes of slow, cheap disk storage Memory manager handles the memory hierarchy 1

Process Memory Address Binding Program instructions and data must be bound to memory addresses before it can be executed, this can happen at three different stages Compile time: If memory location known a priori, 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) Memory Management The simplest approach for managing memory is to execute a process and give it all the memory Every now and then the process can be saved to the disk and another process can be loaded from the disk and be given all the memory Just like we want to share the CPU to get better utilization, we also want to share memory to get better utilization A process might not need all the memory, so it would be a waste to give it all the memory 2

Multiprogramming and CPU Utilization CPU utilization is a function of number of processes in memory CPU utilization = 1 - p n where p is percentage of time a process is waiting for I/O and n is the number of processes in memory (this is a simplistic equation) It is common for processes to exhibit 80% I/O wait time or more Degree of multiprogramming Multiprogramming and CPU Utilization Arrival and work requirements of 4 jobs CPU utilization for 1 4 jobs with 80% I/O wait Sequence of events as jobs arrive and finish Numbers show amount of CPU time jobs get in each interval 3

Swapping In a multiprogrammed OS, not all processes can be in main memory at the same time A process can be swapped temporarily out of memory to a backing store and then brought back into memory for continued execution Backing store is a fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped. Contiguous Memory Management Another simple approach to multiprogramming is to divide memory into a fixed number of partitions Partitions may be of equal or different sizes Processes wait on an input queue for a particular memory partition Processes execute for some period of time and then are swapped out to give another process a chance to run (if no more partitions are available) 4

Contiguous Memory Management Fixed memory partitions can be implemented with Separate input queues for each partition Single input queue Contiguous Memory Management Given a memory partition scheme, it is clear that we cannot be sure where program will be loaded in memory Address locations of variables, code routines cannot be absolute Must keep a program out of other processes partitions Must use base and limit values Address locations added to base value to map to physical address Address locations larger than limit value is an error 5

Logical and Physical Addresses The concept of a logical address space that is bound to a separate physical address space is central to memory management Logical address are generated by the CPU; also referred to as virtual address Physical address is generated by the memory unit Logical and physical addresses are the same in compile-time and load-time address-binding schemes Logical and physical addresses differ in executiontime address-binding scheme Memory Management Unit (MMU) Hardware device that maps virtual to physical address In MMU scheme, every address generated by a user process is manipulated by the MMU to calculate the physical address at the time it is sent to memory For example, add base register and check address against limit register The user programs deal with virtual addresses only; they never see the physical addresses 6

Contiguous Memory Management A more complex memory management approach is a variable partitioned approach A hole is a 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 Allocated partitions Free partitions (i.e., holes) Contiguous Memory Management As processes arrive, they are loaded into a hole that is big enough to accommodate them and the excess space is cut off to create the remaining hole OS OS OS OS process 5 process 5 process 5 process 5 process 9 process 9 process 8 process 10 process 2 process 2 process 2 process 2 7

Memory Partition Allocation Algorithm How to satisfy request of size n from a list of 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, unless ordered by size Produces the largest leftover hole First-fit and best-fit better than worst-fit in terms storage utilization Memory Fragmentation External fragmentation When allocating a hole, the remaining free space is cut off creating a small/smaller hole Over time there will be many non-contiguous holes all over the memory space It may not be possible to satisfy a request for memory even if the memory is available because it is not contiguous Internal fragmentation Creating arbitrarily small holes in memory (i.e., a couple bytes) is inefficient, so we might choose a minimum partition size In such a scenario, allocated memory may be slightly larger than requested memory This internal size difference is then wasted memory 8

Memory Fragmentation 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 OS buffers Noncontiguous Memory Management For N memory blocks, the loss of 0.5N blocks is possible due to external fragmentation 50-percent rule This means that one-third of memory is not usable Compaction is too costly to perform regularly External fragmentation arises because we are trying to allocate memory contiguously We can deal with external fragmentation if we can allow process memory to be noncontiguous 9

Paging Paging permits physical address space of a process to be noncontiguous Divide physical memory into fixed-sized blocks Called frames (size is power of 2, between 512 bytes and 8192 bytes) Divide logical memory into fixed-sized blocks Called pages (same size as frames) Keep track of all free frames To run a program of size n pages, need to find n free frames and load program Use a page table per process for translating logical to physical addresses Use a frame table to keep track of physical memory usage Paging Address Translation Scheme Address generated by CPU is divided into Page number (p) is an index into page table which contains base address of each frame in physical memory Page offset (d) is combined with base address to define the physical memory address that is sent to the memory By using a page size that is a power of two, translating a logical address to a page number and offset is easy Assume size of logical address space is 2 m and page size is 2 n Then the low n bits of a logical address are the page offset and the high m - n bits are the page number p page number (m - n bits) d page offset (n bits) 10

Paging Address Translation Scheme logical address physical address CPU p d f d physical memory f page table Paging Example Example for 32-byte memory with 4-byte pages: 32 bytes = 2 5, m = 5, therefore we have a 5 bit logical address 4 bytes = 2 2, n = 2, the lower 2 bits are the offset address / value 0 a b c d 4 e f g h 8 i j k l 12 m n o p logical memory page / frame 0 1 2 3 5 6 1 2 page table Translate logical address 13 13 = 01101 in binary d = 01 in binary; 1 in decimal p = 011 in binary; 3 in decimal (to get p simply right-shift logical address n times) physical address equals = page frame * page size + offset 2 * 4 + 1 = 9 0 4 8 12 16 20 24 28 physical memory i j k l m n o p a b c d e f g h 11

Internal Fragmentation in Pages Memory cannot be allocated in blocks smaller than the page size This leads to internal fragmentation since the last page frame for a process may not be completely full On average fragmentation is one-half page per process This might suggest to use small page sizes However, there is overhead involved in managing the page table and smaller pages means a bigger page table When writing pages to disk, bigger is better too Typical page size is between 2k to 8k 12