Modeling Page Replacement: Stack Algorithms. Design Issues for Paging Systems

Similar documents
CS450/550 Operating Systems

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

Chapter 4 Memory Management. Memory Management

Chapter 4 Memory Management

Page Size Page Size Design Issues

Operating Systems, Fall Lecture 5, Tiina Niklander 1

Operating Systems, Fall Lecture 5 1. Overhead due to page table and internal fragmentation. Tbl 8.2 [Stal05] 4.

Operating Systems, Fall Lecture 5 1

Motivation. Memory Management. Memory Management. Computer Hardware Review

Week 2: Tiina Niklander

Operating Systems, Fall

Memory management, part 3: outline

Memory management, part 3: outline

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

Operating Systems Lecture 6: Memory Management II

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

Memory management, part 2: outline

Virtual Memory Management

Move back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t

Memory Management Ch. 3

CS510 Operating System Foundations. Jonathan Walpole

Chapter 9: Virtual Memory

MODERN OPERATING SYSTEMS. Chapter 3 Memory Management

Virtual Memory Design and Implementation

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Lecture 12: Demand Paging

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Virtual Memory III. Jo, Heeseung

Perform page replacement. (Fig 8.8 [Stal05])

OPERATING SYSTEM. Chapter 9: Virtual Memory

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Address spaces and memory management

CS 550 Operating Systems Spring Memory Management: Page Replacement

Memory Management. Motivation

Clock page algorithm. Least recently used (LRU) NFU algorithm. Aging (NFU + forgetting) Working set. Process behavior

Design Issues 1 / 36. Local versus Global Allocation. Choosing

Virtual Memory Design and Implementation

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

The Working Set. CS 355 Operating Systems. The Working Set. Working Set Model 3/27/18. Paging Algorithms and Segmentation

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

CS399 New Beginnings. Jonathan Walpole

Memory - Paging. Copyright : University of Illinois CS 241 Staff 1

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

Chapter 9: Virtual-Memory

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Chapters 9 & 10: Memory Management and Virtual Memory

1. Background. 2. Demand Paging

Module 9: Virtual Memory

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

CS 153 Design of Operating Systems Winter 2016

Virtual Memory Outline

Chapter 8. Virtual Memory

CS370 Operating Systems

Segmentation (Apr 5 and 7, 2005)

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

CS370 Operating Systems

12: Memory Management

Paging and Page Replacement Algorithms

Chapter 8: Virtual Memory. Operating System Concepts

Operating System Concepts 9 th Edition

Swapping. Operating Systems I. Swapping. Motivation. Paging Implementation. Demand Paging. Active processes use more physical memory than system has

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Virtual Memory Design and Implementation

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

CS 153 Design of Operating Systems Winter 2016

Module 9: Virtual Memory

Basic Memory Management

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Memory Management Virtual Memory

Operating Systems. IV. Memory Management

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

Chapter 9: Virtual Memory. Operating System Concepts 9th Edition

CSE 4/521 Introduction to Operating Systems. Lecture 15 Virtual Memory I (Background, Demand Paging) Summer 2018

Memory Management and Protection

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

Solution to the. Gaming Parlor. Programming Project

Chapter 6: Demand Paging

Operating System Concepts

Chapter 10: Virtual Memory

The Operating System. Chapter 6

Chapter 8 Main Memory

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) Advantages of Multi-level Page Tables

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

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

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

CS 134: Operating Systems

CSE 120 Principles of Operating Systems Spring 2017

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

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

How to create a process? What does process look like?

Chapter 9: Virtual Memory

CSE 120 Principles of Operating Systems

First-In-First-Out (FIFO) Algorithm

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

Transcription:

Modeling Page Replacement: Stack Algorithms 7 4 6 5 State of memory array, M, after each item in reference string is processed CS450/550 Memory.45 Design Issues for Paging Systems Local page replacement vs. global page replacement How memory be allocated among the competing processes? (a) Original configuration. (b) Local page replacement. (c) Global page replacement. CS450/550 Memory.46

Design Issues for Paging Systems (2) Local page replacement: static allocation What if the working set of some process grows? What if the working set of some process shrinks? The consideration: thrashing and memory utilization Global page replacement: dynamic allocation How many page frames assigned to each process - Keep monitoring the working set size - Allocating an equal share of available page frames - Allocating a proportional share of available page frames - Or hybrid allocation, using PFF (page fault frequency) CS450/550 Memory.47 Page Fault Frequency (PFF) PFF: control the size of allocation set of a process when and how much to increase or decrease a process page frame allocation Replacement: what page frames to be replaced Page fault rate as a function of the number of page frames assigned CS450/550 Memory.48

Load Control Despite good designs, system may still have thrashing When combined working sets of all processes exceed the capacity of memory When PFF algorithm indicates some processes need more memory but no processes need less Solution : swap one or more to disk, divide up pages they held reconsider degree of multiprogramming - CPU-bound and I/O-bound mixing Reduce number of processes competing for memory CS450/550 Memory.49 Page Size (1) Small page size Advantages less unused program in memory (due to internal fragmentation) better fit for various data structures, code sections Disadvantages programs need many pages, larger page tables Long access time of page (compared to transfer time) Also Maybe more paging actions due to page faults CS450/550 Memory.50

Page Size (2) Tradeoff: overhead due to page table and internal fragmentation Where s = average process size in bytes p = page size in bytes e = page entry size in bytes s e overhead = + p page table space p 2 internal fragmentation Optimized/minimized when f (p)=0 p = 2 se CS450/550 Memory.51 Separate Instruction and Data Spaces What if the single virtual address space is not enough for both program and data? Doubles the available virtual address space, and ease page sharing of multiple processes Both addr. spaces can be paged, each has own page table One address space Separate I and D spaces Is it an issue in today s 64-bit machines? CS450/550 Memory.52

Shared Pages How to allow multiple processes share the pages when running the same program at the same time? One process has its own page table(s) Two processes sharing same program sharing its I-page table CS450/550 Memory.53 Shared Pages (2) What to do when a page replacement occurs to a process while other processes are sharing pages with it? How share data pages, compared to share code pages? UNIX fork() and copy-on-write Generating a new page table point to the same set of pages, but not duplicating pages until A violation of read-only causes a trap CS450/550 Memory.54

Cleaning Policy Need for a background process, paging daemon periodically inspects state of memory To ensure plenty of free page frames When too few frames are free selects pages to evict using a replacement algorithm CS450/550 Memory.55 Implementation Issues Four times when OS involved with paging 1. Process creation determine program size create page table 2. Process execution MMU reset for new process TLB flushed (as invalidating the cache) 3. Page fault time determine virtual address causing fault swap target page out, needed page in 4. Process termination time release page table, pages CS450/550 Memory.56

Page Fault Handling 1. Hardware traps to kernel 2. General registers saved 3. OS determines which virtual page needed 4. OS checks validity of address, seeks page frame 5. If selected frame is dirty, write it to disk 6. OS brings schedules new page in from disk 7. Page tables updated 8. Faulting instruction backed up to when it began 9. Faulting process scheduled 10. Registers restored 11. Program continues CS450/550 Memory.57 Instruction Backup The instruction causing the page fault is stopped part way. After OS has fetched the page needed, it must restart the instruction, but where exactly the page fault was due to? The value of the PC at the time of trap depends on which operand faulted and how the CPU s microcode has been implemented, which is hard for OS to tell Hidden internal register copies PC An instruction causing a page fault, say if PC = 1002; how OS knows the content of 1002 is an opcode or an operand? or where the instruction begins? CS450/550 Memory.58

Locking Pages in Memory Virtual memory and I/O occasionally interact Proc issues call for read from device into buffer while waiting for I/O, another processes starts up That process has a page fault If global page replacement, buffer for the first proc may be chosen to be paged out (in particular, partial DMA transfer) Need to specify some pages locked Pinning: lock pages engaged in I/O in memory so that they will not be removed (from being target pages) CS450/550 Memory.59 Backing Store Disk Management How to allocate page space on the disk in support of VM? Static swap area (pages copied): adding the offset of the page in the virtual address space to the start of the swap area Dynamic swapping (page no copied, a table-per-process needed) (a) Paging to static swap area. (b) Backing up pages dynamically CS450/550 Memory.60

Separation of Policy and Mechanism (Self-Reading) Page fault handling with an external pager CS450/550 Memory.61 Segmentation (1) Why to have two or more separate virtual address spaces? How to free a programmer from the issues of expanding and contracting tables? One-dimensional address space with growing tables for compiling, one table may bump/interfere into another CS450/550 Memory.62

Segmentation (2) Segments: many independent virtual address spaces A logical entity, known and used by the programmer Two-dimensional memory: the program must supply a two-part address, a segment number and an address with an segment How about sharing, such as a shared library? Allows each table to grow or shrink, independently CS450/550 Memory.63 Comparison of Segmentation and Paging modularity CS450/550 Memory.64

Implementation of Pure Segmentation An essential difference of paging and segmentation Segments have different sizes while pages are fixed size! (a)-(d) Development of checkerboarding (external fragmentation) in physical memory, if segments are small; (e) Removal of the checkerboarding by compaction CS450/550 Memory.65 What is the key difference of segmentation and swapping? Segmentation with Paging: MULTICS What if the memory is not large enough for a single segment? MULTICS (Honeywell 6000) Paged segment with word (4B) addressing Multi-dim VM up to 2^18 segments, each up to 64K (32-bit) words 34-bit virtual address (seg #, page #, page offset) Physical memory 16M words (24-bit physical address) Page size: 1024 words; or 64 words (64-word alignment) 18-bit segment number for page table address A 34-bit MULTICS virtual address CS450/550 Memory.66

MULTICS Virtual Memory One descriptor segment and 36-bit segment descriptors What if the page table of a segment is not in the memory? How many page tables? Descriptor segment points to page tables. Segment descriptor. CS450/550 Memory.67 MULTICS Virtual Address Physical Address What if the descriptor segment is paged (often it is)? How to speed up the searching &conversion? Conversion of a 2-part MULTICS address into a main memory address CS450/550 Memory.68

MULTICS TLB Simplified version of the MULTICS TLB (LRU replacement), which has 16 most recently referenced pages. CS450/550 Memory.69 Segmentation with Paging: Pentium (Self-Reading) Segmentation in Pentium resembles MULTICS But 16K segments, each up to 1B words CS450/550 Memory.70

Summary Mono-programming -> Multi-programming Swapping Virtual Memory Paging Page replacement algorithms Design and implementation issues Segmentation More reading: Chapter 4.1-4.9 CS450/550 Memory.71