Thanks to visit codestin.com
Credit goes to www.scribd.com

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

Virtual Memory

Uploaded by

r6810088
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)
74 views4 pages

Virtual Memory

Uploaded by

r6810088
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
You are on page 1/ 4

What is Virtual Memory?

Virtual memory is a memory management technique used by operating


systems to give the appearance of a large, continuous block of memory to
applications, even if the physical memory (RAM) is limited.
It allows the system to compensate for physical memory shortages, enabling
larger applications to run on systems with less RAM.

The size of virtual storage is limited by the addressing scheme of the


computer system and the amount of secondary memory available not by the
actual number of main storage locations.

Working of Virtual Memory


It is a technique that is implemented using both hardware and software. It
maps memory addresses used by a program, called virtual addresses, into
physical addresses in computer memory.
it is not necessary that all the pages or segments are present in the main
memory during execution. This means that the required pages need to be
loaded into memory whenever required. Virtual memory is implemented
using Demand Paging or Demand Segmentation.

Paging
Paging divides memory into small fixed-size blocks called pages. When the
computer runs out of RAM, pages that aren’t currently in use are moved to
the hard drive, into an area called a swap file. The swap file acts as an
extension of RAM. When a page is needed again, it is swapped back into
RAM, a process known as page swapping. This ensures that the operating
system (OS) and applications have enough memory to run.
Demand Paging: The process of loading the page into memory on demand
(whenever a page fault occurs) is known as demand paging.

Memory Management Unit


The Memory Management Unit (MMU) is responsible for converting logical addresses to
physical addresses. The physical address refers to the actual address of a frame in
which each page will be stored, whereas the logical address refers to the address
that is generated by the CPU for each page.
When the CPU accesses a page using its logical address, the OS must first collect the
physical address in order to access that page physically. There are two elements to the
logical address:

 Page number
 Offset

The OS’s memory management unit must convert the page numbers to the frame
numbers.

Examples
Let’s say the CPU requests the 10th word of the 4th page of process P3 in the image
above. Because page number 4 of process P1 is stored at frame number 9, the physical
address will be returned as the 10th word of the 9th frame.

Let’s consider another example:

 If the physical address is 12 bits, then the physical address space would be 4 K words
 If the logical address is 13 bits, then the logical address space would be 8 K words
 If the page size is equal to the frame size, which is equal to 1 K words (assumption),

Then:

The address generated by the CPU is divided into the following:

 Page offset(d): It refers to the number of bits necessary to represent a certain word on a
page, page size in Logical Address Space, or page word number or page offset.

 Page number(p): It is the number of bits needed to represent the pages in the Logical
Address Space or the page number.

The Physical Address is divided into the following:

 Frame offset(d): It refers to the number of bits necessary to represent a certain word in a
frame, or the Physical Address Space frame size, the word number of a frame, or the frame
offset.

 Frame number(f): It’s the number of bits needed to indicate a frame of the Physical Address
Space or a frame number.
Dedicated registers can be used to implement the page table in hardware. However,
using a register for the page table is only useful if the page table is tiny. We can employ
TLB (translation look-aside buffer), a particular, tiny, fast look-up hardware cache if the
page table has a significant number of entries.

 The TLB is a high-speed, associative memory.


 LB entries are made up of two parts: a value and a tag.
 When this memory is accessed, an item is compared to all tags at the same time.
 If the object is located, the value associated with it is returned.
m = main memory access time

In case the page table is kept in the main memory,

then the effective access time would be = m(page table) + m(page in page table)

You might also like