Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings

Similar documents
Memory Management. Memory Management

Memory Management. Memory Management Requirements

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

Chapter 7 Memory Management

Chapter 8 Virtual Memory

Chapter 8 Virtual Memory

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Chapter 8 Virtual Memory

ECE519 Advanced Operating Systems

Lecture 7. Memory Management

a process may be swapped in and out of main memory such that it occupies different regions

General Objective:To understand the basic memory management of operating system. Specific Objectives: At the end of the unit you should be able to:

Memory Management Virtual Memory

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University

Process size is independent of the main memory present in the system.

Virtual Memory. Chapter 8

Requirements, Partitioning, paging, and segmentation

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Virtual Memory. control structures and hardware support

3. Memory Management

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency

Requirements, Partitioning, paging, and segmentation

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

CSCI 4717 Computer Architecture. Memory Management. What is Swapping? Swapping. Partitioning. Fixed-Sized Partitions (continued)

UNIT III MEMORY MANAGEMENT

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

Operating System Support

Chapter 8. Operating System Support. Yonsei University

Paging, and segmentation

Memory Management. Memory Management

Operating Systems Lecture 6: Memory Management II

Chapter 8 Memory Management

CIS Operating Systems Contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

Chapters 9 & 10: Memory Management and Virtual Memory

Chapter 9 Real Memory Organization and Management

Chapter 9 Real Memory Organization and Management

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Process. One or more threads of execution Resources required for execution

Chapter 3 - Memory Management

Process. Memory Management

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Operating Systems. Operating Systems Sina Meraji U of T

Last Class: Deadlocks. Where we are in the course

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

Chapter 9 Memory Management


Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Preview. Memory Management

The Virtual Memory Abstraction. Memory Management. Address spaces: Physical and Virtual. Address Translation

Memory Management. Jo, Heeseung

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

MEMORY MANAGEMENT. Jo, Heeseung

Memory Management Virtual Memory

Chapter 3 Memory Management: Virtual Memory

Operating Systems 2230

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

CIS Operating Systems Memory Management. Professor Qiang Zeng Fall 2017

First-In-First-Out (FIFO) Algorithm

CS399 New Beginnings. Jonathan Walpole

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

MEMORY MANAGEMENT: Real Storage. Unit IV

UNIT-III VIRTUAL MEMORY

Chapters 7-8. Memory Management. Chapter 7 - Physical Memory. 7.1 Preparing a Program for Execution

Memory Management. Dr. Yingwu Zhu

Operating System 1 (ECS-501)

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Readings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.

Compile: compiler. Load: loader. compiler linker loader memory. source object load code module module 2

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

Fall COMP3511 Review

Part II: Memory Management. Chapter 7: Physical Memory Chapter 8: Virtual Memory Chapter 9: Sharing Data and Code in Main Memory

Role of OS in virtual memory management

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

CS370 Operating Systems

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Chapter 8: Main Memory

Memory management OS

Operating Systems and Computer Networks. Memory Management. Dr.-Ing. Pascal A. Klein

Chapter 9: Virtual Memory

Chapter 4 Memory Management

Chapter 8: Main Memory

Memory Management: Virtual Memory and Paging CS 111. Operating Systems Peter Reiher

Operating Systems Design Exam 2 Review: Spring 2012

In multiprogramming systems, processes share a common store. Processes need space for:

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Memory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Transcription:

Operating Systems: Internals and Design Principles Chapter 7 Memory Management Seventh Edition William Stallings

Memory Management Requirements Memory management is intended to satisfy the following requirements: Relocation Protection Sharing Logical organization Physical organization

Physical Organization Cannot leave the programmer with the responsibility to manage memory Memory available for a program plus its data may be insufficient overlaying allows various modules to be assigned the same region of memory but is time consuming to program Programmer does not know how much space will be available

Fixed Portioning Equal-size partitions Any process whose size is less than or equal to the partition size can be loaded into an available partition If all partitions are full, the operating system can swap a process out of a partition A program may not fit in a partition. The programmer must design the program with overlays Fixed partitioning in main memory is inefficient. Any program, no matter how small, occupies an entire partition. What about the memory left over if the program does not fit perfectly. This is called internal fragmentation.

Fixed Portioning Solution to Equal-size partitions? Assign each process to the smallest partition within which it will fit Queue for each partition Processes are assigned in such a way as to minimize wasted memory within a partition Unequal size portioning. Less Internal fragmentation.

The number of partitions specified at system generation time limits the number of active processes in the system Small jobs will not utilize partition space efficiently

Dynamic Portioning Partitions are of variable length and number Process is allocated exactly as much memory as required Eventually get holes in the memory. This is called external fragmentation Must use compaction To shift processes so they are contiguous and all free memory is in one block

Placement Algorithms Best-fit First-fit chooses the block that is closest in size to the request begins to scan memory from the beginning and chooses the first available block that is large enough Next-fit begins to scan memory from the location of the last placement and chooses the next available block that is large enough

Addresses Logical reference to a memory location independent of the current assignment of data to memory Relative address is expressed as a location relative to some known point Physical or Absolute actual location in main memory

Relocation

Paging

Paging Paging Main memory and process both are divided into fixed size small chunks, the chunk of process is known as page and chunk of memory is known as frames. Each process has its own page table A bit is needed to indicate whether the page is in main memory or not Page table entry contains frame# of the corresponding page in memory.

Paging

Paging

Segmentation A program can be subdivided into segments may vary in length there is a maximum length Addressing consists of two parts: segment number an offset Similar to dynamic partitioning Eliminates internal fragmentation Paging is invisible to programmer while segmentation is usually visible.

Logical view of segmentation

Segmentation Logical to physical address mapping

Summary Memory Management one of the most important and complex tasks of an operating system needs to be treated as a resource to be allocated to and shared among a number of active processes desirable to maintain as many processes in main memory as possible desirable to free programmers from size restriction in program development basic tools are paging and segmentation (possible to combine)» paging small fixed-sized pages» segmentation pieces of varying size

Memory Management Real memory main memory, the actual RAM Virtual memory memory on disk allows for effective multiprogramming and relieves the user of tight constraints of main memory

Thrashing A state in which the system spends most of its time swapping process pieces rather than executing instructions To avoid this, the operating system tries to guess, based on recent history, which pieces are least likely to be used in the near future

Principle of Locality Program and data references within a process tend to cluster Only a few pieces of a process will be needed over a short period of time Therefore it is possible to make intelligent guesses about which pieces will be needed in the future Avoids thrashing

Paging The term virtual memory is usually associated with systems that employ paging Use of paging to achieve virtual memory was first reported for the Atlas computer Each process has its own page table each page table entry contains the frame number of the corresponding page in main memory

Memory Management

Paging System

Two Level Paging

Two Level Paging Example A logical address (32bit machine, 4K page size) is divided into a page number consisting of 20 bits, a page offset consisting of 12 bits Since the page table is paged, the page number consists of a 10-bit page number, a 10-bit page offset Thus, a logical address is organized as (p1,p2,d) where p1 is an index into the outer page table p2 is the displacement within the page of the outer page table

Paging System with Inverted Page Table

TLB

TLB

Page Size The design issue of page size is related to the size of physical main memory and program size Contemporary programming techniques (OO & multi-threading) used in large programs tend to decrease the locality of references within a process main memory is getting larger and address space used by applications is also growing most obvious on personal computers where applications are becoming increasingly complex

Basic Algorithms Algorithms used for the selection of a page to replace: 1. Optimal Replace the page that won t be needed for the longest time in the future 2. Least recently used (LRU Replace the page that hasn t been referenced for the longest time 3. First-in-first-out (FIFO) 4. Clock Clock hand sweeps over pages looking for one with used bit = 0 Replace pages that haven t been referenced for one complete revolution of the clock

Replacement policies

Replacement policies

Replacement policies

Clock Policy

Summary Desirable to: maintain as many processes in main memory as possible free programmers from size restrictions in program development With virtual memory: all address references are logical references that are translated at run time to real addresses a process can be broken up into pieces two approaches are paging and segmentation management scheme requires both hardware and software support