Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University
|
|
- Myles Clark
- 6 years ago
- Views:
Transcription
1 Operating Systems CSE 410, Spring 2004 Virtual Memory Stephen Wagner Michigan State University
2 Virtual Memory Provide User an address space that is larger than main memory Secondary storage is used to augment main memory Transparent to the user A single process may be larger than main memory Allows the OS to support more processes
3 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time. A process may be swapping in and out of memory and does not need to occupy the same region of memory. A process can be broken up into pieces that do not need to be located contiguously in memory. All pieces of a program do not need to be loaded into main memory during execution.
4 Virtual Memory and Paging Each process has its own virtual address space A virtual address consists of a virtual page # and an offset A virtual page can be stored in physical memory or on disk Page table is used to indicate where a virtual page is stored
5 Execution of a Program Operating system brings into memory a few pieces of the process Resident Set: memory portion of the process that is currently in main An interrupt is generated when an address is needed that is not in main memory Operating system places the process in a blocked state
6 Page Faults If a page is not in memory when accessed, it must be read from disk to memory This is a page fault Page faults are very expensive Cache memory access : 1 cycle Main memory access : 10 cycles Disk access : 1,000,000 cycles Usually some other page will need to be evicted from main memory.
7 Page Faults Process is put in a blocked state Operating system issues a disk I/O read request Another process is dispatched to run while the I/O takes place When I/O completes, an interrupt is generated and the process is put back in the ready queue The instruction that cause the page fault needs to be executed again, or completed
8 Advantages of Virtual Memory More processes may be supported Each process only needs some of its pages in memory With more processes available, it is more likely some process will be in the Ready state A process can have an address space larger than main memory A program is not restricted by a particular architecture
9 Types of Memory Real Memory: Physical main memory Virtual Memory: Physical memory plus memory on disk Allows for effective multiprogramming and relieves the user of tight memory constraints
10 Thrashing What happens if there are too many processes in the system? Working Set: the set of pages a process needs to perform some useful work The working set is usually much smaller than the set of all pages in the process The working set can change throughout a process s lifetime If the working sets of all processes do not fit into memory, thrashing will occur The OS will spend most of its time swapping pages in and out
11 Thrashing Thrashing will severely impair system performance Working Set Model: keep track of each process s working set and only let the process run when its working set is in memory Prepaging: load the pages of a process before letting the process run normally you wait until a request is made to the page before loading it in prepaging you load the page before any request is made
12 Principle of Locality Program and data references with a process tend to cluster Only a few pieces of a process will be needed over a relatively long period of time Possible to make intelligent guesses about which pieces will be needed in the future Principle of Locality is what makes virtual memory work efficiently
13 Support Needed for Virtual Memory Hardware must support paging or segmentation Operating system must be able to manage the movement of pages/segments between secondary memory and main memory.
14 Page Tables Each process has its own page table Each page table entry contains the frame number of the corresponding page in main memory A bit is needed to indicate whether the page is in main memory or not If a page is not in main memory, we need to know where on disk it is stored
15 Page Tables and the Modify Bit When a page is swapped out of main memory, we need to save any changes made to the page we have to write the evicted page to disk we have to read in the new page To minimize writes, we only write a page if it has been modified since it was last loaded into main memory Keep track of this information with a Modify Bit If the page has not been changed, we do not have to write it to disk
16 Page Table Entry Virtual Address Page Number Offset Page Table Entry P MOther Control Bits Frame Number (a) Paging only Virtual Address Segment Number P: present bit Segment Table Entry P MOther Control Bits M: modify bit Length Offset (b) Segmentation only Segment Base Virtual Address Segment Number Page Number Offset
17 Virtual Address Page # Offset Frame # Offset Register Page Table Ptr Page Table + Page# Offset Page Frame Frame # Program Paging Mechanism Main Memory Figure 8.3 Address Translation in a Paging System
18 Size of Page Table Assume a 32 bit address and 4K pages 2 20 virtual pages, Page table requires 2 20 entries If each page table entry (PTE) requires 4 bytes, this is 4MB. Each process requires its own page table Where do we store the page table?
19 Virtual Page Tables Store the page table in virtual memory Each page access has potential for two page faults Base address of page table is a virtual address in system space Virtual address of PTE = Base address of page table + Logical Page # * size of PTE Virtual address of PTE needs to be converted into physical address
20 Two Level Paging A method to support storing pages in virtual memory A root page table maps an address to a page containing part of the page table The virtual address can be divided into: index into root page table : index into page of PTEs : offset in page
21 Two Level Paging 4-kbyte root page table 4-Mbyte user page table 4-Gbyte user address space Figure 8.4 A Two-Level Hierarchical Page Table [JACO98a]
22 Translation Look Aside Buffer Each memory access results in two accesses of physical memory One access to read the page table One access to read the requested data To speed up process a Translation Look Aside Buffer (TLB) is used The TLB is implemented in hardware and contains page number to frame number mappings The TLB is fast, but small, and only contains a small subset of the page table
23 Translation Look Aside Buffer Is a cache of recently used virtual addresses Given a virtual address, processor examines the TLB If page table entry (PTE) is present, the frame is retrieved and the real address is formed If the PTE is not present, the page number is used to access the process s page table The TLB is updated to include the new PTE
24 Return to Faulted Instruction Start CPU checks the TLB Page Table Entry in TLB? Yes No Page Fault Handling Routine OS Instructs CPU to Read the Page from Disk CPU Activates I/O Hardware No Access Page Table Page in Main Memory? Yes Update TLB Page Transferred from Disk to Main Memory CPU Generates Physical Address Memory Full? Yes No Page Tables Updated Page Tables Updated Figure 8.8 Operation of Paging and Translation Lookaside Buffer (TLB) [FURH87]
25 Virtual Address Main Memory Secondary Memory Page # Offset Translation Lookaside Buffer TLB hit Offset Page Table Load page TLB miss Frame # Offset Real Address Page fault Figure 8.7 Use of a Translation Lookaside Buffer
26 Virtual Address Page # Offset Virtual Address Page # Offset Page # PT Entries Frame # Offset Real Address Translation Lookaside Buffer Frame # Offset Real Address Page Table (a) Direct mapping (b) Associative mapping Figure 8.9 Direct Versus Associative Lookup for Page Table Entries
27 Inverted Page Table The number of physical pages (frames) is much smaller than the number of virtual pages The memory requirements are much smaller if we store one entry per frame, instead of per virtual page The TLB and/or a hash table is used to map virtual page # to an entry in the inverted page table Because multiple virtual pages may map to same location, the entries are chained in the page table
28 Inverted Page Table Example: 64-bit virtual address, 4K pages and 32MB of RAM 2 52 (45 quadrillion) possible pages 8192 frames Inverted Page Table is much smaller Used on some IBM and Hewlett Packard work stations
29 Virtual Address Inverted Page Table Page # Offset Page # Inverted Page Table entry Chain Frame # Hash Table Frame # Offset Physical Address
30 Page Size Smaller page size, less internal fragmentation Smaller page size, more pages required per process More pages per process means larger page tables Larger page tables means large portion of page tables in virtual memory Secondary memory is designed to efficiently transfer large blocks of data so large page size is better
31 Page Size Small page size means a large number of pages will be found in main memory As time progresses, each page in memory will contain portions of the process near recent references With larger pages, each page will contain portions of the process farther from recent references Number of page faults is related to the percent of the process in memory that is near recent references
32 Page Fault Rate Page Fault Rate (a) Page Size P W (b) Number of Page Frames Allocated N P = size of entire process W = working set size N = total number of pages in process The page fault rate drops as the number of pages in memory increases Figure 8.11 Typical Paging Behavior of a Program
33 Page Size Multiple page sizes would allow greater flexibility Large page sizes can be used for program instructions or data with high spatial locality Smaller page sizes can be used for threads Variable page sizes not supported by mainstream OSes
34 Computer Atlas Honeywell-Multics IBM 370/XA and 370/ESA VAX family IBM AS/400 DEC Alpha MIPS UltraSPARC Pentium PowerPC Page Sizes Page Size bit words bit words 4 Kbytes 512 bytes 512 bytes 8 Kbytes 4 Kbytes to 16 Mbytes 8 Kbytes to 4 Mbytes 4 Kbytes to 4 Mbytes 4 Kbytes
35 Segmentation Processes are divided into different segments Segments can be different sizes Segments are visible to the programmer Allows parts of a program to be altered and compiled independently (minimal linking) Lends itself to sharing and protection
36 Combined Paging and Segmentation Paging is transparent to the programmer Paging eliminates external fragmentation Segmentation is visible to the programmer Segmentation allows for growing data structures, modularity, and support for sharing and protection Each segment is broken into fixed-size pages
37 P MOther Control Bits Length Segment Base (b) Segmentation only Paging and Segmentation Virtual Address Segment Number Page Number Offset Segment Table Entry Other Control Bits Length Segment Base Page Table Entry P MOther Control Bits Frame Number (c) Combined segmentation and paging P= present bit M = Modified bit Figure 8.2 Typical Memory Management Formats
38 Locality Only a small number of pages will be in memory If pages were accessed uniformly, most page accesses would be page faults and performance will be poor Real programs tend to reused a small set of data Temporal locality: if a process accesses a data item, it is likely to access the same data again Spatial locality: if a process accesses a data item, it is likely to access a nearby data item
39 Locality The use of pages takes advantage of spatial locality When a data item is accessed, the entire page containing the data is read into memory Other items in the page will likely be accessed Too large of a page size will not take advantage of spatial locality Pages already in memory will tend to be accessed again due to temporal locality The replacement policy can try to take further advantage of temporal locality
40 Locality The fact that real programs exhibit spatial and temporal locality makes the memory hierarchy practical Consider a 32 bit virtual address and 512 MB of real memory Virtual memory is 8 times as big real memory What percentage of memory references will cause page faults? If memory references were random, 87.5% of memory references would cause page faults In practice, less than 1% of memory references cause page faults
41 Fetch Policy When should pages be brought into memory? Demand Paging: requested. only bring a page into memory when it is Only brings in pages that are needed Lots of page faults when a process first starts Prepaging: bring in pages before they are requested Requires some guess work Bringing in pages that are physically contiguous on disk is very efficient
42 Replacement Policies When a new page is brought in, we usually have to evict a page so that there is a free frame Which place should be replaced? We want to evict something that will not be used soon
43 Replacement Policies Optimal Replacement policy Replace page that will not be used for the longest time. Requires knowledge of the future. Not possible to implement. Least Recently Used (LRU) First In First Out (FIFO) Clock
44 LRU When temporal locality is in affect, the near future looks like the recent past LRU replaces the page that was used least recently Requires keeping track of when each page was last accessed Tends to outperform other replacement policies, but it is expensive to implement
45 FIFO Replace the page that has been in memory the longest Very trivial to implement fifo_replacement() { frame_number = next_frame next_frame=(next_frame+1)%number_of_frames return frame_number } Does not take advantage of temporal locality
46 Page address stream OPT F F F LRU F F F F FIFO F F F F F F CLOCK 2* 2* 3* 2* 3* 2* 3* 1* 5* 3 1 F 5* 2* 1 F 5* 2* 4* F 5* 2* 4* 3* 2 4 F 3* 2* 4 3* 2 5* F 3* 2* 5* Figure 8.15 Behavior of Four Page-Replacement Algorithms
47 Clock LRU works well but is expensive to implement FIFO is easy to implement, but does not take advantage of temporal locality Clock is a policy that attempts to cheaply simulate LRU Keep track of an additional use bit that is set to 1 whenever the page is referenced Scan the frames looking for a frame with a use bit set to 0 Set use bit to 0 as frames are scanned Many similar replacement policies
48 Clock clock_replacement() { while (set[next_frame] == 1) { set[next_frame]=0 frame_number = next_frame next_frame=(next_frame+1)%number_of_frames } frame_number = next_frame next_frame=(next_frame+1)%number_of_frames return frame_number }
49 n 1 page 9 use = 1 0 page 19 use = 1 next frame pointer page 1 use = 1 1 First frame in circular buffer of frames that are candidates for replacement page 45 use = page 222 use = 0 page 191 use = page 33 use = 1 page 67 use = 1 page 556 use = 0 page 13 use = (a) State of buffer just prior to a page replacement 5 n 1 0 page 9 use = 1 page 19 use = 1 page 1 use = 0 1
50 (a) State of buffer just prior to a page replacement n 1 0 page 9 use = 1 page 19 use = 1 page 1 use = 0 1 page 45 use = page 222 use = 0 page 191 use = page 33 use = 1 page 67 use = 1 page 13 use = 0 page 727 use = (b) State of buffer just after the next page replacement 5 Figure 8.16 Example of Clock Policy Operation
51 Improved Clock Algorithm Evicting a modified (dirty) page is more expensive than evicting a clean page Have to write out the modified page then read in the new page We can modify clock to favor dirty pages
52 Improved Clock Algorithm On first scan look for u bit = 0 and m bit = 0. Do not change u bit. If first scan does not find a frame, on second scan look for u bit = 0 and m bit = 1. Change u bit to 0. Repeat above two steps until a free frame is found. Other modifications including additional use bits to better approximate LRU.
53 n 1 First frame in circular buffer for this process 0 Page 7 not accessed recently; modified Page 9 not accessed recently; modified Page 94 not accessed recently; not modified 1 9 Page 13 not accessed recently; not modified Page 95 accessed recently; not modified 2 8 Next replaced Page 47 not accessed recently; not modified 7 Page 46 not accessed recently; modified Page 121 accessed recently; not modified Page 45 accessed recently; not modified Page 97 not accessed recently; modified Page 96 accessed recently; not modified 4 3 Last replaced 6 5 Figure 8.18 The Clock Page-Replacement Algorithm [GOLD89]
54 Aging Clock algorithms do not distinguish between old references and recent ones. Approximate LRU by aging Each PTE has a counter and a use bit (like in clock) Every k ticks, shift each counter to the right, and insert the use bit as the new high order bet Reset the use bit Choose as victim the PTE with lowest count.
55 Ref. 1 Frames Use Counter Page Ref. 1 Frames Use Counter Page Use Counter Page Use Counter Page Use Counter Page Use Counter Page
56 Ref 5 Frames Use Counter Page Ref 4 Frames Use Counter Page Use Counter Page Use Counter Page Use Counter Page Use Counter Page
57 TLB and Replacement Policies The TLB only contains a subset of the page table entries To take advantage of temporal locality, the TLB should be updated to keep track of recently used pages The TLB is implemented in hardware, so the replacement policy needs to be simple
58 Frame Locking In some cases we want to lock a frame in memory to guarantee it is not swapped out Kernel pages I/O buffers Control Structures Associate a lock bit with each frame
59 Page Buffering Writing single pages out to disk is inefficient A replaced page is added to one of two lists a free page list if the page has not been modified a modified page list if the page has been modified Evicted pages actually remain in memory. Similar to a victim cache System tries to keep some free pages. Modified pages can be written out in clusters
60 Fixed-set Allocation Resident Set Management gives a process a fixed number of frames within which to execute when a page fault occurs, one of the pages of that process must be replaced Variable-allocation number of frames allocated to process varies over the lifetime of the process
61 Fixed Allocation Variable Allocation Local Replacement Number of frames allocated to a process is fixed. Page to be replaced is chosen among the frames allocated to the process. The number of frames allocated to a process may be changed from time to time. Page to be replaced is chosen among the frames allocated to the process. Global Replacement Not possible Page to be replaced is chosen among all available frames. Number of frames used by a process varies.
62 Fixed Allocation, Local Scope A page in the same process will be replaced Replacement algorithms are applied The amount of allocation needs to be decided Too small an allocation means a high number of page faults Too large an allocation limits the number of resident processes
63 Variable Allocation, Global Scope Easiest to implement Adopted by many operating systems Operating system keeps list of free frames Free frame is added to resident set of process when a page fault occurs If no free frame, replace one from another process
64 Variable Allocation, Global Scope When a new process is created, allocate number of page frames based on application type, program request, or other criteria When page fault occurs, select a page among the resident set of the process that suffered the fault Reevaluate allocation from time to time
65 Working Set Strategy Working Set, W (t, ): the set of pages of that process that have been referenced in the last virtual time units. is a window of time over which the process is observed. Working set size will be a nondecreasing function of the window size. The large the window size the larger the working set. The working set size can vary over time for a fixed.
66 - tsequence of Page References Window Size, Figure 8.19 Working Set of Process as Defined by Window Size
67 Working Set Strategy Monitor the working set of each process Periodically remove from the resident set of a process those pages that are not in its working set. A process may only execute if its working set is in main memory.
68 Working Set Problems The past does not always accurately predict the future A true measurement of the working set for each process is not practical The optimal value of is not known and will vary
69 Cleaning Policy Demand cleaning a page is written to disk only when it is selected for replacement Precleaning pages are written out in batches can take advantage of I/O parallelism can write out pages in a more efficient manner
70 Cleaning Policy Best approach used page buffering Replaced pages are put into two lists: modified and unmodified Pages in the modified list are periodically written out in batches Pages in the unmodified list are either reclaimed if referenced again or the frame is assigned to another page
71 Virtual Memory and Scheduling Page faults are expensive. A process that generates a page fault should be blocked until the page fault is resolved With virtual memory, more processes can be supported If too many processes are in memory, thrashing may result Each process needs a subset of its pages (the working set) to work efficiently If the working sets of the current processes do not all fit in memory, excessive page faults will occur If there are too many processes, some may be suspended
72 Process Suspension Lowest priority process Faulting process this process does not have its working set in memory so it will be blocked anyways Last process activated this process is least likely to have its working set resident
73 Process Suspension Process with smallest resident set this process will be the easiest to reload Process with largest resident set obtains the most free frames
74 UNIX and Solaris Memory Management Paging System Kernel Memory Management
75 UNIX and Solaris Paging System Page Table : one per each process Disk block descriptor : associated with each page of a process is an entry that describes the disk copy of the virtual page Page frame data table : describes each frame of real memory and is indexed by frame number Swap-use table: one for each swap device, with one entry for each page on the device
76 Reference count Page/storage unit number Page frame number Age Reference Valid Modify Copy on write Protect (a) Page table entry Swap device number Device block number Type of storage (b) Disk block descriptor Page state Reference count Logical device Block number Pfdata pointer (c) Page frame data table entry
77 Page state Reference count Logical device Block number Pfdata pointer (c) Page frame data table entry Reference count Page/storage unit number (d) Swap-use table entry Figure 8.22 UNIX SVR4 Memory Management Formats
78 UNIX Paging Page Replacement refinement of the clock policy known as the two-handed clock algorithm. The algorithm Set to 0 when the page is first brought in Set to 1 when the page is reference for a read or write
79 fronthand handspread backhand Fronthand: sweeps through pages and sets reference bits to 0. Figure 8.23 Two-Handed Clock Page-Replacement Algorithm Backhand: sweeps and checks references bit. Pages with 0 are placed on a list to be paged out. Scanrate: the rate at which the hands move in pages per second Handspread: the gap between the hands
80 UNIX Kernel Memory Allocation Most allocations are smaller than a page size Using pages would waste memory Lazy Buddy System (SRV4) Defers coalescing until it is needed, and then combine as many blocks as possible This avoids unnecessary work In the steady state the kernel uses many small blocks
81 Linux Memory Managment Three level page table for Virtual Memory Addressing Page directory: a process has a single page directory in memory. Each entry points to a page in the page middle directory. Page middle directory: spans multiple pages. Each entry points to one page in the page table. Page table: each entry refers to one virtual page
82 Linux Virtual Memory Managment Page allocation uses the buddy system Kernel maintains a list of contiguous page frame groups of fixed size, eg. 1, 2, 4, 8, 16, 32 As pages are allocated and deallocated in main memory, the available groups are split and merged as needed
83 Linux Page Replacement Variant of clock and aging algorithm Use bit is replaced by an 8 bit age variable Age variable is incremented each time page is accessed Periodically sweep through global page pool and decrements age Lowest age page is best candidate for replacement
84 Linux Kernel Memory Managment Uses paging A variation of the buddy algorithm is used to allocate smaller chunks within the page
85 W2K Virtual Memory Each user process sees a 32-bit (4 GB) address space A portion of memory is reserved for OS Each user has 2GB of memory Can be increased to 3GB, leaving 1GB for the OS
86 64-Kbyte region for NULL-pointer assignments (inaccessible) 0 2-Gbyte user address space (unreserved, usable) 64-Kbyte region for bad pointer assignments (inaccessible) 2-Gbyte region for the operating system (inacessible) 0xFFFFFFFF Figure 8.25 Windows 2000 Default Virtual Address Space
87 W2K Paging A page can be in one of three states Available : not currently used by this process Reserved: set aside for a process, but does not count against the processes s memory quota until used Committed : pages for which the system has set aside space in its paging file
88 W2K Paging Variable allocation, local scope Assign a certain number of pages to a process as its working set when it is first activated Working sets are adjusted if memory is available, processes are allowed to grow otherwise LRU pages are removed from the resident set
Chapter 8 Virtual Memory
Chapter 8 Virtual Memory Contents Hardware and control structures Operating system software Unix and Solaris memory management Linux memory management Windows 2000 memory management Characteristics of
More informationECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (8 th Week) (Advanced) Operating Systems 8. Virtual Memory 8. Outline Hardware and Control Structures Operating
More informationChapter 8 Virtual Memory
Operating Systems: Internals and Design Principles Chapter 8 Virtual Memory Seventh Edition William Stallings Operating Systems: Internals and Design Principles You re gonna need a bigger boat. Steven
More informationMEMORY MANAGEMENT/1 CS 409, FALL 2013
MEMORY MANAGEMENT Requirements: Relocation (to different memory areas) Protection (run time, usually implemented together with relocation) Sharing (and also protection) Logical organization Physical organization
More informationMemory Management Virtual Memory
Memory Management Virtual Memory Part of A3 course (by Theo Schouten) Biniam Gebremichael http://www.cs.ru.nl/~biniam/ Office: A6004 April 4 2005 Content Virtual memory Definition Advantage and challenges
More informationChapter 8 Virtual Memory
Operating Systems: Internals and Design Principles Chapter 8 Virtual Memory Seventh Edition William Stallings Modified by Rana Forsati for CSE 410 Outline Principle of locality Paging - Effect of page
More informationProcess size is independent of the main memory present in the system.
Hardware control structure Two characteristics are key to paging and segmentation: 1. All memory references are logical addresses within a process which are dynamically converted into physical at run time.
More informationa process may be swapped in and out of main memory such that it occupies different regions
Virtual Memory Characteristics of Paging and Segmentation A process may be broken up into pieces (pages or segments) that do not need to be located contiguously in main memory Memory references are dynamically
More informationChapter 8. Virtual Memory
Operating System Chapter 8. Virtual Memory Lynn Choi School of Electrical Engineering Motivated by Memory Hierarchy Principles of Locality Speed vs. size vs. cost tradeoff Locality principle Spatial Locality:
More informationVirtual Memory. Chapter 8
Virtual Memory 1 Chapter 8 Characteristics of Paging and Segmentation Memory references are dynamically translated into physical addresses at run time E.g., process may be swapped in and out of main memory
More informationCSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management
CSE 120 July 18, 2006 Day 5 Memory Instructor: Neil Rhodes Translation Lookaside Buffer (TLB) Implemented in Hardware Cache to map virtual page numbers to page frame Associative memory: HW looks up in
More informationVirtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358
Virtual Memory Reading: Silberschatz chapter 10 Reading: Stallings chapter 8 1 Outline Introduction Advantages Thrashing Principal of Locality VM based on Paging/Segmentation Combined Paging and Segmentation
More informationVirtual Memory. control structures and hardware support
Virtual Memory control structures and hardware support 1 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time A process may be swapped in and
More informationMemory Management Virtual Memory
Background; key issues Memory Management Virtual Memory Memory allocation schemes Virtual memory Memory management design and implementation issues 1 Remember Basic OS structures: intro in historical order
More informationOperating System Concepts
Chapter 9: Virtual-Memory Management 9.1 Silberschatz, Galvin and Gagne 2005 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped
More informationVirtual Memory. Chapter 8
Chapter 8 Virtual Memory What are common with paging and segmentation are that all memory addresses within a process are logical ones that can be dynamically translated into physical addresses at run time.
More informationChapter 8: Virtual Memory. Operating System Concepts
Chapter 8: Virtual Memory Silberschatz, Galvin and Gagne 2009 Chapter 8: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating
More informationRole of OS in virtual memory management
Role of OS in virtual memory management Role of OS memory management Design of memory-management portion of OS depends on 3 fundamental areas of choice Whether to use virtual memory or not Whether to use
More informationOPERATING SYSTEM. Chapter 9: Virtual Memory
OPERATING SYSTEM Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory
More informationChapter 9: Virtual Memory
Chapter 9: Virtual Memory Chapter 9: Virtual Memory 9.1 Background 9.2 Demand Paging 9.3 Copy-on-Write 9.4 Page Replacement 9.5 Allocation of Frames 9.6 Thrashing 9.7 Memory-Mapped Files 9.8 Allocating
More informationTLB Recap. Fast associative cache of page table entries
Virtual Memory II 1 TLB Recap Fast associative cache of page table entries Contains a subset of the page table What happens if required entry for translation is not present (a TLB miss)? 2 TLB Recap TLB
More informationOperating System Support
Operating System Support Objectives and Functions Convenience Making the computer easier to use Efficiency Allowing better use of computer resources Layers and Views of a Computer System Operating System
More informationVirtual to physical address translation
Virtual to physical address translation Virtual memory with paging Page table per process Page table entry includes present bit frame number modify bit flags for protection and sharing. Page tables can
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 23 Virtual memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Is a page replaces when
More informationVirtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)
Virtual Memory - programmer views memory as large address space without concerns about the amount of physical memory or memory management. (What do the terms 3-bit (or 6-bit) operating system or overlays
More informationCS6401- Operating System UNIT-III STORAGE MANAGEMENT
UNIT-III STORAGE MANAGEMENT Memory Management: Background In general, to rum a program, it must be brought into memory. Input queue collection of processes on the disk that are waiting to be brought into
More informationCISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College
CISC 7310X C08: Virtual Memory Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/22/2018 CUNY Brooklyn College 1 Outline Concepts of virtual address space, paging, virtual page,
More informationFirst-In-First-Out (FIFO) Algorithm
First-In-First-Out (FIFO) Algorithm Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1 3 frames (3 pages can be in memory at a time per process) 15 page faults Can vary by reference string:
More informationOperating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings
Operating Systems: Internals and Design Principles Chapter 7 Memory Management Seventh Edition William Stallings Memory Management Requirements Memory management is intended to satisfy the following requirements:
More informationObjectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency
William Stallings Computer Organization and Architecture 7 th Edition Chapter 8 Operating System Support Objectives and Functions Convenience Making the computer easier to use Efficiency Allowing better
More informationLecture 12: Demand Paging
Lecture 1: Demand Paging CSE 10: Principles of Operating Systems Alex C. Snoeren HW 3 Due 11/9 Complete Address Translation We started this topic with the high-level problem of translating virtual addresses
More informationOperating Systems Virtual Memory. Lecture 11 Michael O Boyle
Operating Systems Virtual Memory Lecture 11 Michael O Boyle 1 Paged virtual memory Allows a larger logical address space than physical memory All pages of address space do not need to be in memory the
More informationThe memory of a program. Paging and Virtual Memory. Swapping. Paging. Physical to logical address mapping. Memory management: Review
The memory of a program Paging and Virtual Memory Operating Systems Spring 4 Source-code is compiled into linkable object modules Memory addresses given as relative offsets Libraries contain object modules
More informationMemory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization
Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical
More informationVirtual Memory Management
Virtual Memory Management CS-3013 Operating Systems Hugh C. Lauer (Slides include materials from Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew Tanenbaum and from Operating
More informationAddresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.
1 Memory Management Address Binding The normal procedures is to select one of the processes in the input queue and to load that process into memory. As the process executed, it accesses instructions and
More informationChapter 9: Virtual Memory
Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating
More informationChapter 9: Virtual Memory
Chapter 9: Virtual Memory Background Demand Paging Chapter 9: Virtual Memory Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations
More informationOperating Systems Lecture 6: Memory Management II
CSCI-GA.2250-001 Operating Systems Lecture 6: Memory Management II Hubertus Franke frankeh@cims.nyu.edu What is the problem? Not enough memory Have enough memory is not possible with current technology
More informationCOMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)
COMP 346 WINTER 2018 1 MEMORY MANAGEMENT (VIRTUAL MEMORY) VIRTUAL MEMORY A process may be broken up into pieces (pages or segments) that do not need to be located contiguously in main memory. Memory references
More informationCS307: Operating Systems
CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn
More informationBasic Memory Management
Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester 10/15/14 CSC 2/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it
More informationChapter 9: Virtual Memory. Operating System Concepts 9th Edition
Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L20 Virtual Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 Questions from last time Page
More informationChapter 10: Virtual Memory
Chapter 10: Virtual Memory Chapter 10: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations
More informationReadings and References. Virtual Memory. Virtual Memory. Virtual Memory VPN. Reading. CSE Computer Systems December 5, 2001.
Readings and References Virtual Memory Reading Chapter through.., Operating System Concepts, Silberschatz, Galvin, and Gagne CSE - Computer Systems December, Other References Chapter, Inside Microsoft
More informationBasic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1
Basic Memory Management Program must be brought into memory and placed within a process for it to be run Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester Mono-programming
More informationVirtual Memory Outline
Virtual Memory Outline Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations Operating-System Examples
More informationOperating System Concepts 9 th Edition
Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating
More informationPAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo
PAGE REPLACEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced
More informationChapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space
Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations
More informationChapter 9: Virtual Memory
Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations
More informationPage Size Page Size Design Issues
Paging: design and implementation issues 1 Effect of page size More small pages to the same memory space References from large pages more probable to go to a page not yet in memory References from small
More information!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?
Chapter 10: Virtual Memory Questions? CSCI [4 6] 730 Operating Systems Virtual Memory!! What is virtual memory and when is it useful?!! What is demand paging?!! When should pages in memory be replaced?!!
More informationChapter 9: Virtual Memory. Operating System Concepts 9 th Edition
Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating
More informationOperating Systems, Fall Lecture 5 1. Overhead due to page table and internal fragmentation. Tbl 8.2 [Stal05] 4.
Paging: design and implementation issues Effect of page size More small pages to the same memory space References from large pages more probable to go to a page not yet in memory References from small
More informationChapter 4: Memory Management. Part 1: Mechanisms for Managing Memory
Chapter 4: Memory Management Part 1: Mechanisms for Managing Memory Memory management Basic memory management Swapping Virtual memory Page replacement algorithms Modeling page replacement algorithms Design
More informationOperating Systems, Fall Lecture 5 1
Paging: design and implementation issues 1 Effect of page size More small pages to the same memory space References from large pages more probable to go to a page not yet in memory References from small
More informationChapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition
Chapter 8: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 8: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating
More informationChapter 9: Virtual-Memory
Chapter 9: Virtual-Memory Management Chapter 9: Virtual-Memory Management Background Demand Paging Page Replacement Allocation of Frames Thrashing Other Considerations Silberschatz, Galvin and Gagne 2013
More informationOperating Systems. Operating Systems Sina Meraji U of T
Operating Systems Operating Systems Sina Meraji U of T Recap Last time we looked at memory management techniques Fixed partitioning Dynamic partitioning Paging Example Address Translation Suppose addresses
More informationChapter 4 Memory Management. Memory Management
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7
More informationVIRTUAL MEMORY READING: CHAPTER 9
VIRTUAL MEMORY READING: CHAPTER 9 9 MEMORY HIERARCHY Core! Processor! Core! Caching! Main! Memory! (DRAM)!! Caching!! Secondary Storage (SSD)!!!! Secondary Storage (Disk)! L cache exclusive to a single
More informationChapter 9: Virtual Memory. Operating System Concepts 9 th Edition
Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating
More informationVirtual Memory III. Jo, Heeseung
Virtual Memory III Jo, Heeseung Today's Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced virtual memory techniques Shared
More informationMemory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.
Memory Management To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Basic CPUs and Physical Memory CPU cache Physical memory
More informationPaging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1
Paging algorithms CS 241 February 10, 2012 Copyright : University of Illinois CS 241 Staff 1 Announcements MP2 due Tuesday Fabulous Prizes Wednesday! 2 Paging On heavily-loaded systems, memory can fill
More informationChapter 8 & Chapter 9 Main Memory & Virtual Memory
Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array
More informationMove back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t
Memory Management Ch. 3 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Memory Hierarchy Cache CPU Main Swap Area Memory
More informationMemory Management Ch. 3
Memory Management Ch. 3 Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ 1 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ
More informationVirtual Memory. CSCI 315 Operating Systems Design Department of Computer Science
Virtual Memory CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture have been largely based on those from an earlier edition of the course text Operating
More informationWeek 2: Tiina Niklander
Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Policies and methods Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka
More informationVirtual Memory COMPSCI 386
Virtual Memory COMPSCI 386 Motivation An instruction to be executed must be in physical memory, but there may not be enough space for all ready processes. Typically the entire program is not needed. Exception
More informationAll Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging
3/14/2001 1 All Paging Schemes Depend on Locality VM Page Replacement Emin Gun Sirer Processes tend to reference pages in localized patterns Temporal locality» locations referenced recently likely to be
More informationChapter 9 Memory Management
Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual
More informationMemory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.
Chapter 4 Memory Management Ideally programmers want memory that is Memory Management large fast non volatile 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms
More informationChapter 8. Operating System Support. Yonsei University
Chapter 8 Operating System Support Contents Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management 8-2 OS Objectives & Functions OS is a program that Manages the
More informationOptimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs
Optimal Algorithm Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs page 1 Least Recently Used (LRU) Algorithm Reference string: 1, 2, 3,
More informationMemory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts
Memory management Last modified: 26.04.2016 1 Contents Background Logical and physical address spaces; address binding Overlaying, swapping Contiguous Memory Allocation Segmentation Paging Structure of
More informationOperating Systems, Fall
Policies and methods Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka
More informationCS 153 Design of Operating Systems Winter 2016
CS 153 Design of Operating Systems Winter 2016 Lecture 18: Page Replacement Terminology in Paging A virtual page corresponds to physical page/frame Segment should not be used anywhere Page out = Page eviction
More informationCPE300: Digital System Architecture and Design
CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Virtual Memory 11282011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Review Cache Virtual Memory Projects 3 Memory
More informationChapter 3 - Memory Management
Chapter 3 - Memory Management Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 3 - Memory Management 1 / 222 1 A Memory Abstraction: Address Spaces The Notion of an Address Space Swapping
More informationChapter 8: Memory-Management Strategies
Chapter 8: Memory-Management Strategies Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and
More informationChapter 8: Main Memory. Operating System Concepts 8th Edition
Chapter 8: Main Memory Operating System Concepts 8th Edition Silberschatz, Galvin and Gagne 2009 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page
More informationPage Replacement Algorithms
Page Replacement Algorithms MIN, OPT (optimal) RANDOM evict random page FIFO (first-in, first-out) give every page equal residency LRU (least-recently used) MRU (most-recently used) 1 9.1 Silberschatz,
More informationHow to create a process? What does process look like?
How to create a process? On Unix systems, executable read by loader Compile time runtime Ken Birman ld loader Cache Compiler: generates one object file per source file Linker: combines all object files
More informationChapter 10: Virtual Memory. Background
Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples 10.1 Background Virtual memory separation of user logical
More informationComputer Organization and Architecture. OS Objectives and Functions Convenience Making the computer easier to use
Computer Organization and Architecture Chapter 8 Operating System Support 1. Processes and Scheduling 2. Memory Management OS Objectives and Functions Convenience Making the computer easier to use Efficiency
More informationOperating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory
Operating Systems Lecture 7 Memory management : Virtual memory Overview Virtual memory part Page replacement algorithms Frame allocation Thrashing Other considerations Memory over-allocation Efficient
More informationVirtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms
Virtual Memory Today! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms Reminder: virtual memory with paging! Hide the complexity let the OS do the job! Virtual address
More informationAddress spaces and memory management
Address spaces and memory management Review of processes Process = one or more threads in an address space Thread = stream of executing instructions Address space = memory space used by threads Address
More informationCourse Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems
Course Outline Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems 1 Today: Memory Management Terminology Uniprogramming Multiprogramming Contiguous
More informationChapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory
Chapter 0: Virtual Memory Background Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples Virtual memory separation of user logical memory
More informationCPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner
CPS104 Computer Organization and Programming Lecture 16: Virtual Memory Robert Wagner cps 104 VM.1 RW Fall 2000 Outline of Today s Lecture Virtual Memory. Paged virtual memory. Virtual to Physical translation:
More informationCHAPTER 8 - MEMORY MANAGEMENT STRATEGIES
CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES OBJECTIVES Detailed description of various ways of organizing memory hardware Various memory-management techniques, including paging and segmentation To provide
More informationChapter 8 Memory Management
1 Chapter 8 Memory Management The technique we will describe are: 1. Single continuous memory management 2. Partitioned memory management 3. Relocatable partitioned memory management 4. Paged memory management
More informationOperating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza
Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement May 05, 2008 Léon Mugwaneza http://www.it.uu.se/edu/course/homepage/os/vt08 Review: Multiprogramming (with
More informationCS399 New Beginnings. Jonathan Walpole
CS399 New Beginnings Jonathan Walpole Memory Management Memory Management Memory a linear array of bytes - Holds O.S. and programs (processes) - Each cell (byte) is named by a unique memory address Recall,
More informationOperating Systems, Fall Lecture 5, Tiina Niklander 1
Paging: Design issues, Segmentation Page Fault Handling more details 1. Hardware traps to kernel 2. General registers saved 3. OS determines which virtual page needed 4. OS checks validity of address,
More information