SlideShare a Scribd company logo
Virtual Memory
Lecture Slides
By
Virtual Memory
History
 virtual memory was developed in
approximately 1959 – 1962, at the University
of Manchester for the Atlas Computer,
completed in 1962.
 In 1961, Burroughs released the B5000, the
first commercial computer with virtual memory.
Virtual Memory
OS and hardware produce illusion of a disk as fast as main memory
 Virtual memory as an alternate set of memory addresses.
 Programs use these virtual addresses rather than real addresses to store instructions and
data.
 When the program is actually executed, the virtual addresses are converted into real
memory addresses.
 Process runs when not all pages are loaded in memory
 Only keep referenced pages in main memory
 Keep unreferenced pages on slower, cheaper backing store (disk)
 Bring pages from disk to memory when necessary.
 Virtual memory is imaginary memory: it gives you the
illusion of a memory arrangement that’s not physically
there.
 The simple tactic of breaking a process up into pages led to
the development of important concept : Virtual memory
Virtual Memory ……(cont’d)
 The basic idea of Virtual Memory is to keep only those
parts of the program currently in use in the memory and
the rest on the disk drive.
 For example: a 16M program can run on a 4M machine by
carefully choosing which 4M to keep in memory at each
instant, with pieces of the program being swapped
between disk and memory as needed.
 It can work in a Multiprogramming system, with bits and
pieces of many programs brought to the memory at once
by the Operating System. While a program is waiting for
part of itself to be brought in, it is waiting for I/O and
cannot run, so the CPU can be given to another process,
the same way as for any other multiprogramming
system.
Advantages
 You can run more applications at once.
 Allows you to fit many large programs into a relatively small RAM.
 You don't have to buy more memory RAM
 VM supports Swapping.
 Common data or code may be shared to save memory.
 Process need not be in memory as a whole , Only part of a program
needs to be loaded into memory.
 Process may even be larger than all of physical memory.
 Data / code can be read from disk as needed.
 Code can be placed anywhere in physical memory without
relocation.
 More processes can be maintained in Main Memory which increases
effective use of CPU.
 Don't need to break program into fragments to accommodate
memory limitations
Why is it needed….
 Before the development of the virtual memory
technique, programmers in the 1940s and 1950s
had to manage directly two-level storage such as
main memory or ram and secondary memory in
the form of hard disks or earlier, magnetic drums.
 Enlarge the address space, the set of addresses a
program can utilize.
 Virtual memory might contain twice as many
addresses as main memory.
How does it work…
 To facilitate copying virtual memory into real
memory, the operating system divides virtual
memory into pages, each of which contains a
fixed number of addresses.
 Each page is stored on a disk until it is
needed.
 When the page is needed, the operating
system copies it from disk to main memory,
translating the virtual addresses into real
addresses.
Paging
• Extends partition idea by dividing up both memory and
processes into equal size pieces
• Split memory into equal sized, small chunks – called page
frames
• Split programs (processes) into equal sized small chunks -
called 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
• Each process has a list of frames that it is using, called a page
table, stored in the PCB
• Paging Use page table to keep track
Allocation of Free Frames
Logical and Physical Addresses -Paging
Demand paging
• Fetch Policy Determines when a page should be brought
into main memory. One of common policies is Demand
paging
• Refines paging by demand paging - each page of a
process is brought in only when needed, that is, on
demand
• Demand paging
– Do not require all pages of a process in memory
– Bring in pages as required
– Less I/O needed
– Less memory needed
– Faster response
– More users „
Page fault
 If a page is needed which is not in memory, a page fault is
triggered, which requires an I/O operation
• 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 fault……(cont’d)
 An interrupt to the software raised by the hardware
when a program accesses a page that is not mapped in
physical memory.
 when a program accesses a memory location in its
memory and the page corresponding to that memory is
not loaded
 when a program accesses a memory location in its
memory and the program does not have privileges to
access the page corresponding to that memory.
Problems faced with Virtual Memory implementation:
 Thrashing
 Possibly large page table
Solution:
 Use multilevel page tables.
 Use TLB (Translation Lookaside Buffer) or some ti
mes called ‘Associative Memory’.
 Page fault rates can be reduced by using a Wo
rking Set Model’ approach or a ‘Prepaging’ app
roach.
 Increase RAM!
Thrashing
 Pages currently in memory may have to be replaced. In some
situations this can lead to thrashing, where the processor
spends too much time swapping the same pages in and out
Thrashing
 Swapping out a piece of a process just before that piece is
needed
 The processor spends most of its time swapping pieces rather
than executing user instructions
 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
Page Table Structure
 Each process has a list of frames that it is using, called a page table, stored in the
PCB
 Page Table Structure is a Basic mechanism for reading a word from memory
involves using a page table to translate :
• a virtual address - page number and offset
into
• a physical address - frame number and offset
 Page tables may be very large
• they cannot be stored in registers
• they are often stored in virtual memory (so are subject to paging!)
• sometimes a page directory is used to organize many pages of page tables
,Pentium uses such a two-level structure
• sometimes an inverted page table structure is used to map a virtual address
to a real address using a hash on the page number of the virtual address
AS/400 and PowerPC use this idea.
18
Page Table Structure
 Page tables are variable in length (depends
on process size)
 then must be in main memory instead of
registers
 A single register holds the starting
physical address of the page table of the
currently running process
Page Tables
Memory-resident
page table
(physical page
or disk address) Physical Memory
Disk Storage
(swap file or
regular file system file)
Valid
1
1
1
1
1
1
1
0
0
0
Virtual Page
Number
Inverted Page Table Structure
Translation Lookaside Buffer )TLB)
• Each virtual memory reference can causes two
physical memory access
One to fetch the appropriate page table entry
One to fetch the desired data
• To overcome this problem a high-speed cache is set
up for page table entries
– Called a Translation Lookaside Buffer (TLB)
• TLB is a special cache, just for page table entries
• Contains page table entries that have been most
recently used
Translation Lookaside Buffer
• Given a virtual address, processor examines
the TLB
• If page table entry is present (TLB hit), the
frame number is retrieved and the real
address is formed
• If page table entry is not found in the TLB
(TLB miss), the page number is used to index
the process page table
Translation Lookaside Buffer
• First checks if page is already in main
memory
– If not in main memory a page fault is issued
• The TLB is updated to include the new page
entry
TLB Operation
TLB and Cache Operation
Segmentation
• Another way in which addressable memory can
be subdivided, known as Segmentation
• May be unequal, dynamic size
• 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
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 data among processes
• Lends itself to protection
• Some systems combine segmentation with
paging
Combined Paging and Segmentation
• Paging is transparent to the programmer
• Segmentation is visible to the programmer
• Each segment is broken into fixed-size pages.
Computer architecture virtual memory
Thank yo
u
for liste
ning

More Related Content

PPS
Virtual memory
PPTX
CULTURE OF ANDHRA PRADESH BY PAVANSAI
PPS
Cache memory
PPTX
Daily Expense Tracker
PPTX
Virtual Memory
PPTX
resume builder.pptx
PPTX
Magnitude comparator
Virtual memory
CULTURE OF ANDHRA PRADESH BY PAVANSAI
Cache memory
Daily Expense Tracker
Virtual Memory
resume builder.pptx
Magnitude comparator

What's hot (20)

PPTX
Memory organization (Computer architecture)
PDF
Addressing modes in computer organization
PPTX
General register organization (computer organization)
PPTX
ADDRESSING MODES
PPTX
DMA and DMA controller
PPT
Paging.ppt
PPTX
Stack organization
DOCX
Control Units : Microprogrammed and Hardwired:control unit
PPTX
bus and memory tranfer (computer organaization)
PPTX
INTER PROCESS COMMUNICATION (IPC).pptx
PPTX
Input output interface
PPTX
Direct memory access (dma)
PPTX
Instruction Execution Cycle
PPT
Instruction Set Architecture (ISA)
PPTX
Cache Memory
PPTX
PPTX
Cache memory
PPTX
Demand paging
PPTX
Memory mapped I/O and Isolated I/O
PPTX
File allocation methods (1)
Memory organization (Computer architecture)
Addressing modes in computer organization
General register organization (computer organization)
ADDRESSING MODES
DMA and DMA controller
Paging.ppt
Stack organization
Control Units : Microprogrammed and Hardwired:control unit
bus and memory tranfer (computer organaization)
INTER PROCESS COMMUNICATION (IPC).pptx
Input output interface
Direct memory access (dma)
Instruction Execution Cycle
Instruction Set Architecture (ISA)
Cache Memory
Cache memory
Demand paging
Memory mapped I/O and Isolated I/O
File allocation methods (1)
Ad

Similar to Computer architecture virtual memory (20)

PPTX
coafinal1-copy-150430204758-conversion-gate01.pptx
PPTX
operating system virtual memory and logical memory
PPT
Mca ii os u-4 memory management
PPTX
Abhaycavirtual memory and the pagehit.pptx
PPTX
Virtual Memory Managementddddddddffffffffffffff.pptx
PDF
CSI-503 - 9. Virtual Memory
PPT
memory management and Virtual Memory.ppt
PPT
Cache replacement policies,cache miss,writingtechniques
PDF
CH09.pdf
PPT
Virtual memory - Demand Paging
PPT
Power Point Presentation on Virtual Memory.ppt
PPTX
Os Module 4_Virtual Memory Management.pptx
PPTX
Lecture 8- Virtual Memory Final.pptx
PPTX
Virtual memory managment
PDF
Virtual memory
PPTX
16. PagingImplementIssused.pptx
PDF
Virtual memory
PPTX
Paging +Algorithem+Segmentation+memory management
DOCX
virtual memory
PPT
NOV11 virtual memory.ppt
coafinal1-copy-150430204758-conversion-gate01.pptx
operating system virtual memory and logical memory
Mca ii os u-4 memory management
Abhaycavirtual memory and the pagehit.pptx
Virtual Memory Managementddddddddffffffffffffff.pptx
CSI-503 - 9. Virtual Memory
memory management and Virtual Memory.ppt
Cache replacement policies,cache miss,writingtechniques
CH09.pdf
Virtual memory - Demand Paging
Power Point Presentation on Virtual Memory.ppt
Os Module 4_Virtual Memory Management.pptx
Lecture 8- Virtual Memory Final.pptx
Virtual memory managment
Virtual memory
16. PagingImplementIssused.pptx
Virtual memory
Paging +Algorithem+Segmentation+memory management
virtual memory
NOV11 virtual memory.ppt
Ad

More from Mazin Alwaaly (20)

PPTX
Pattern recognition voice biometrics
PPTX
Pattern recognition palm print authentication system
PPTX
Pattern recognition on line signature
PPTX
Pattern recognition multi biometrics using face and ear
PPTX
Pattern recognition IRIS recognition
PPT
Pattern recognition hand vascular pattern recognition
PPTX
Pattern recognition Hand Geometry
PPTX
Pattern recognition forensic dental identification
PPT
Pattern recognition fingerprints
PPTX
Pattern recognition facial recognition
PPTX
Pattern recognition ear as a biometric
PPTX
Pattern recognition 3d face recognition
PPTX
Multimedia multimedia over wireless and mobile networks
PPT
Multimedia network services and protocols for multimedia communications
PPTX
Multimedia content based retrieval in digital libraries
PPTX
Multimedia lossy compression algorithms
PPTX
Multimedia lossless compression algorithms
PPTX
Multimedia basic video compression techniques
PPT
Multimedia image compression standards
PPTX
Multimedia fundamental concepts in video
Pattern recognition voice biometrics
Pattern recognition palm print authentication system
Pattern recognition on line signature
Pattern recognition multi biometrics using face and ear
Pattern recognition IRIS recognition
Pattern recognition hand vascular pattern recognition
Pattern recognition Hand Geometry
Pattern recognition forensic dental identification
Pattern recognition fingerprints
Pattern recognition facial recognition
Pattern recognition ear as a biometric
Pattern recognition 3d face recognition
Multimedia multimedia over wireless and mobile networks
Multimedia network services and protocols for multimedia communications
Multimedia content based retrieval in digital libraries
Multimedia lossy compression algorithms
Multimedia lossless compression algorithms
Multimedia basic video compression techniques
Multimedia image compression standards
Multimedia fundamental concepts in video

Recently uploaded (20)

PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PDF
Looking into the jet cone of the neutrino-associated very high-energy blazar ...
PPTX
The KM-GBF monitoring framework – status & key messages.pptx
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PDF
Placing the Near-Earth Object Impact Probability in Context
PPTX
BIOMOLECULES PPT........................
PDF
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
PPTX
famous lake in india and its disturibution and importance
PPTX
neck nodes and dissection types and lymph nodes levels
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PPTX
ECG_Course_Presentation د.محمد صقران ppt
PPTX
Vitamins & Minerals: Complete Guide to Functions, Food Sources, Deficiency Si...
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
PDF
Sciences of Europe No 170 (2025)
PDF
The scientific heritage No 166 (166) (2025)
PDF
CHAPTER 3 Cell Structures and Their Functions Lecture Outline.pdf
Classification Systems_TAXONOMY_SCIENCE8.pptx
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
Looking into the jet cone of the neutrino-associated very high-energy blazar ...
The KM-GBF monitoring framework – status & key messages.pptx
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
Biophysics 2.pdffffffffffffffffffffffffff
Phytochemical Investigation of Miliusa longipes.pdf
Placing the Near-Earth Object Impact Probability in Context
BIOMOLECULES PPT........................
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
famous lake in india and its disturibution and importance
neck nodes and dissection types and lymph nodes levels
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
ECG_Course_Presentation د.محمد صقران ppt
Vitamins & Minerals: Complete Guide to Functions, Food Sources, Deficiency Si...
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
Sciences of Europe No 170 (2025)
The scientific heritage No 166 (166) (2025)
CHAPTER 3 Cell Structures and Their Functions Lecture Outline.pdf

Computer architecture virtual memory

  • 3. History  virtual memory was developed in approximately 1959 – 1962, at the University of Manchester for the Atlas Computer, completed in 1962.  In 1961, Burroughs released the B5000, the first commercial computer with virtual memory.
  • 4. Virtual Memory OS and hardware produce illusion of a disk as fast as main memory  Virtual memory as an alternate set of memory addresses.  Programs use these virtual addresses rather than real addresses to store instructions and data.  When the program is actually executed, the virtual addresses are converted into real memory addresses.  Process runs when not all pages are loaded in memory  Only keep referenced pages in main memory  Keep unreferenced pages on slower, cheaper backing store (disk)  Bring pages from disk to memory when necessary.  Virtual memory is imaginary memory: it gives you the illusion of a memory arrangement that’s not physically there.  The simple tactic of breaking a process up into pages led to the development of important concept : Virtual memory
  • 5. Virtual Memory ……(cont’d)  The basic idea of Virtual Memory is to keep only those parts of the program currently in use in the memory and the rest on the disk drive.  For example: a 16M program can run on a 4M machine by carefully choosing which 4M to keep in memory at each instant, with pieces of the program being swapped between disk and memory as needed.  It can work in a Multiprogramming system, with bits and pieces of many programs brought to the memory at once by the Operating System. While a program is waiting for part of itself to be brought in, it is waiting for I/O and cannot run, so the CPU can be given to another process, the same way as for any other multiprogramming system.
  • 6. Advantages  You can run more applications at once.  Allows you to fit many large programs into a relatively small RAM.  You don't have to buy more memory RAM  VM supports Swapping.  Common data or code may be shared to save memory.  Process need not be in memory as a whole , Only part of a program needs to be loaded into memory.  Process may even be larger than all of physical memory.  Data / code can be read from disk as needed.  Code can be placed anywhere in physical memory without relocation.  More processes can be maintained in Main Memory which increases effective use of CPU.  Don't need to break program into fragments to accommodate memory limitations
  • 7. Why is it needed….  Before the development of the virtual memory technique, programmers in the 1940s and 1950s had to manage directly two-level storage such as main memory or ram and secondary memory in the form of hard disks or earlier, magnetic drums.  Enlarge the address space, the set of addresses a program can utilize.  Virtual memory might contain twice as many addresses as main memory.
  • 8. How does it work…  To facilitate copying virtual memory into real memory, the operating system divides virtual memory into pages, each of which contains a fixed number of addresses.  Each page is stored on a disk until it is needed.  When the page is needed, the operating system copies it from disk to main memory, translating the virtual addresses into real addresses.
  • 9. Paging • Extends partition idea by dividing up both memory and processes into equal size pieces • Split memory into equal sized, small chunks – called page frames • Split programs (processes) into equal sized small chunks - called 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 • Each process has a list of frames that it is using, called a page table, stored in the PCB • Paging Use page table to keep track
  • 11. Logical and Physical Addresses -Paging
  • 12. Demand paging • Fetch Policy Determines when a page should be brought into main memory. One of common policies is Demand paging • Refines paging by demand paging - each page of a process is brought in only when needed, that is, on demand • Demand paging – Do not require all pages of a process in memory – Bring in pages as required – Less I/O needed – Less memory needed – Faster response – More users „
  • 13. Page fault  If a page is needed which is not in memory, a page fault is triggered, which requires an I/O operation • 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
  • 14. Page fault……(cont’d)  An interrupt to the software raised by the hardware when a program accesses a page that is not mapped in physical memory.  when a program accesses a memory location in its memory and the page corresponding to that memory is not loaded  when a program accesses a memory location in its memory and the program does not have privileges to access the page corresponding to that memory.
  • 15. Problems faced with Virtual Memory implementation:  Thrashing  Possibly large page table Solution:  Use multilevel page tables.  Use TLB (Translation Lookaside Buffer) or some ti mes called ‘Associative Memory’.  Page fault rates can be reduced by using a Wo rking Set Model’ approach or a ‘Prepaging’ app roach.  Increase RAM!
  • 16. Thrashing  Pages currently in memory may have to be replaced. In some situations this can lead to thrashing, where the processor spends too much time swapping the same pages in and out Thrashing  Swapping out a piece of a process just before that piece is needed  The processor spends most of its time swapping pieces rather than executing user instructions  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
  • 17. Page Table Structure  Each process has a list of frames that it is using, called a page table, stored in the PCB  Page Table Structure is a Basic mechanism for reading a word from memory involves using a page table to translate : • a virtual address - page number and offset into • a physical address - frame number and offset  Page tables may be very large • they cannot be stored in registers • they are often stored in virtual memory (so are subject to paging!) • sometimes a page directory is used to organize many pages of page tables ,Pentium uses such a two-level structure • sometimes an inverted page table structure is used to map a virtual address to a real address using a hash on the page number of the virtual address AS/400 and PowerPC use this idea.
  • 18. 18 Page Table Structure  Page tables are variable in length (depends on process size)  then must be in main memory instead of registers  A single register holds the starting physical address of the page table of the currently running process
  • 19. Page Tables Memory-resident page table (physical page or disk address) Physical Memory Disk Storage (swap file or regular file system file) Valid 1 1 1 1 1 1 1 0 0 0 Virtual Page Number
  • 20. Inverted Page Table Structure
  • 21. Translation Lookaside Buffer )TLB) • Each virtual memory reference can causes two physical memory access One to fetch the appropriate page table entry One to fetch the desired data • To overcome this problem a high-speed cache is set up for page table entries – Called a Translation Lookaside Buffer (TLB) • TLB is a special cache, just for page table entries • Contains page table entries that have been most recently used
  • 22. Translation Lookaside Buffer • Given a virtual address, processor examines the TLB • If page table entry is present (TLB hit), the frame number is retrieved and the real address is formed • If page table entry is not found in the TLB (TLB miss), the page number is used to index the process page table
  • 23. Translation Lookaside Buffer • First checks if page is already in main memory – If not in main memory a page fault is issued • The TLB is updated to include the new page entry
  • 25. TLB and Cache Operation
  • 26. Segmentation • Another way in which addressable memory can be subdivided, known as Segmentation • May be unequal, dynamic size • 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
  • 27. 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 data among processes • Lends itself to protection • Some systems combine segmentation with paging
  • 28. Combined Paging and Segmentation • Paging is transparent to the programmer • Segmentation is visible to the programmer • Each segment is broken into fixed-size pages.