Evolution in memory management techniques

Slides:



Advertisements
Similar presentations
CS 153 Design of Operating Systems Spring 2015
Advertisements

Memory Management (II)
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
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.
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.
CSE378 Virtual memory.1 Evolution in memory management techniques In early days, single program ran on the whole machine –used all the memory available.
Review of Memory Management, Virtual Memory CS448.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
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.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Virtual Memory Chapter 8.
Memory Management Chapter 3
Translation Lookaside Buffer
MODERN OPERATING SYSTEMS Third Edition ANDREW S
SLC/VER1.0/OS CONCEPTS/OCT'99
Chapter 2 Memory and process management
CS161 – Design and Architecture of Computer
CSE 120 Principles of Operating
Lecture 12 Virtual Memory.
CS703 - Advanced Operating Systems
Paging COMP 755.
Memory Management References text: Tanenbaum ch.4.
PA1 is out Best by Feb , 10:00 pm Enjoy early
Paging and Segmentation
CSE 153 Design of Operating Systems Winter 2018
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.
Operating System Concepts
Evolution in Memory Management Techniques
Memory Management References text: Tanenbaum ch.4.
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.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
Virtual Memory Hardware
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
Translation Buffers (TLB’s)
Contents Memory types & memory hierarchy Virtual memory (VM)
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
Memory Management CSE451 Andrew Whitaker.
CSE 153 Design of Operating Systems Winter 2019
CSE 471 Autumn 1998 Virtual memory
Evolution in memory management techniques
Evolution in memory management techniques
Principle of Locality: Memory Hierarchies
Translation Buffers (TLBs)
Review What are the advantages/disadvantages of pages versus segments?
Virtual Memory.
CSE 542: Operating Systems
Virtual Memory 1 1.
Presentation transcript:

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 5/19/2019 CSE378 Virtual memory.

Multiprogramming: issues in memory management 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? 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

Relocation and length registers Program A Base register Program B Program B is executing Unallocated 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 Length reg. Program C Unallocated 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

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) 5/19/2019 CSE378 Virtual memory.

Illustration of paging Program A Physical memory V.p.0 Frame 0 V.p.1 Frame 1 V.p.2 Frame 2 V.p.3 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 V.p.n Frame m V.p.0 V.p.1 Program B V.p.2 Mapping device V.p.q 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

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

From virtual address to memory location (highly abstracted) ALU Virtual address Page table Memory hierarchy Physical address 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

Virtual address translation (ct’d) Virtual page number Offset 1 Page table Physical frame number Offset 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

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 state of the faulting program is saved and the O.S. takes over. This is called context-switching 5/19/2019 CSE378 Virtual memory.

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. 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.

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 5/19/2019 CSE378 Virtual memory.