Module IV Memory Organization.

Slides:



Advertisements
Similar presentations
9.4 Page Replacement What if there is no free frame?
Advertisements

Chapter 10: Virtual Memory
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Chapter 9 Virtual Memory Bernard Chen 2007 Spring.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 13: Main Memory (Chapter 8)
Chapter 9: Virtual Memory
Virtual Memory Management G. Anuradha Ref:- Galvin.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Memory Management Design & Implementation Segmentation Chapter 4.
03/26/2010CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying an earlier.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Chapter 10: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 10: Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Virtual Memory.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Part 8: Virtual Memory. Silberschatz, Galvin and Gagne ©2005 Virtual vs. Physical Address Space Each process has its own virtual address space, which.
Operating Systems Chapter 8
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
CS212: OPERATING SYSTEM Lecture 6: Virtual-Memory Management 1 Computer Science Department.
Subject: Operating System.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Virtual Memory Various memory management techniques have been discussed. All these strategies have the same goal: to keep many processes in memory simultaneously.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
Lecture 19 Virtual Memory Demand Paging. Background Virtual memory – separation of user logical memory from physical memory. –Only part of the program.
Virtual Memory The address used by a programmer will be called a virtual address or logical address. An address in main memory is called a physical address.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual-Memory Management.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
SLC/VER1.0/OS CONCEPTS/OCT'99
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Operating Systems Virtual Memory Alok Kumar Jagadev.
Module 9: Virtual Memory
Chapter 9: Virtual Memory
O.S Lecture 13 Virtual Memory.
Chapter 9: Virtual-Memory Management
Operating Systems Lecture November 2018.
Module IV Memory Organization.
What Happens if There is no Free Frame?
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
Operating Systems CMPSC 473
Module IV Memory Organization.
Module 9: Virtual Memory
Chapter 9: Virtual Memory CSS503 Systems Programming
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
Presentation transcript:

Module IV Memory Organization

Paging Paging method Paging avoids external fragmentation breaks physical memory into fixed-sized blocks called frames and breaks logical memory into blocks of same size called pages Paging avoids external fragmentation Disadv: Internal Fragmentation When a process is to be executed, its pages are loaded into available memory frames from their source.

Paging Hardware Every address by CPU is divided into two parts: page number (p) & page offset (d). Page number is an index to page table Page table contains base address of the page This base address is combined with page offset to get physical address

Paging Hardware

Paging Model

Demand Paging To load an executable program from disk into memory Option 1: load entire program at execution time. But for a program with options, it is inefficient Option 2: load pages only as they are needed and is known as demand paging

Demand Paging A pager swaps a page into memory when a page is needed Pager find whether the page is in memory or disk by valid–invalid bit. When this bit is set to “valid,” the page is legal and is in memory. If it is set to “invalid,” the page either is not valid ( not in logical address space of process) or is valid but is in the disk.

Demand Paging Page-table entry is brought into memory for each process Page-table entry for a page that is not currently in memory is either marked invalid or contains the address of the page on disk. Access to a page that is not in memory causes page fault invoking a trap to OS.

Demand Paging Paging allows multiprogramming It lead to over-allocation of memory When no free frames are available, a page replacement algorithm is applied

Page Fault Service Routine 1. Find the location of the desired page on the disk. 2. Find a free frame: a. If there is a free frame, use it. b. If there is no free frame, use a page-replacement algorithm to select a victim frame. c. Write victim frame to disk & update page & frame table. 3. Read the desired page into the newly freed frame; change the page and frame tables. 4. Restart the user process.

Basic Page Replacement

Page Replacement Algorithms Many algorithms are available One with the lowest page-fault rate is considered as best. They are: FIFO Page Replacement Optimal Page Replacement LRU Page Replacement. LFU Page Replacement

FIFO Page Replacement It associates each page with the time it was brought into memory. To replace a page, the oldest one is chosen. Implementation create a FIFO queue to hold all pages. replace the page at the head of the queue Insert the page at the tail of the queue.

FIFO Page Replacement Example Consider the reference string : 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 for a memory with three frames.

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1 7

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1 7

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1 7

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 1 2 3 4 Page Frame Hit 3 2 1 7 Hit Ratio = 5/20 No. of Page Faults = 15

FIFO Page Replacement It is easy to understand and program. Its performance is not always good If initial page contain an initialization module, it works good If it contain a heavily used variable in constant use, the performance degrades.