0% found this document useful (0 votes)
21 views4 pages

Explain Virtual Memory

Virtual memory is a technique that allows the main memory to act as a cache for secondary storage, enabling efficient and safe sharing of memory among multiple programs. It protects programs by ensuring they can only access assigned memory portions and implements address translation for protection and isolation. Virtual memory also allows user programs to exceed primary memory size by dividing programs into pages, simplifying loading and execution through relocation and addressing mechanisms.

Uploaded by

divyamaster63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Explain Virtual Memory

Virtual memory is a technique that allows the main memory to act as a cache for secondary storage, enabling efficient and safe sharing of memory among multiple programs. It protects programs by ensuring they can only access assigned memory portions and implements address translation for protection and isolation. Virtual memory also allows user programs to exceed primary memory size by dividing programs into pages, simplifying loading and execution through relocation and addressing mechanisms.

Uploaded by

divyamaster63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Explain Virtual Memory

The main memory can act as a “cache” for the secondary storage this technique is called virtual
memory.

Need for Virtual Memory

 To allow efficient and safe sharing of memory among multiple programs.


 Virtual memory role is to protect and ensuring that a program can only read and write the
portions of main memory that have been assigned to it
 Virtual memory implements the translation of a program’s address space to physical
addresses. This translation process enforces protection of a program’s address space

Protection

 A set of mechanisms for ensuring that multiple processes sharing the processor, memory,
or I/O devices cannot interfere, intentionally or unintentionally, with one another by
reading or writing each other’s data.
 It is also used to isolate OS process and user process.

User program

 Virtual memory allows a single user program to exceed the size of primary memory.
 Programmers divided programs into pieces and then identified the pieces that were
mutually exclusive.
 User program control ensures that program never access overlays that are not loaded and
these overlays never exceed the allocated size of the memory.

Page, Page Fault, Address Translation

 A virtual memory block is called a page, and a virtual memory miss is called a page
fault.
 The processor produces a virtual address, which is translated by a combination of
hardware and soft ware to a physical address, which intern can be used to access main
memory. This process is called address mapping or address translation.

Mapping from a virtual to a physical address


Address Translation

 Virtual memory also simplifies loading the program for execution by providing
relocation.
 This relocation allows us to load the program anywhere in main memory.
 All virtual memory systems uses relocation, the program is divided as a set of fixed-size
blocks (pages), it eliminates the need to find a contiguous block of memory for a
program
 instead, the operating system need only find a sufficient number of pages in main
memory.
 In virtual memory, the address is broken into a virtual page number and a page off
set. (refer previous diagram)
 The physical page number constitutes the upper portion of the physical address, while
the page off set, which is not changed, constitutes the lower portion.
 The number of bits in the page off set field determines the page size.
 A larger number of virtual pages than physical pages is essentially the concept to show
unbounded amount of virtual memory.
 Page fault leads to enormous miss penalty. (millions of clock cycles)

To Design a virtual memory system


1. 1. Pages should be large enough to reduce high access time. Sizes from 4 KiB to 16 KiB
are typical today (depends on computer types).
2. The primary technique used here is to allow fully associative placement of pages in
memory.
3. Page faults can be handled in software because the overhead will be small compared to
the disk access time. (it reduces miss penalty)
4. Write-through will not work for virtual memory, since writes take too long. Instead,
virtual memory systems use write-back.

You might also like