Cache memory & Virtual memory explain the purpose of virtual memory explain the purpose of cache memory

Cache memory & Virtual memory

Cache memory

Cache memory is a small amount of very fast memory which is usually located on the CPU chip (or very close to it on the motherboard). The CPU can access cache memory more quickly than normal RAM, but there is much less of it.

The system tries to keep the most frequently used data in the cache. It uses an algorithm to decide which data should go in the cache. 

Levels of cache memory

Often the cache memory is arranged in levels:

  • the L1 cache contains a small amount of very fast memory
  • the L2 cache contains a larger amount of slightly slower memory
  • the L3 cache contains an even larger amount of even slower memory

Often, each core has its own fast cache, but the slower caches are shared between all the cores. The faster caches are always on the CPU chip, but the slowest cache is sometimes on the motherboard close to the chip. 

Virtual memory

Sometimes RAM memory is not enough for all the data the CPU needs. When RAM gets too full, the computer's operating system can help out by temporarily marking sections of secondary storage for the CPU to use as a kind of extra memory.

These sections are called virtual memory.

The operating system creates a 'pagefile' in this area which is used to hold data the CPU does not need immediately. 

Paging (also called swapping) is where relatively inactive pages are temporarily removed from physical memory and placed into virtual memory. 

Virtual memory is volatile. 

The speed of accessing data located on the hard disk is thousands of times slower than RAM memory.

Virtual memory allocation scheme

In this scheme, the operating system retrieves data from secondary storage in same-size blocks called pages.

Least recently used. The pages that have been accessed for the longest time are deleted. 

Least recently used. The newly released pages are deleted. 


Advantages and disadvantages of using Virtual memory

Advantages Disadvantages

You can run more applications at once

You can run larger applications with less real RAM

You don't have buy more memory RAM

Applications run slower

It takes more time to switch between applications

Less hard drive space for your use



  1. What is 'cache'?
  2. Is cache memory implemented using the DRAM chips?
  3. What does data store in cache memory?  
  4. What is 'virtual memory'?
  5. What happens when a large number of programs run on a computer? 
  6. How to speed up the processor even more? 
  7. What to do if it’s not enough size of RAM?


Research questions: 

  1. What size of RAM is installed on your PC? 
  2. What is the size of the virtual memory paging file installed on your computer? 
  3. How can you increase the size of the virtual memory paging file installed on your computer?  
  4. What data is stored in the paging file? 
  5. How does the data get into the paging file and on what principle? 


Exam questions:

Why do computers need to use virtual memory? (Marks: )
  • When a computer is running the operating system and several other programs at the
    same time, the physical memory often becomes full.
  • Instead of closing some programs the operating system will use ‘pretend’ or virtual
    memory to store some of the data.
Where is the data stored when it is in virtual memory? (Marks: )
  • It is stored on an area of a secondary storage device e.g. hard disk drive.
Describe how a computer uses virtual memory. (Marks: )
  • process running on the computer may need to store data in the physical memory.
  • If there are no free pages, the memory manager will ‘swap out’ a page of memory to the
    page file or swap area on the hard disk drive and ‘swap in’ the requested data into the
    now free page.
  • Usually the least recently used page is swapped out.
  • If a page is swapped out and then is referenced, it is swapped back in, from the swap
    area, at the expense of another page.
Describe a disadvantage of using virtual memory. (Marks: )
  • The read/write speed of a hard drive is much slower than RAM, and the technology of a
    hard drive is not geared toward accessing small pieces of data at a time.
  • If the system has to rely too heavily on virtual memory, there will be a significant performance drop.
Explain what is meant by ‘disk thrashing’. (Marks: )
  • This occurs when the operating system has to constantly swap information back and
    forth between RAM and the hard disk.
  • It significantly slows down the execution of the programs.



Ex. 1 (Author: Litvinova Olga - CS teacher of NIS Pavlodar)

Ex. 2

Ex. 3

Ex. 4

CPU and memory test questions

Категория: Main memory | Добавил: bzfar77 (09.09.2020)
Просмотров: 217 | Теги: cache, cache level, computer memory, pagefile, paging, virtual memory | Рейтинг: 0.0/0
Всего комментариев: 0