Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.

Slides:



Advertisements
Similar presentations
Chapters 7 & 8 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Advertisements

Memory Management Norman White Stern School of Business.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Memory Design Example. Selecting Memory Chip Selecting SRAM Memory Chip.
Operating System Support Focus on Architecture
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Multiprocessing Memory Management
Operating System Support Focus on Architecture
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Memory Management 2010.
Chapter 8 Operating System Support (Continued)
Virtual Memory Chapter 8.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 8 Operating System Support
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Memory Management Chapter 5.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Computer Organization and Architecture
Virtual Memory I Chapter 8.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Computer Organization and Architecture Operating System Support Chapter 8.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Review of Memory Management, Virtual Memory CS448.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Memory Management Reading: Stallings, Sections.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Chapter 9 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management – Page 1CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Memory Management *** Modified – look for Reading:
Memory Management Chapter 5 Advanced Operating System.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Virtual Memory. Cache memory enhances performance by providing faster memory access speed. Virtual memory enhances performance by providing greater memory.
Computer Architecture Chapter (8): Operating System Support
Chapter 8 Operating System Support
William Stallings Computer Organization and Architecture
Chapter 8 Virtual Memory
Virtual Memory Chapter 8.
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Computer Architecture
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
William Stallings Computer Organization and Architecture 8th Edition
Operating Systems.
Computer Architecture
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSCI 4717/5717 Computer Architecture
William Stallings Computer Organization and Architecture 8th Edition
Operating Systems: Internals and Design Principles, 6/E
Presentation transcript:

Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory

Cache memory enhances performance by providing faster memory access speed. Virtual memory enhances performance by providing greater memory capacity, without the expense of adding main memory. Instead, a portion of a disk drive serves as an extension of main memory. Most modern OSs use Virtual Memory.

Schedulers (very briefly) Virtual Memory is controled by the Medium term scheduler of an OS. An OS normally has 3 schedulers —Long Term Scheduler –Use to control multi programming. IE how many processes line up to use the processor. —Medium Term Scheduler –Use to control use of memory (and virtual memory if it exists) —Short Term Scheduler –Which process actually gets to use the processor. We’ll come back to schedulers in the OS lecture, but right now we look at the Medium Term Scheduler and memory management.

Memory Management Uni-program —Memory split into two —One for Operating System (monitor) —One for currently executing program Multi-program —“User” part is sub-divided and shared among active processes

Swapping Problem: I/O is so slow compared with CPU that even in multi-programming system, CPU can be idle most of the time Solutions: —Increase main memory –Expensive –Leads to larger programs —Swapping

What is Swapping? A queue of processes stored on disk Processes “swapped” in as space becomes available As a process completes it is moved out of main memory If none of the processes in memory are ready to use the CPU —Swap out a blocked process to intermediate queue —Swap in a ready process or a new process —But swapping is an I/O process...

Partitioning Splitting memory into sections to allocate to processes (including Operating System) Fixed-sized partitions —May not be equal size —Process is fitted into smallest hole that will take it (best fit) —Some wasted memory —Leads to variable sized partitions

Use of Swapping

Fixed Partitioning

Variable Sized Partitions (1) Allocate exactly the required memory to a process This leads to a hole at the end of memory, too small to use —Only one small hole - less waste When all processes are blocked, swap out a process and bring in another New process may be smaller than swapped out process Another hole

Variable Sized Partitions (2) Eventually have lots of holes (fragmentation) Solutions: —Coalesce - Join adjacent holes into one large hole —Compaction - From time to time go through memory and move all hole into one free block (c.f. disk de- fragmentation)

Effect of Dynamic Partitioning

Relocation No guarantee that process will load into the same place in memory Instructions contain addresses —Locations of data —Addresses for instructions (branching) Logical address - relative to beginning of program Physical address - actual location in memory (this time) Automatic conversion using base address

Paging Split memory into equal sized, small chunks - page frames Split programs (processes) into equal sized small chunks - pages Allocate the required number page frames to a process Operating System maintains list of free frames A process does not require contiguous page frames Use page table to keep track

Allocation of Free Frames

Logical and Physical Addresses - Paging

Virtual Memory Demand paging —Do not require all pages of a process in memory —Bring in pages as required Page fault —Required page is not in memory —Operating System must swap in required page —May need to swap out a page to make space –Page replacement algorithms, see cache replacement algorithms.

Thrashing Too many processes in too little memory Operating System spends all its time swapping Little or no real work is done Disk light is on all the time Solutions —Good page replacement algorithms —Reduce number of processes running —Fit more memory

Bonus We do not need all of a process in memory for it to run We can swap in pages as required So - we can now run processes that are bigger than total memory available! Main memory is called real memory User/programmer sees much bigger memory - virtual memory

Page Table Structure

Translation Lookaside Buffer Every virtual memory reference causes two physical memory access —Fetch page table entry —Fetch data Use special cache for page table —TLB

1. Extract the page number from the virtual address. 2. Extract the offset from the virtual address. 3. Search for the virtual page number in the TLB. 4. If the (virtual page #, page frame #) pair is found in the TLB, add the offset to the physical frame number and access the memory location. 5. If there is a TLB miss, go to the page table to get the necessary frame number. If the page is in memory, use the corresponding frame number and add the offset to yield the physical address. 6. If the page is not in main memory, generate a page fault and restart the access when the page fault is complete. TLB lookup process

Virtual Memory Putting it all together: The TLB, Page Table, and Main Memory

Segmentation Paging is not (usually) visible to the programmer Segmentation is visible to the programmer Usually different segments allocated to program and data May be a number of program and data segments A program may be run 2 times at the same time, but the OS uses the same program segment and different data segments. —Saving Memory!

Advantages of Segmentation Simplifies handling of growing data structures Allows programs to be altered and recompiled independently, without re-linking and re-loading Lends itself to sharing among processes Lends itself to protection Some systems combine segmentation with paging

Paging and Segmentation Combine to the best of both worlds Paging is used for memory allocation Segmentation is used on top of Paging —A Segment may take X number of pages. —Now data segments can continue to grow as needed and “new” pages are used as a segment causes a page fault.

Paging and Segmentation (2) Large page tables are cumbersome and slow, but with its uniform memory mapping, page operations are fast. Segmentation allows fast access to the segment table, but segment loading is labor- intensive. Paging and segmentation can be combined to take advantage of the best features of both by assigning fixed-size pages within variable-sized segments. Each segment has a page table. This means that a memory address will have three fields, one for the segment, another for the page, and a third for the offset.

A Real-World Example The Pentium architecture supports both paging and segmentation, and they can be used in all 4 variants. The processor supports two levels of cache (L1 and L2), both having a block size of 32 bytes. The L1 cache is next to the processor, and the L2 cache sits between the processor and memory. The L1 cache is in two parts: and instruction cache (I- cache) and a data cache (D-cache). The next slide shows this organization schematically.

A Real-World Example

Q A &