System on Chip Architecture/Design : What is Virtual Memory.
-Aviral Mittal

Connect @ https://www.linkedin.com/in/avimit/

SITE HOME

What is Virtual Memory? A Very simple Explanation in Plain English.
Short answer is nothing. Its very surprizing that this name has been used as a misnomer since ages.
The name 'virtual memory' itself may give an undesired impression to someone hearing/reading it for the first time.
Factually there is nothing called virtual memory. Every memory address that a proessor generates must have a unique location in some physical memory.

So what is this misnomer called 'virtual memory'?
A computer system has a hierarchical memory structure, with the fastest and most expensive memories physically located close to the processor, and slowest and cheap memories physically located away from the processor. Example of fast memory is cache memory. Example of slow memory is Hard disk.
More examples of fast memories, fastest and smallest comes first : L1 Cache, L2 Cache, S-RAMs, D-RAMs.
More examples of slow memories: Flash Memory, PS-RAM memory, Hard Disk Drive.


Only a tiny fraction of the Hard-Disk storage can reside inside cache or SRAM or DRAM. This is because SRAM/DRAMs are very expensive (per MegaByte of storage), and hence smaller and Hard Disk storage is very cheap and hence quite large. Also the SRAM/DRAM are volatile memories, that means they loose their contents on power-off, while Hard-disk is non-volatile, means they retain contents upon power off.

When a processor accesses a location for example it issues a read command to an address (say A0), the data corresponding to that location (address), say D0 can be either in Cache, or DRAM or in the worst case in the Hard Disk. Note that at startup, i.e. immediately after power on, the D0 will always be in non-volatile memory, e.g. ROM, or a Hard Drive.

If the data D0 corresponding to Address A0, is present in Hard Disk Only, then this data, and also the data corresponding to all near by locations are fetched from Hard-disk into onchip RAMs and/or cache. The unit of the data transfer is called 'page'. i.e one page of worth data will be transferred into on-chip RAMs from the Hard Disk. Somehwere in this page the D0 corresponding to A0 must be present. Once the entire page has been transferred, the execution of the processor will be quite fast.

Now, they say the Hard-Disk is acting as a 'Virtual Memory' for the processor. Does the name 'virtual memory' makes any sense? No, not to me at least.

On-Chip RAMs can store multiple 'pages' of memory. So as long as the processor is issuing addresses which falls in any of those pages that are currently (at the time access is issued) residing in on-chip RAMs, the processor would work faster. But if the processor issues an address which does not fall in any of the on-chip pages currently in the RAMs, then a fetch cycle must start, and the corresponding page must be fetched from hard-disk and stored in on-chip RAMs. Of course, to make space for this page, an existing page in RAMs may have to be discarded. The processor may 'stall' for sometime, till the new page is avaialble, but thereafter it would again gain speed. On average, the page fetches are less frequent which means, the processor execution is made efficient and faster using this 'paging' scheme, while keeping the costs of memory storage checked.

They say by using his scheme of memory management, the processor is led to believe it has a lot more memory than actual memory, hence this scheme is termed as 'virtual memory'. Nope, there isn't any more memory than there actually is.

Hence 'Virtual Memory' is a scheme of memory management supported by a hierarchical structure of memories, which makes the processor run faster at a lower cost. But no memory is 'Virtual'. Every memory address has a physical presence in the system.



<= PREV                                     NEXT

Click Here to Make Comments or ask Questions
SITE HOME