Page 1 of 1

Difference between cache and virtual memory.

Posted: Tue May 17, 2016 3:25 pm
by Ramnath
Hi,

What is the difference between cache and virtual memory? Don't they just serve a very similar purpose? Can anyone of you please share your views on it?

Re: Difference between cache and virtual memory.

Posted: Tue May 17, 2016 4:06 pm
by enrico-sorichetti
Don't they just serve a very similar purpose?
NO
Can anyone of you please share your views on it?
for such questions personal views are irrelevant and most often wrong ...

start by trying to understand
cache to real storage relation (ram in PC jargon )
real storage(memory) to virtual storage relation

a good reading would be
http://www.redbooks.ibm.com/abstracts/sg246366.html

Re: Difference between cache and virtual memory.

Posted: Tue May 17, 2016 8:29 pm
by Robert Sample
The z13 overview at http://www-03.ibm.com/systems/data/flas ... _Final.pdf makes a big point about the L1, L2, L3, L4 caches.  L4 has 960 MB while the z13 can have up to 10 TB of memory.  Once you've read the reference enrico cited, you can look at this Powerpoint and see how differently cache and virtual memory are treated.

Re: Difference between cache and virtual memory.

Posted: Thu May 19, 2016 1:46 pm
by Ramnath
Thanks for the manual links.

Re: Difference between cache and virtual memory.

Posted: Sat Jun 25, 2016 6:56 pm
by Gerhard_Adam
The primary difference is that virtual memory is a concept, while cache memory is real, physical memory. As mentioned previously, the z13 has 4 levels of cache memory and then central storage [RAM]. The role of cache memory is to improve the access speed to instructions and data. Each core has a Level 1 [L1] cache from which instructions are processed and data is referenced.

When the system executes an instruction, everything must be available in the highest level cache to be acted on. The primary reason for this is speed. It takes about 600 machine cycles to retrieve something from RAM, so it is far too slow to keep pace with modern processor speeds. As a result, this information is staged up into the L1 cache for fast access.

The purpose of the L2, L3, and L4 caches is as more data comes into the L1 cache, these lower level caches ensure that the data gradually "drifts" back down to RAM. This way, if it is re-referenced it is at a higher level cache and can be more readily promoted again.

Caches are also used in a variety of other devices, any time it is desired to improve the access speed by staging data ahead of time. Disk controllers use cache memory to perform "read ahead" on sequential files. It is used to complete write operations rather than waiting for the disk to be updated.

Virtual memory, on the other hand is a concept that defines how these real memory resources are going to be managed. In z/OS, memory is divided into 4K pages [or page frames to represent their real storage use]. This provides two benefits. In the first if storage demands are too high, the system can take unreferenced pages and move them to disk. In this way if the page isn't being used, then there's really no point in keeping it in real memory, so the move to disk may be beneficial.

This only occurs when the system's pool of available page frames is below a threshold value. However, paging is NOT a desirable state, and is used to manage how committed real memory is to existing work. Paging is considered to be occurring when pages that have been moved to disk need to be brought back into real memory.

The most important role of virtual memory is that it provides a "view" to the program. In other words, since each piece of memory is divided into 4K pages, then the system can provide a virtual view of those pages so that they all appear together, regardless of where they physically reside. As a result, each program that runs views its storage usage as being uniform and contiguous.

This is a major factor in storage management because it allows each unit of work to view a logical organization of data without causing the fragmentation problems that would occur if real storage had to meet these needs.