Page 137 - DCAP403_Operating System
P. 137
Operating System
Notes example, Windows but not DOS) in conjunction with the hardware. You can think of 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.
The purpose of virtual memory is to enlarge the address space, the set of addresses a program
can utilize.
Example: Virtual memory might contain twice as many addresses as main memory.
A program using all of virtual memory, therefore, would not be able to fit in main memory all at
once. Nevertheless, the computer could execute such a program by copying into main memory
those portions of the program needed at any given point during execution.
Figure 7.10: Virtual Memory
VIRTUAL MEMORY
2 MAIN MEMORY
CPU (present)
MAPPER page frames
3
1 page frame + x
(not presert) logical page 4
5
logical page + x
VIRTUAL ADDRESS
SECONDARY STORAGE
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.
The process of translating virtual addresses into real addresses is called mapping. The copying of
virtual pages from disk to main memory is known as paging or swapping.
Some physical memory is used to keep a list of references to the most recently accessed information
on an I/O (input/output) device, such as the hard disk. The optimization it provides, is that it
is faster to read the information from physical memory, than use the relevant I/O channel to get
that information. This is called caching. It is implemented inside the OS.
Task Why operating system need virtual memory? Discuss.
7.9 Demand Paging
As there is much less physical memory than virtual memory the operating system must be careful
that it does not use the physical memory inefficiently. One way to save physical memory is to
130 LOVELY PROFESSIONAL UNIVERSITY