Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Memory Management (II)
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
1 Friday, June 30, 2006 "Man's mind, once stretched by a new idea, never regains its original dimensions." - Oliver Wendell Holmes, Jr.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 7: Main Memory CS 170, Fall Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
A. Frank - P. Weisberg Operating Systems Simple/Basic Paging.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Operating Systems Chapter 8
Chapter 8 Memory Management Dr. Yingwu Zhu. Outline Background Basic Concepts Memory Allocation.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 34 Paging Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-8 Memory Management (2) Department of Computer Science and Software.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Implementation of Page Table Page table is kept in main memory Page-table base.
CE Operating Systems Lecture 14 Memory management.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
9.1 Operating System Concepts Paging Example. 9.2 Operating System Concepts.
Paging Paging is a memory-management scheme that permits the physical-address space of a process to be noncontiguous. Paging avoids the considerable problem.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Silberschatz, Galvin and Gagne  Operating System Concepts Paging Logical address space of a process can be noncontiguous; process is allocated.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
W4118 Operating Systems Instructor: Junfeng Yang.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 33 Paging Read Ch. 9.4.
Main Memory: Paging and Segmentation CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition, Chapter 8: Memory- Management Strategies.
COMP 3500 Introduction to Operating Systems Paging: Basic Method Dr. Xiao Qin Auburn University Slides.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 8: Memory-Management Strategies.
Module 9: Memory Management
Chapter 9: Memory Management
Non Contiguous Memory Allocation
Chapter 8: Memory Management
Chapter 8: Main Memory Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 8: Main Memory.
Chapter 8: Memory Management
Paging and Segmentation
Chapter 8: Main Memory.
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Storage Management Chapter 9: Memory Management
Operating System Concepts
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Module 9: Memory Management
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Main Memory Session -15.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Management-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
So far in memory management…
Contents Memory types & memory hierarchy Virtual memory (VM)
Chapter 8: Memory Management strategies
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Chapter 8: Main Memory.
Virtual Memory.
Page Main Memory.
Presentation transcript:

Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide physical memory into fixed-sized chunks/blocks called frames (size is power of 2, usually between 512 bytes and 8192 bytes). Divide logical memory into blocks of same size called pages.

Basic Paging (2) The process pages can thus be assigned to any available frames in main memory; a process does not need to occupy a contiguous portion of physical memory. Need to set up a page table to translate logical to physical pages/addresses. Internal fragmentation possible (for page at end of program).

Paging Example

Basic Paging (3) To run a program of size n (s/p) pages, need to find any n free frames and load all the program (pages). So need to keep track of all free frames in physical memory – use free-frame list. Free-frame list example in next slide.

Free-Frame list example Before allocation After allocation

Example of processes loading (1) Now suppose that process B is swapped out.

Example of processes loading (2) When process A and C are blocked, the pager loads a new process D of 5 pages. Process D does not occupy a contiguous portion of memory. There is no external fragmentation. Internal fragmentation can happen only in the last page of each process.

Example of processes loading (3) The OS now needs to maintain (in main memory) a page table for each process. Each entry of a page table consists of the frame number where the corresponding page is physically located. The corresponding page table is indexed by the page number to obtain the frame number. A free frame table/list, of available pages, is maintained.

Logical address in paging The logical address becomes a relative address when the page size is a power of 2. Example: if 16 bits addresses are used and page size = 1K, we need 10 bits for offset and have 6 bits available for page number. Then the 16 bit address, obtained with the 10 least significant bits as offset and 6 most significant bits as page number, is a location relative to the beginning of the process.

Logical-to-Physical Address Translation in Paging

Logical address used in paging Within each program, each logical address must consist of a page number and an offset within the page. A dedicated register always holds the starting physical address of the page table of the currently running process. Presented with the logical address (page number, offset) the processor accesses the page table to obtain the physical address (frame number, offset).

Address Translation Scheme (1) Logical address generated by CPU is divided into two parts: Page number (p) – used as an index into a page table which contains the base address of each page in physical memory (i.e. start address of the frame). Page offset/displacement (d) – combined with base address to define the physical memory address that is sent to the memory unit.

Address Translation Scheme (2) By using a page size of a power of 2, the pages are invisible to the programmer, compiler/assembler, and the linker. Address translation at run-time is then easy to implement in hardware: logical address (p, d) gets translated to physical address (f, d) by indexing the page table with p and appending the same displacement/offset d to the frame number f.

Address Translation Architecture

Paging Example Frame number 1 2 3 4 5 6 7

How to implement Page Table? Keep Page Table in main memory: Page-table base register (PTBR) points to the page table. Page-table length register (PTLR) indicates size of the page table. However, in this scheme, every data/instruction access requires two memory accesses - one for the page table and one for the data/instruction. Keep Page Table in hardware (in MMU) - However, page table can be large - too expensive.

How to implement Page Table? The two memory accesses problem can be solved by combining mechanisms 1 & 2: Use a special fast-lookup hardware cache called Associative Memory or Translation Look-aside Buffer (TLB) - enables fast parallel search: Page # Frame # If page # is in associative register, get frame # out. Otherwise get frame # from page table in memory.

Paging Hardware With TLB

Why TLB works TLB takes advantage of the Locality Principle. TLB uses associative mapping hardware to simultaneously interrogate all TLB entries to find a match/hit on page number. TLB hit rates are 90+%. The TLB must be flushed each time a new process enters the running state. Maybe keep/load TLB information in/from process context.

Memory Protection Memory protection implemented by associating a protection bit with each frame. Valid-invalid bit attached to each entry in the page table: “valid” indicates that the associated page is in the process’ logical address space, and is thus a legal page. “invalid” indicates that the page is not in the process’ logical address space.

Valid (v) or Invalid (i) Bit in a Page Table

Shared Pages If we share the same code (i.e., text editors, compilers, window systems) among different users, it is sufficient to keep only one copy in main memory. Shared code must be reentrant (i.e., non self-modifying) so that 2 or more processes can execute the same code. If we use paging, each sharing process will have a page table who’s entry points to the same frames: only one copy is in main memory. But each user needs to have its own private data pages.

Shared Pages Example