A. Frank - P. Weisberg Operating Systems Simple/Basic Paging.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Page Table Implementation
Paging Hardware With TLB
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
Main Memory CS Memory Management1. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Memory Management (II)
Background A program must be brought into memory and placed within a process for it to be executed. Input queue – collection of processes on the disk that.
Memory Management.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Memory Management Gordon College Stephen Brinton.
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.
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.
1 Tuesday, July 04, 2006 "Programs expand to fill the memory available to hold them." - Modified Parkinson’s Law.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Main Memory.
Chap 8 Memory Management. Background Program must be brought into memory and placed within a process for it to be run Input queue – collection of processes.
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.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 8: Memory Management.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 8 Operating Systems.
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.
CS212: OPERATING SYSTEM Lecture 5: Memory Management Strategies 1 Computer Science Department.
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 ©2013 Operating System Concepts – 9 th Edition Objectives To provide a detailed description of various ways of organizing.
Page Table Implementation. Readings r Silbershatz et al:
Memory Management. Background Memory consists of a large array of words or bytes, each with its own address. The CPU fetches instructions from memory.
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 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.
Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide.
Module 9: Memory Management
Chapter 9: Memory Management
Non Contiguous Memory Allocation
Chapter 8: Main Memory Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 8: Main Memory.
Paging and Segmentation
Chapter 8: Main Memory.
Operating System Concepts
Module 9: Memory Management
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.
So far in memory management…
Chapter 8: Memory Management strategies
Chapter 8: Main Memory.
Presentation transcript:

A. Frank - P. Weisberg Operating Systems Simple/Basic Paging

2 A. Frank - P. Weisberg Real Memory Management Background Memory Management Requirements Fixed/Static Partitioning Variable/Dynamic Partitioning Simple/Basic Paging Simple/Basic Segmentation Segmentation with Paging

3 A. Frank - P. Weisberg Simple/Basic Paging (1) Idea: Physical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is available: –Avoids external fragmentation. –Avoids problem of varying sized memory chunks. Divide physical memory into fixed-sized chunks/blocks called frames (size is power of 2, usually between 512 bytes and 16 MB). Divide logical memory into blocks of same size pages.

4 A. Frank - P. Weisberg Simple/Basic Paging (2) The process pages can thus be assigned to any free frames in main memory; a process does not need to occupy a contiguous portion of physical memory. Need to keep track of all free frames. To run a program of size n pages, need to find n free frames and load program. Need to set up a page table to translate logical to physical pages/addresses. Internal fragmentation possible only for page at end of program.

5 A. Frank - P. Weisberg Paging Example

6 A. Frank - P. Weisberg Simple/Basic Paging (3) To run a program of size n 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.

7 A. Frank - P. Weisberg Free-Frame list example Before allocation After allocation

8 A. Frank - P. Weisberg Example of processes loading

9 A. Frank - P. Weisberg 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.

10 Calculating Internal Fragmentation Page size = 2,048 bytes Process size = 72,766 bytes 35 pages + 1,086 bytes Internal fragmentation of 2, ,086 = 962 bytes Worst case fragmentation = 1 frame – 1 byte On average fragmentation = 1 / 2 frame size So small frame sizes desirable? But each page table entry takes memory to track. Page sizes growing over time: –Solaris supports two page sizes – 8 KB and 4 MB.

11 A. Frank - P. Weisberg 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.

12 A. Frank - P. Weisberg 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).

13 A. Frank - P. Weisberg Logical-to-Physical Address Translation in Paging

14 A. Frank - P. Weisberg 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. –Page offset/displacement (d) – combined with base address to define the physical memory address that is sent to the memory unit. For given logical address space 2 m and page size 2 n. page number page offset p d m – n n

15 A. Frank - P. Weisberg 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.

16 A. Frank - P. Weisberg Address Translation Architecture

17 A. Frank - P. Weisberg Paging Example

18 A. Frank - P. Weisberg How to implement Page Table? (1) 1.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. 2.Keep Page Table in hardware (in MMU) – However, page table can be large – too expensive.

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

20 A. Frank - P. Weisberg Paging Hardware With TLB

21 A. Frank - P. Weisberg TLB Flow Chart

22 A. Frank - P. Weisberg 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.

23 A. Frank - P. Weisberg Effective Access Time (EAT) Effective Access Time (EAT) is between 1 and 2 access times – should be closer to 1. Assume memory cycle time is 1 microsecond. Associative (Memory) Lookup =  time unit. Hit ratio =  – percentage of times that a page number is found in the associative memory; ratio related to number of associative registers. EAT =  (  + 1) + (1 –  )(  + 2) = 2 +  – 

24 A. Frank - P. Weisberg EAT Examples Assume memory cycle time is 100 nanosecond. Associative memory lookup = 20 nanosecond. Hit ratio = 80% –EAT = 0.80 x x 220 = 140 ns –So 40% slowdown in memory access time. Hit ratio = 98% –EAT = 0.98 x x 220 = 122 ns –So only 22% slowdown in memory access time.

25 Advanced TLB Aspects Some TLBs store address-space identifiers (ASIDs) in each TLB entry – uniquely identifies each process to provide address-space protection for that process: –Otherwise need to flush at every context switch. TLBs typically small (64 to 1,024 entries). On a TLB miss, value is loaded into the TLB for faster access next time: –Replacement policies must be considered. –Some entries can be wired down for permanent fast access.

26 A. Frank - P. Weisberg Memory Protection Memory protection implemented by associating protection bit with each frame to indicate if read-only or read-write access is allowed: –Can also add more bits to indicate page execute-only, and so on. 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.

27 A. Frank - P. Weisberg Valid (v) or Invalid (i) Bit in a Page Table

28 A. Frank - P. Weisberg Transfer of a Paged Memory to Contiguous Disk Space

29 A. Frank - P. Weisberg Shared Pages Shared code: –One copy of read-only (reentrant) code shared among processes (i.e., text editors, compilers, window systems). –Shared code must appear in same location in the logical address space of all processes. Private code and data: –Each process keeps separate copy of code and data. –The pages for the private code and data can appear anywhere in the logical address space.

30 A. Frank - P. Weisberg Shared Pages Example