CSE378 Virtual memory.1 Evolution in memory management techniques In early days, single program ran on the whole machine –used all the memory available.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Segmentation and Paging Considerations
CS 153 Design of Operating Systems Spring 2015
Virtual Memory Chapter 8.
Memory Management (II)
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management.
Memory Management 2010.
Chapter 3.2 : Virtual Memory
Translation Buffers (TLB’s)
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
Computer Organization and Architecture
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.
Mem. Hier. CSE 471 Aut 011 Evolution in Memory Management Techniques In early days, single program run on the whole machine –Used all the memory available.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Virtual Memory  Early computers had a small and fixed amount to memory. All programs had to be able to fit in this memory. Overlays were used when the.
Memory Management CSE451 Andrew Whitaker. Big Picture Up till now, we’ve focused on how multiple programs share the CPU Now: how do multiple programs.
Review of Memory Management, Virtual Memory CS448.
Operating Systems Chapter 8
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.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
1 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
CE Operating Systems Lecture 14 Memory management.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Review (1/2) °Caches are NOT mandatory: Processor performs arithmetic Memory stores data Caches simply make data transfers go faster °Each level of memory.
Virtual Memory 1 1.
Memory Management Operating Systems CS550. Memory Manager Memory manager - manages allocation and de-allocation of main memory Plays significant impact.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
The Memory Hierarchy Lecture 31 20/07/2009Lecture 31_CA&O_Engr. Umbreen Sabir.
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.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Virtual Memory Chapter 8.
SLC/VER1.0/OS CONCEPTS/OCT'99
Chapter 2 Memory and process management
CSE 120 Principles of Operating
CS703 - Advanced Operating Systems
Paging COMP 755.
Paging and Segmentation
Lecture 28: Virtual Memory-Address Translation
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Evolution in Memory Management Techniques
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
Translation Buffers (TLB’s)
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Translation Buffers (TLB’s)
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Evolution in memory management techniques
Evolution in memory management techniques
Evolution in memory management techniques
Translation Buffers (TLBs)
Review What are the advantages/disadvantages of pages versus segments?
CSE 542: Operating Systems
Virtual Memory 1 1.
Presentation transcript:

CSE378 Virtual memory.1 Evolution in memory management techniques In early days, single program ran on the whole machine –used all the memory available Even so, there was often not enough memory to hold data and program for the entire run –use of overlays, i.e., static partitioning of program and data so that parts that were not needed at the same time could share the same memory addresses Soon, it was noticed that I/O was much more time consuming than processing, hence the advent of multiprogramming

CSE378 Virtual memory.2 Multiprogramming: issues in memory management Multiprogramming –Several programs are resident in main memory at the same time –When one program executes and needs I/O, it relinquishes CPU to another program Some important questions from the memory management viewpoint: –How is one program protected from another? –How does one program ask for more memory? –How can a program be loaded in main memory?

CSE378 Virtual memory.3 Multiprogramming: early implementations Programs are compiled and linked wrt to address 0 Addresses that are generated by the CPU need to be modified –A generated address is a virtual address –The virtual address is translated into a real or physical address In early implementations, use of a base and length registers –physical address = base register contents + virtual address –if physical address > (base register contents + length register) then we have an exception

CSE378 Virtual memory.4 Relocation and length registers Program A Program B Unallocated Program C Base register Length reg. Program B is executing Note: fragmentation (unallocated memory) gets worse as time goes on (more small pieces) Program must be allocated in continuous memory locations Still requires overlays for large programs

CSE378 Virtual memory.5 Virtual memory: paging Basic idea first proposed and implemented at the University of Manchester in the early 60’s. Basic idea is to divide the virtual space into chunks of the same size, or (virtual) pages and divide also the physical memory into physical pages or frames Provide a general (fully-associative) mapping between virtual pages and frames –This is a relocation mechanism whereby any virtual page can be stored in any physical frame

CSE378 Virtual memory.6 Paging and segmentation Division in equal size pages is arbitrary –division in segments corresponding to semantic entities (objects), e.g., function text, data arrays etc. may make more sense but… –implementation of segments of different sizes is not as easy (although it has been done, most notably in the Burroughs series of machines) Nowadays, segmentation has the connotation of groups of pages

CSE378 Virtual memory.7 Paging Allows virtual address space larger than physical memory –recall that the stack starts at the largest possible virtual address and grows towards lower addresses while code starts at low addresses Allows sharing of physical memory between programs (multiprogramming) without as much fragmentation –physical memory allocated to a program does not need to be continuous; only an integer number of pages Allows sharing of pages between programs (not always simple, cf. CSE 451)

CSE378 Virtual memory.8 Illustration of paging Program A Program B Physical memory V.p.0 V.p.1 V.p.2 V.p.3 V.p.n V.p.q Frame 0 Frame 1 Frame 2 Frame m Note: In general n, q >> m Programs A and B share frame 0 but with different virtual page numbers Not all virtual pages of a program are mapped at a given time Mapping device

CSE378 Virtual memory.9 Mapping device: Page table Mapping info. for each program is kept in a page table A page table entry (PTE) indicates the mapping of the virtual page to the physical page A valid bit indicates whether the mapping is current or not If there is a memory reference (recall that a reference is a virtual address) to a page with the valid bit off in its corresponding PTE, we have a page fault –this means we’ll have to go to disk to fetch the page The PTE also contains a dirty bit to indicate whether the page has been modified since it was fetched

CSE378 Virtual memory.10 Illustration of page table Program A Program B Physical memory V.p.0 V.p.1 V.p.2 V.p.3 V.p.n V.p.q Frame 0 Frame 1 Frame 2 Frame m m 0 Page table for Program A Valid bits Page table for Program B

CSE378 Virtual memory.11 From virtual address to memory location (highly abstracted) ALU Virtual address Page table Physical address Memory hierarchy

CSE378 Virtual memory.12 Virtual address translation Page size is always a power of 2 –Typical page sizes: 4 KB, 8 KB A virtual address consists of a virtual page number and an offset within the page –For example, with a 4KB page size the virtual address will have a page number and an offset between 0 and 4K -1 –By analogy with a fully-associative cache, the offset is the displacement field, the virtual page number is the tag. –Thus for a 4KB page, offset will be 12 bits and virtual page number is 20 bits The physical address will have a frame number and the same offset as the virtual address it is translated from

CSE378 Virtual memory.13 Virtual address translation (ct’d) 1 Virtual page numberOffset Physical frame number Page table

CSE378 Virtual memory.14 Paging system summary (so far) Addresses generated by the CPU are virtual addresses In order to access the memory hierarchy, these addresses must be translated into physical addresses That translation is done on a program per program basis. Each program must have its own page table The virtual address of program A and the same virtual address in program B will, in general, map to two different physical addresses

CSE378 Virtual memory.15 Page faults When a virtual address has no corresponding physical address mapping (valid bit is off in the PTE) we have a page fault On a page fault (a page fault is an exception) –the faulting page must be fetched from disk (takes milliseconds) –the whole page (e.g., 4 or 8KB ) must be fetched (amortize the cost of disk access) –because the program is going to be idle during that page fetch, the CPU better be used by another program. On a page fault, the process state of the faulting program is saved and the O.S. takes over. This is called context-switching

CSE378 Virtual memory.16 Page size choices Small pages (e.g., 512 bytes in the VAX) –Pros: takes less time to fetch from disk but as we’ll see fetching a page of size 2x takes less than twice the time of fetching a page of size x; better utilization of pages (less fragmentation) –Con: page tables are large but one can use multilevel pages Large pages. Pros and cons converse from small pages Current trends –Page size 4 KB or 8KB. –Possibility of two pages sizes, one normal (4KB) and one very large, e.g. 256KB for applications such as graphics.

CSE378 Virtual memory.17 Top level questions relative to paging systems When do we bring a page in main memory? Where do we put it? How do we know it’s there? What happens if main memory is full

CSE378 Virtual memory.18 Top level answers relative to paging systems When do we bring a page in main memory? –When there is a page fault for that page, i.e., on demand Where do we put it? –No restriction; mapping is fully-associative How do we know it’s there? –The corresponding PTE entry has its valid bit on What happens if main memory is full –We have to replace one of the virtual pages currently mapped. Replacement algorithms can be sophisticated (cf. CSE 451) since we have a context-switch and hence plenty of time