Paging.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

CS 311 – Lecture 21 Outline Memory management in UNIX
Day 20 Memory Management. Assumptions A process need not be stored as one contiguous block. The entire process must reside in main memory.
CS 153 Design of Operating Systems Spring 2015
Memory Management Design & Implementation Segmentation Chapter 4.
Chapter 3.2 : Virtual Memory
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Virtual Memory:Part 2 Kashyap Sheth Kishore Putta Bijal Shah Kshama Desai.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
Paging. Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Review of Memory Management, Virtual Memory CS448.
Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.
Operating Systems Chapter 8
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
CE Operating Systems Lecture 14 Memory management.
Chapter 4 Memory Management Virtual Memory.
Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area.
LINUX 15 : Memory Management
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Introduction to Paging. Readings r 4.3 of the text book.
Memory Management Virtual Memory.
Chapter 2: The Linux System Part 4
Non Contiguous Memory Allocation
Virtual Memory CSSE 332 Operating Systems
CSE 120 Principles of Operating
Memory Caches & TLB Virtual Memory
Lecture Topics: 11/19 Paging Page tables Memory protection, validation
Chapter 9: Virtual Memory
COMBINED PAGING AND SEGMENTATION
Page Table Implementation
Chien-Chung Shen CIS/UD
CS510 Operating System Foundations
Operating System Concepts
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Evolution in Memory Management Techniques
Paging Lecture November 2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Computer Architecture
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
So far… Text RO …. printf() RW link printf Linking, loading
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 32 Syed Mansoor Sarwar
Overview: File system implementation (cont)
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
2P13 Week 7.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Segmentation Observation: Programmers don’t think in pages!
CS703 - Advanced Operating Systems
Translation Buffers (TLBs)
COMP755 Advanced Operating Systems
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

Paging

Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth of partition is troublesome No winning policy on allocation/deallocation P2 P3

The Basic Problem A process needs a contiguous partition(s) But Contiguity is difficult to manage Contiguity mandates the use of physical memory addressing (so far)

The Basic Solution Give illusion of a contiguous address space The actual allocation need not be contiguous Use a Memory Management Unit (MMU) to translate from the illusion to reality

A solution: Virtual Addresses Use n-bit to represent virtual or logical addresses A process perceives an address space extending from address 0 to 2n-1 MMU translates from virtual addresses to real ones Processes no longer see real or physical addresses

Paged Memory Subdivide the address space (both virtual and physical) to “pages” of equal size Use MMU to map from virtual pages to physical ones Physical pages are called frames

Paging: Example Virtual Physical Virtual Process 1 Process 0

Key Facts Virtual address spaces of different processes are independent Two or more may have the same address range Yet the mappings differentiate between them A virtual page has no storage of its own It must be backed by a physical frame (real page) that provides the actual storage A contiguous virtual space need not be physically contiguous

Key Facts Physical address space is independent of virtual address spaces They can have different sizes Allows process size to be independent of available physical memory size Page size is always a power of 2, to simplify hardware addressing

Page Tables Virtual Page Table

Page Table Structure Indexed by virtual page number Contains frame number (if any) Contains protection bits Contains reference bit Frame No. v w r x f m Frame No. v w r x f m Frame No. v w r x f m v: valid bit w: write bit r: read bit x: execute bit (rare) f: reference bit m: modified bit

Mapping Virtual to Real Addresses n bits Virtual address virtual page number offset s bits index into page table s bits frame no. offset p bits s: log (page size) Physical address

Example: PDP-11 Page size: 8K Up to 4M mem 16 bits Virtual address vpn offset 13 bits 13 bits frame no. offset 8-entry page table 22 bits Physical address (in hardware)

Weird Stuff: Free Page Management Virtual Physical Virtual Process 0 Process 1 Key fact: A memory frame cannot be accessed unless mapped Free space

Fun Stuff: Sharing Virtual Physical Virtual Process 1 Process 0

Sharing Processes can share pages by mapping their virtual pages to the same memory frame In UNIX and Windows, code segments of processes running the same program to share the pages containing executables saves a lot of memory saves loading time for frequently run programs Fine tuning using protection bits (rwx)

Fork Revisited: Copy-on-Write Virtual Physical Virtual W W W W W W Father Child

Copy-on-Write Fork Initially no memory copying Efficient If an exec follows, no much harm Page tables set the protection to disallow writes If either father or child attempts to write, a page fault occurs

Copy-on-Write Virtual Physical Virtual W W W W W W Father Child

Requirements for Sharing Page frames must have a reference count Cannot be deallocated unless unmapped Adds complexity to memory manager Protection bits must be set properly Must externalize protection bits to user programs (mprotect()) Protection bits meaning could be overloaded (bad)