SlideShare a Scribd company logo
1 of 15
VIRTUAL MEMORY



                              Maninder Kaur
                              professormaninder@gmail.com




1   www.eazynotes.com                          24-Nov-2010
What is Virtual Memory?
    The term virtual memory refers to something which appears to
       be present but actually it is not.

    The virtual memory technique allows users to use more
       memory for a program than the real memory of a computer.

    So, virtual memory is the concept that gives the illusion to
       the user that they will have main memory equal to the
       capacity of secondary storage media.



2   www.eazynotes.com                                       24-Nov-2010
Concept of Virtual Memory
     A programmer can write a program which requires more memory
       space than the capacity of the main memory. Such a program is
       executed by virtual memory technique.

     The program is stored in the secondary memory. The memory
       management unit (MMU) transfers the currently needed part of the
       program from the secondary memory to the main memory for
       execution.
    
     This to and fro movement of instructions and data (parts of a
       program) between the main memory and the secondary memory
       is called Swapping.



3   www.eazynotes.com                                           24-Nov-2010
Address Space And Memory
                      Space
    Virtual address is the address used by the programmer and
       the set of such addresses is called the address space or virtual
       memory.

    An address in main memory is called a location or physical
       address. The set of such locations in main memory is called
       the memory space or physical memory.




4   www.eazynotes.com                                            24-Nov-2010
Virtual Memory




5   www.eazynotes.com                    24-Nov-2010
Virtual Memory (cont.)
    1.    CPU generated logical address consisting of a logical page number
          plus the location within that page (x).

    2.    It must be mapped onto an actual (physical) main memory address by
          the operating system using mapper.

    3.     If the page is present in the main memory, CPU gets the requires data
          from the main memory.

    4.     If the mapper detects that the requested page is not present in main
          memory, a page fault occurs and the page must be read from
          secondary storage (4, 5) into a page frame in main memory.


6   www.eazynotes.com                                                   24-Nov-2010
Address Mapping Using
      Memory Mapping Page Table
     When the requested page is not available in the main memory, we
       can say that a page fault have been occurred in the main memory.

     Then the virtual address generated by the CPU is used to take out
       the requested page from the secondary storage media to the main
       memory to remove this page fault.

     If empty page frame is not available, then a page must be removed
       from page frame in main memory.



7   www.eazynotes.com                                           24-Nov-2010
Page Replacement Algorithms
    In a computer operating system that uses paging for virtual
       memory management, page replacement algorithms decide
       which memory pages to page out (swap out, write to disk)
       when a page of memory needs to be allocated.

    Paging happens when a page fault occurs and a free page
       cannot be used to satisfy the allocation, either because there
       are none, or because the number of free pages is lower than
       some threshold.




8   www.eazynotes.com                                         24-Nov-2010
First - In - First - Out (FIFO)
     First-in-first-out is very easy to implement. The FIFO algorithm selects
       the page for replacement that has been in memory the longest time.

     When a new page must be loaded, the page recently brought in is
       removed. The page to be removed is easily determined because its
       identification number is at the top of the FIFO stack.

     The FIFO replacement policy has the advantage of being easy to
       implement.

     It has the disadvantage that under certain circumstances pages are
       removed and loaded from memory too frequently.




9   www.eazynotes.com                                                 24-Nov-2010
FIFO Algorithm
      Consider a paging system having capacity of 3 pages. The execution of a
       program requires references to five distinct pages P1, P2, P3, P4 and P5. The
       pages are executed in the following sequence:
      P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2




10      www.eazynotes.com                                              24-Nov-2010
Least Recently Used (LRU)
      The least recently used page (LRU) replacement algorithm keeps track
        of page usage over a short period of time.

      The LRU algorithm can be implemented by associating a counter with
        every page that is in main memory.

      When a page is referenced, its associated counter is set to 0. At fixed
        intervals of time, the counters associated with all pages presently in
        memory are incremented by 1.

      The least recently used page is the page with the highest count. The
        counters are often called aging registers, as their count indicates their age,
        that is, how long their associated pages have been referenced.



11   www.eazynotes.com                                                      24-Nov-2010
LRU Algorithm
 Consider a paging system having capacity of 3 pages. The execution of a
 program requires references to five distinct pages P1, P2, P3, P4 and P5. The
 pages are executed in the following sequence:
 P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2




12    www.eazynotes.com                                             24-Nov-2010
Optimal (OPT)
      The optimal policy selects that page for replacement for which the
        time to the next reference is longest.

      This algorithm results in fewest number of page faults. But, this
        algorithm is impossible to implement.

      At the time of page fault , the operating system has no way of
        knowing when each of the pages will be referenced next.
        However , it does serve as a standard against which to judge other
        algorithms.


13   www.eazynotes.com                                            24-Nov-2010
Optimal (OPT)
Consider a paging system having capacity of 3 pages. The execution
 of a program requires references to five distinct pages P 1, P2, P3, P4
 and P5. The pages are executed in the following sequence:
P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2




14    www.eazynotes.com                                          24-Nov-2010
15

More Related Content

What's hot

Timing and-control-unit
Timing and-control-unitTiming and-control-unit
Timing and-control-unitAnuj Modi
 
Cache memory
Cache memoryCache memory
Cache memoryAnuj Modi
 
Memory management
Memory managementMemory management
Memory managementcpjcollege
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208Ameer Mehmood
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Gaditek
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating SystemRaj Mohan
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memoryMazin Alwaaly
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsWayne Jones Jnr
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Register Reference Instructions | Computer Science
Register Reference Instructions | Computer ScienceRegister Reference Instructions | Computer Science
Register Reference Instructions | Computer ScienceTransweb Global Inc
 

What's hot (20)

Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Timing and-control-unit
Timing and-control-unitTiming and-control-unit
Timing and-control-unit
 
Cache memory
Cache memoryCache memory
Cache memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Memory management
Memory managementMemory management
Memory management
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208
 
memory hierarchy
memory hierarchymemory hierarchy
memory hierarchy
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Memory management
Memory managementMemory management
Memory management
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Memory management
Memory managementMemory management
Memory management
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage Systems
 
Cache memory
Cache memoryCache memory
Cache memory
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Register Reference Instructions | Computer Science
Register Reference Instructions | Computer ScienceRegister Reference Instructions | Computer Science
Register Reference Instructions | Computer Science
 

Viewers also liked

Direct memory access
Direct memory accessDirect memory access
Direct memory accessshubham kuwar
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipeliningTech_MX
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInteX Research Lab
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemSara Ali
 
Direct Memory Access(DMA)
Direct Memory Access(DMA)Direct Memory Access(DMA)
Direct Memory Access(DMA)Page Maker
 

Viewers also liked (7)

Direct memory access
Direct memory accessDirect memory access
Direct memory access
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
pipelining
pipeliningpipelining
pipelining
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Direct Memory Access(DMA)
Direct Memory Access(DMA)Direct Memory Access(DMA)
Direct Memory Access(DMA)
 

Similar to Virtual memory

virtual-memory-130126022841-phpapp01.pdf
virtual-memory-130126022841-phpapp01.pdfvirtual-memory-130126022841-phpapp01.pdf
virtual-memory-130126022841-phpapp01.pdfry54321288
 
Virtual Memory in Operating System
Virtual Memory in Operating SystemVirtual Memory in Operating System
Virtual Memory in Operating SystemMeghaj Mallick
 
virtualmemory-111228090333-phpapp02 (1).pdf
virtualmemory-111228090333-phpapp02 (1).pdfvirtualmemory-111228090333-phpapp02 (1).pdf
virtualmemory-111228090333-phpapp02 (1).pdfArchanaPandiyan
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual MemoryArchith777
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryvampugani
 
virtual memory.ppt
virtual memory.pptvirtual memory.ppt
virtual memory.pptsuryansh85
 
Chapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptChapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptMonirJihad1
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.pptPratikBose10
 
Power Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptPower Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptRahulRaj395610
 
Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementkazim Hussain
 
Virtual Memory in Windows
Virtual Memory in Windows Virtual Memory in Windows
Virtual Memory in Windows HanzlaRafique
 
CSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual MemoryCSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual Memoryghayour abbas
 
Computer architecture ppt
Computer architecture pptComputer architecture ppt
Computer architecture pptShishu
 

Similar to Virtual memory (20)

virtual-memory-130126022841-phpapp01.pdf
virtual-memory-130126022841-phpapp01.pdfvirtual-memory-130126022841-phpapp01.pdf
virtual-memory-130126022841-phpapp01.pdf
 
Virtual Memory in Operating System
Virtual Memory in Operating SystemVirtual Memory in Operating System
Virtual Memory in Operating System
 
virtualmemory-111228090333-phpapp02 (1).pdf
virtualmemory-111228090333-phpapp02 (1).pdfvirtualmemory-111228090333-phpapp02 (1).pdf
virtualmemory-111228090333-phpapp02 (1).pdf
 
Virtual memory ppts
Virtual memory pptsVirtual memory ppts
Virtual memory ppts
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
virtual memory.ppt
virtual memory.pptvirtual memory.ppt
virtual memory.ppt
 
Chapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptChapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.ppt
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.ppt
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.ppt
 
Power Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptPower Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.ppt
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory management
 
Virtual Memory in Windows
Virtual Memory in Windows Virtual Memory in Windows
Virtual Memory in Windows
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
CSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual MemoryCSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual Memory
 
Computer architecture ppt
Computer architecture pptComputer architecture ppt
Computer architecture ppt
 

More from Anuj Modi

Android Technology
Android TechnologyAndroid Technology
Android TechnologyAnuj Modi
 
Synchronous and-asynchronous-data-transfer
Synchronous and-asynchronous-data-transferSynchronous and-asynchronous-data-transfer
Synchronous and-asynchronous-data-transferAnuj Modi
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-busAnuj Modi
 
Ram and-rom-chips
Ram and-rom-chipsRam and-rom-chips
Ram and-rom-chipsAnuj Modi
 
Computer instructions
Computer instructionsComputer instructions
Computer instructionsAnuj Modi
 
HTML Lesson 5-insert-and-align-graphics
HTML Lesson 5-insert-and-align-graphicsHTML Lesson 5-insert-and-align-graphics
HTML Lesson 5-insert-and-align-graphicsAnuj Modi
 
HTML Lesson 2-format-pages-and-text
HTML Lesson 2-format-pages-and-textHTML Lesson 2-format-pages-and-text
HTML Lesson 2-format-pages-and-textAnuj Modi
 
HTML Lesson 1-create-a-home-page
HTML Lesson 1-create-a-home-pageHTML Lesson 1-create-a-home-page
HTML Lesson 1-create-a-home-pageAnuj Modi
 
Introduction to-dbms
Introduction to-dbmsIntroduction to-dbms
Introduction to-dbmsAnuj Modi
 
Architecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceArchitecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceAnuj Modi
 
Central Processing Unit User View
Central Processing Unit User ViewCentral Processing Unit User View
Central Processing Unit User ViewAnuj Modi
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data StructureAnuj Modi
 

More from Anuj Modi (17)

Android Technology
Android TechnologyAndroid Technology
Android Technology
 
Synchronous and-asynchronous-data-transfer
Synchronous and-asynchronous-data-transferSynchronous and-asynchronous-data-transfer
Synchronous and-asynchronous-data-transfer
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-bus
 
Ram and-rom-chips
Ram and-rom-chipsRam and-rom-chips
Ram and-rom-chips
 
Memory
MemoryMemory
Memory
 
Computer instructions
Computer instructionsComputer instructions
Computer instructions
 
HTML Lesson 5-insert-and-align-graphics
HTML Lesson 5-insert-and-align-graphicsHTML Lesson 5-insert-and-align-graphics
HTML Lesson 5-insert-and-align-graphics
 
HTML Lesson 2-format-pages-and-text
HTML Lesson 2-format-pages-and-textHTML Lesson 2-format-pages-and-text
HTML Lesson 2-format-pages-and-text
 
HTML Lesson 1-create-a-home-page
HTML Lesson 1-create-a-home-pageHTML Lesson 1-create-a-home-page
HTML Lesson 1-create-a-home-page
 
Introduction to-dbms
Introduction to-dbmsIntroduction to-dbms
Introduction to-dbms
 
DBA
DBADBA
DBA
 
Data models
Data modelsData models
Data models
 
Architecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceArchitecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independence
 
Central Processing Unit User View
Central Processing Unit User ViewCentral Processing Unit User View
Central Processing Unit User View
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 

Virtual memory

  • 1. VIRTUAL MEMORY Maninder Kaur professormaninder@gmail.com 1 www.eazynotes.com 24-Nov-2010
  • 2. What is Virtual Memory? The term virtual memory refers to something which appears to be present but actually it is not. The virtual memory technique allows users to use more memory for a program than the real memory of a computer. So, virtual memory is the concept that gives the illusion to the user that they will have main memory equal to the capacity of secondary storage media. 2 www.eazynotes.com 24-Nov-2010
  • 3. Concept of Virtual Memory  A programmer can write a program which requires more memory space than the capacity of the main memory. Such a program is executed by virtual memory technique.  The program is stored in the secondary memory. The memory management unit (MMU) transfers the currently needed part of the program from the secondary memory to the main memory for execution.   This to and fro movement of instructions and data (parts of a program) between the main memory and the secondary memory is called Swapping. 3 www.eazynotes.com 24-Nov-2010
  • 4. Address Space And Memory Space Virtual address is the address used by the programmer and the set of such addresses is called the address space or virtual memory. An address in main memory is called a location or physical address. The set of such locations in main memory is called the memory space or physical memory. 4 www.eazynotes.com 24-Nov-2010
  • 5. Virtual Memory 5 www.eazynotes.com 24-Nov-2010
  • 6. Virtual Memory (cont.) 1. CPU generated logical address consisting of a logical page number plus the location within that page (x). 2. It must be mapped onto an actual (physical) main memory address by the operating system using mapper. 3. If the page is present in the main memory, CPU gets the requires data from the main memory. 4. If the mapper detects that the requested page is not present in main memory, a page fault occurs and the page must be read from secondary storage (4, 5) into a page frame in main memory. 6 www.eazynotes.com 24-Nov-2010
  • 7. Address Mapping Using Memory Mapping Page Table  When the requested page is not available in the main memory, we can say that a page fault have been occurred in the main memory.  Then the virtual address generated by the CPU is used to take out the requested page from the secondary storage media to the main memory to remove this page fault.  If empty page frame is not available, then a page must be removed from page frame in main memory. 7 www.eazynotes.com 24-Nov-2010
  • 8. Page Replacement Algorithms In a computer operating system that uses paging for virtual memory management, page replacement algorithms decide which memory pages to page out (swap out, write to disk) when a page of memory needs to be allocated. Paging happens when a page fault occurs and a free page cannot be used to satisfy the allocation, either because there are none, or because the number of free pages is lower than some threshold. 8 www.eazynotes.com 24-Nov-2010
  • 9. First - In - First - Out (FIFO)  First-in-first-out is very easy to implement. The FIFO algorithm selects the page for replacement that has been in memory the longest time.  When a new page must be loaded, the page recently brought in is removed. The page to be removed is easily determined because its identification number is at the top of the FIFO stack.  The FIFO replacement policy has the advantage of being easy to implement.  It has the disadvantage that under certain circumstances pages are removed and loaded from memory too frequently. 9 www.eazynotes.com 24-Nov-2010
  • 10. FIFO Algorithm  Consider a paging system having capacity of 3 pages. The execution of a program requires references to five distinct pages P1, P2, P3, P4 and P5. The pages are executed in the following sequence:  P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2 10 www.eazynotes.com 24-Nov-2010
  • 11. Least Recently Used (LRU)  The least recently used page (LRU) replacement algorithm keeps track of page usage over a short period of time.  The LRU algorithm can be implemented by associating a counter with every page that is in main memory.  When a page is referenced, its associated counter is set to 0. At fixed intervals of time, the counters associated with all pages presently in memory are incremented by 1.  The least recently used page is the page with the highest count. The counters are often called aging registers, as their count indicates their age, that is, how long their associated pages have been referenced. 11 www.eazynotes.com 24-Nov-2010
  • 12. LRU Algorithm  Consider a paging system having capacity of 3 pages. The execution of a program requires references to five distinct pages P1, P2, P3, P4 and P5. The pages are executed in the following sequence:  P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2 12 www.eazynotes.com 24-Nov-2010
  • 13. Optimal (OPT)  The optimal policy selects that page for replacement for which the time to the next reference is longest.  This algorithm results in fewest number of page faults. But, this algorithm is impossible to implement.  At the time of page fault , the operating system has no way of knowing when each of the pages will be referenced next. However , it does serve as a standard against which to judge other algorithms. 13 www.eazynotes.com 24-Nov-2010
  • 14. Optimal (OPT) Consider a paging system having capacity of 3 pages. The execution of a program requires references to five distinct pages P 1, P2, P3, P4 and P5. The pages are executed in the following sequence: P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2 14 www.eazynotes.com 24-Nov-2010
  • 15. 15