0% found this document useful (0 votes)
1 views

Virtual Memory

Uploaded by

designography02
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Virtual Memory

Uploaded by

designography02
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Operating System - Virtual Memory

 A computer can address more memory than the amount physically installed
on the system. This extra memory is actually called virtual memory and it is
a section of a hard disk that's set up to emulate the computer's RAM.
 The main visible advantage of this scheme is that programs can be larger
than physical memory. Virtual memory serves two purposes. First, it allows
us to extend the use of physical memory by using disk. Second, it allows us
to have memory protection, because each virtual address is translated to a
physical address.
 Following are the situations, when entire program is not required to be
loaded fully in main memory.
a. User written error handling routines are used only when an error occurred in
the data or computation.
b. Certain options and features of a program may be used rarely.
c. Many tables are assigned a fixed amount of address space even though only
a small amount of the table is actually used.
d. The ability to execute a program that is only partially in memory would
counter many benefits.
e. Less number of I/O would be needed to load or swap each user program into
memory.
f. A program would no longer be constrained by the amount of physical memory
that is available.
g. Each user program could take less physical memory, more programs could
be run the same time, with a corresponding increase in CPU utilization and
throughput.
h. Modern microprocessors intended for general-purpose use, a memory
management unit, or MMU, is built into the hardware. The MMU's job is to
translate virtual addresses into physical addresses. A basic example is given
below −
Virtual memory is commonly implemented by demand paging. It can also be
implemented in a segmentation system. Demand segmentation can also be used to
provide virtual memory.

Demand Paging
 A demand paging system is quite similar to a paging system with swapping
where processes reside in secondary memory and pages are loaded only
on demand, not in advance.
 When a context switch occurs, the operating system does not copy any of
the old program’s pages out to the disk or any of the new program’s pages
into the main memory Instead, it just begins executing the new program after
loading the first page and fetches that program’s pages as they are
referenced.
While executing a program, if the program references a page which is not available
in the main memory because it was swapped out a little ago, the processor treats
this invalid memory reference as a page fault and transfers control from the
program to the operating system to demand the page back into the memory.
Advantages
Following are the advantages of Demand Paging −

 Large virtual memory.


 More efficient use of memory.
 There is no limit on degree of multiprogramming.
Disadvantages
 Number of tables and the amount of processor overhead for handling page
interrupts are greater than in the case of the simple paged management
techniques.

You might also like