Memory is a hardware device that is used to store the information either temporary or permanently. In this article, I have discussed the differences between virtual and cache memory. A Cache memory is a high-speed memory which is used to reduce the access time for data. On the other hands, Virtual memory is not exactly a physical memory it is a technique which extends the capacity of the main memory beyond its limit.
The major difference between virtual memory and the cache memory is that a virtual memory allows a user to execute programs that are larger than the main memory whereas, cache memory allows the quicker access to the data which has been recently used. We will discuss some more differences with the help of comparison chart shown below.
Content: Virtual Vs Cache Memory
Comparison Chart
BASIS FOR COMPARISON | VIRTUAL MEMORY | CACHED MEMORY |
---|---|---|
Basic | Virtual memory extends the capacity of main memory for the user. | Cache memory fastens the data accessing speed of CPU. |
Nature | Virtual memory is technique. | Cache memory is a storage unit. |
Function | Virtual memory allows execution of the program that is larger than the main memory. | Cache memory stores the copies of original data that has been recently used. |
Memory management | Virtual memory is managed by the operating system. | Cache memory is fully managed by the hardware. |
Size | Virtual memory is far larger than cached memory. | Cache memory has bounded size. |
Mapping | Virtual memory requires mapping structures to map virtual address to physical address. | No mapping structures are required as such in a cache memory. |
Definition of Virtual Memory
Virtual memory is not exactly a physical memory of a computer instead it’s a technique that allows the execution of a large program that may not be completely placed in the main memory. It enables the programmer to execute the programs larger than the main memory.
Now let us understand how does the virtual memory works? The program has its virtual memory address which is divided into a number of pages. The main memory is also divided into a number of pages. Now, as we can see the virtual address of a program is larger than the available main memory. So memory map is used to map the virtual address to the main memory.
Page 0, 1, 2, gets mapped in main memory and the main memory fills up. Now, when page 3 of virtual memory asks for space in main memory, the oldest placed page i.e. page 0 get transferred to the hard disk and evacuates the place for page 3, in main memory and the process goes on. In case the page 0 is again needed, then again the oldest placed page at that time is transferred to hard disk making the place for page 0.
If the two programs need same data, placed in main memory, the memory mapping unit allows both the programs to share the same address space in main memory where the shared data is stored. This makes sharing of files easy.
The benefits of virtual memory are:
- The programs are no longer constrained by the limit of main memory.
- Virtual memory increases the degree of multiprogramming.
- Increases CPU utilization.
- The less I/O unit will require to load or to swap programs in the memory.
But there is a drawback of virtual memory, placing more pages of a program in hard disk will slow down the performance as accessing the data from hard disk takes more time in comparison to accessing data from main memory.
Definition of Cache Memory
Unlike virtual memory, Cache is a storage device implemented on the processor itself. It carries the copies of original data that has been accessed recently. The original data may be placed in the main memory or a secondary memory. The cache memory fastens the accessing speed of data, but how? Let’s understand.
We can say that the accessing speed of CPU is limited to the accessing speed of main memory. Whenever a program is to be executed by the processor, it fetches it from main memory. If a copy of the program is already present in the cache implemented on the processor. The process would be able to access that data faster which will result in faster execution.
Key Differences Between Virtual and Cache Memory
- Virtual memory extends the capacity of main memory virtually for the user. However, the cache memory makes the accessing of data faster for CPU.
- Cache is a memory storage unit whereas as the Virtual memory is a technique.
- Virtual memory enables the executions of the program that larger than the main memory.On the other hands, cache memory stores the copies of original data that were used recently.
- Virtual memory management is done by the operating system. On the other hands, cache memory management is done by the hardware.
- Virtual memory is far larger than the cached memory in size.
- Virtual memory technique requires the mapping structures to map virtual address to physical address whereas, cache memory does not require any mapping structures.
Conclusion:
The Virtual memory is a technique to expand the capacity of main memory virtually for the users. The cache memory is a storage unit that stores the recently accessed data which enables the CPU to access it faster.
No comments:
Post a Comment
commnet here