Paging (continued) & Caching CS-3013 A-term 20081 Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

Paging 1 CS502 Spring 2006 Paging CS-502 Operating Systems.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
CS 153 Design of Operating Systems Spring 2015
PagingCS-3013 A-term Paging CS-3013, Operating Systems A-term 2009 (Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew Tanenbaum.
Memory Management (II)
Memory Management.
Memory Management 2010.
Memory Organization.
CS-3013 & CS-502 Summer 2006 Paging1 CS-3013 & CS-502 Summer 2006.
Memory Management (continued) CS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
PagingCS-3013 C-term Paging CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz,
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Memory Management CSE451 Andrew Whitaker. Big Picture Up till now, we’ve focused on how multiple programs share the CPU Now: how do multiple programs.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
Review of Memory Management, Virtual Memory CS448.
Operating Systems Chapter 8
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
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.
PagingCS-502 Fall Paging CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz, Galvin,
1 Virtual Memory and Address Translation. 2 Review Program addresses are virtual addresses.  Relative offset of program regions can not change during.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Chapter 4 Memory Management Virtual Memory.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Caching Principles & Paging Performance CS-502 (EMC) Fall Caching Principles and Paging Performance CS-502, Operating Systems Fall 2009 (EMC) (Slides.
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
Processes and Virtual Memory
PagingCS-502 (EMC) Fall Paging CS-502, Operating Systems Fall 2009 (EMC) (Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
Silberschatz, Galvin and Gagne  Operating System Concepts Paging Logical address space of a process can be noncontiguous; process is allocated.
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.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Virtual Memory So, how is this possible?
Non Contiguous Memory Allocation
CE 454 Computer Architecture
CS161 – Design and Architecture of Computer
CSE 120 Principles of Operating
CS703 - Advanced Operating Systems
Memory Management and Virtual Memory
Chapter 8: Main Memory.
CSCI206 - Computer Organization & Programming
O.S Lecture 13 Virtual Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Caching Principles and Paging Performance
CSE 451: Operating Systems Autumn 2005 Memory Management
CS-3013 Operating Systems Hugh C. Lauer
Caching Principles and Paging Performance
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE451 Virtual Memory Paging Autumn 2002
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.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Paging and Segmentation
CS703 - Advanced Operating Systems
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
CS-3013 Operating Systems A-term 2008
Presentation transcript:

Paging (continued) & Caching CS-3013 A-term Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew Tanenbaum and from Operating System Concepts, 7 th ed., by Silbershatz, Galvin, & Gagne)

Paging (continued) & Caching CS-3013 A-term Review – Paging Partition virtual memory into small fixed size units called pages Typically bytes Translate every memory address on-the-fly from virtual to physical address Allow process to execute, even if not all pages are in physical memory

Paging (continued) & Caching CS-3013 A-term Definition — Page Fault Trap when process attempts to reference a location in virtual memory whose virtual address cannot be translated I.e., valid bit in PTE set to false I.e., reference violates protection bits in PTE OS takes appropriate action, restarts process at point of fault

Paging (continued) & Caching CS-3013 A-term PTE Structure Valid bit gives state of this PTE –says whether or not a virtual address is valid – in memory and VA range –If not set, page might not be in memory or may not even exist! Reference bit says whether the page has been accessed –it is set by hardware whenever a page has been read or written to Modify bit says whether or not the page is dirty –it is set by hardware during every write to the page Protection bits control which operations are allowed –read, write, execute, etc. Page frame number (PFN) determines the physical page –physical page start address Other bits dependent upon machine architecture page frame numberprotMRV

Paging (continued) & Caching CS-3013 A-term Paging – Advantages Easy to allocate physical memory pick any free frame No external fragmentation All frames are equal Minimal internal fragmentation Bounded by page/frame size Easy to swap out pages (called pageout) Size is usually a multiple of disk blocks PTEs may contain info that help reduce disk traffic Processes can run with not all pages swapped in

Paging (continued) & Caching CS-3013 A-term Definitions & Recurring Themes Temporal Locality – locations referenced recently tend to be referenced again soon Spatial Locality – locations near recent references tend to be referenced soon Working set – the set of pages that a process needs to run without frequent page faults Thrashing – excessive page faulting due to insufficient frames to support working set

Paging (continued) & Caching CS-3013 A-term Paging Issues #1 — Page Tables can consume large amounts of space –If PTE is 4 bytes, and use 4KB pages, and have 32 bit VA space  4MB for each process’s page table Stored in main memory! –What happens for 64-bit logical address spaces? #2 — Performance Impact –Converting virtual to physical address requires multiple operations to access memory Read Page Table Entry from memory! Get page frame number Construct physical address Assorted protection and valid checks –Without fast hardware support, requires multiple memory accesses and a lot of work per logical address

Paging (continued) & Caching CS-3013 A-term Paging Issues #1 — Page Tables can consume large amounts of space –If PTE is 4 bytes, and use 4KB pages, and have 32 bit VA space  4MB for each process’s page table Stored in main memory! –What happens for 64-bit logical address spaces? #2 — Performance Impact –Converting virtual to physical address requires multiple operations to access memory Read Page Table Entry from memory! Get page frame number Construct physical address Assorted protection and valid checks –Without fast hardware support, requires multiple memory accesses and a lot of work per logical address Two-level or inverted page tables Translation Lookaside Buffer (TLB)

Paging (continued) & Caching CS-3013 A-term Paging Tricks Shared Virtual Memory Pages of two or more processes point to same page frames E.g. shared libraries Copy-on-write Processes share virtual memory Writable pages marked read-only On page fault, make separate writable copies

Paging (continued) & Caching CS-3013 A-term Definition — Backing Storage A place on external storage medium where copies of virtual pages are kept Usually a hard disk (locally or on a server) Place from which contents of pages are read after page faults Place where contents of pages are written if page frames need to be re-allocated

Paging (continued) & Caching CS-3013 A-term Backing Storage Executable code and constants:– The loadable image file produced by compiler Working memory (stack, heap, static data) Special swapping file (or partition) on disk Persistent application data Application data files on local or server disks

Paging (continued) & Caching CS-3013 A-term Definition — Mapping Mapping (a part of) virtual memory to a file = Connecting blocks of the file to the virtual memory pages so that –Page faults in (that part of) virtual memory resolve to the blocks of the file –Dirty pages in (that part of) virtual memory are written back to the blocks of the file

Paging (continued) & Caching CS-3013 A-term Warning — Memory-mapped Files Tempting idea:– –Instead of standard I/O calls ( read(), write(), etc.) map file starting at virtual address X –Access to “X + n” refers to file at offset n –Use paging mechanism to read file blocks into physical memory on demand … –… and write them out as needed Has been tried many times Rarely works very well in practice

Paging (continued) & Caching CS-3013 A-term Warning — Memory-mapped Files Tempting idea:– –Instead of standard I/O calls ( read(), write(), etc.) map file starting at virtual address X –Access to “X + n” refers to file at offset n –Use paging mechanism to read file blocks into physical memory on demand … –… and write them out as needed Has been tried many times Rarely works well in practice Hard to program; even Harder to manage performance

Paging (continued) & Caching CS-3013 A-term Virtual Memory Organization 0x xFFFFFFFF Virtual address space program code (text) static data heap (dynamically allocated) stack (dynamically allocated) PC SP From an earlier topic

Paging (continued) & Caching CS-3013 A-term Virtual Memory Organization program code & constants static data heap (dynamically allocated) stack (dynamically allocated) PC SP Mapped to read-only executable file Map to writable swap file Unmapped, may be dynamically mapped guard page (never mapped)

Paging (continued) & Caching CS-3013 A-term thread 3 stack Virtual Memory Organization (continued) program code & constants static data heap thread 1 stack PC (T2) SP (T2) thread 2 stack SP (T1) SP (T3) PC (T3) guard page (never mapped) guard page Mapped to read-only executable file Map to writable swap file Unmapped, may be dynamically mapped Map to writable swap file

Paging (continued) & Caching CS-3013 A-term Virtual Memory Organization (continued) Each area of process VM is its own segment (or sequence of segments) Executable code & constants – fixed size Shared libraries Static data – fixed size Heap – open-ended Stacks – each open-ended Other segments as needed –E.g., symbol tables, loader information, etc.

Paging (continued) & Caching CS-3013 A-term Virtual Memory – a Major OS Abstraction Processes execute in virtual memory, not physical memory Virtual memory may be very large Much larger than physical memory Virtual memory may be organized in interesting & useful ways Open-ended segments Virtual memory is where the action is! Physical memory is just a cache of virtual memory

Paging (continued) & Caching CS-3013 A-term Reading Assignment Tanenbaum –§§ (previous topic – Memory Management) –§ 3.3 (this topic on Paging)

Paging (continued) & Caching CS-3013 A-term Related topic – Caching

Paging (continued) & Caching CS-3013 A-term Definition — Cache A small subset of active items held in fast storage while most of the items are in much larger, slower storage –Virtual Memory Very large, mostly stored on (slow) disk Small working set in (fast) RAM during execution –Page tables Very large, mostly stored in (slow) RAM Small working set stored in (fast) TLB registers

Paging (continued) & Caching CS-3013 A-term Caching is Ubiquitous in Computing Transaction processing Keep records of today’s departures in RAM while records of future flights are on disk Program execution Keep the bytes near the current program counter in on-chip memory while rest of program is in RAM File management Keep disk maps of open files in RAM while retaining maps of all files on disk Game design Keep nearby environment in cache of each character …

Paging (continued) & Caching CS-3013 A-term Caching issues When to put something in the cache What to throw out to create cache space for new items How to keep cached item and stored item in sync after one or the other is updated How to keep multiple caches in sync across processors or machines Size of cache needed to be effective Size of cache items for efficiency …

Paging (continued) & Caching CS-3013 A-term Caching issues When to put something in the cache What to throw out to create cache space for new items How to keep cached item and stored item in sync after one or the other is updated How to keep multiple caches in sync across processors or machines Size of cache needed to be effective Size of cache items for efficiency … This is a very important list!

Paging (continued) & Caching CS-3013 A-term Questions?