SHARED MEMORY, VIRTUAL MEMORY AND CACHE MEMORY

Nihari priya reddy
7 min readDec 6, 2022

--

What are we learning in this blog?

Most people know that their computers have some type of memory, but many don’t know the difference between virtual memory and cache memory, or even shared memory. Here’s where you will get to know more about these memories, we will start exploring from basic terminology and the meaning then we will drive further into where we use it as well as its advantages and disadvantages.

Key words: — Virtual memory, Shared memory, and Cache memory.

Shared memory

What is Shared memory? And where we use it? Cons and pros of using Shared memory….

Shared memory

Shared memory is a type of computer memory that can be accessed by multiple processors at the same time. It is often used in multiprocessor systems to optimize performance. Shared memory is typically used for storing data that needs to be accessed by multiple processes, such as shared data structures or message queues.

Working flow of Shared memory

The working of shared memory is actually quite simple. When a processor wants to access the shared memory, it first checks if the memory is available. If it is available, the processor will read or write the data from the shared memory.

However, if the shared memory is not available, the processor will wait until the memory is available. This is because the shared memory is a shared resource, and multiple processors cannot access it at the same time.

Shared memory is a very efficient way of communication between different processors, as it is very fast and easy to use.

Advantages and Disadvantages of shared memory

It has several advantages over other types of inter-process communication (IPC) mechanisms, such as pipes and sockets. First, it is much faster since data does not need to be copied between processes. Second, it is easier to use since it does not require setting up communication channels between processes. Finally, shared memory is more flexible since it can be used for both one-to-one and one-to-many communication.

Despite its advantages, shared memory has some disadvantages. First, it is more difficult to debug since data corruption can occur if two processes try to write to the same location in memory. Second, it is not suitable for large amounts of data since the entire dataset needs to fit in memory. Finally, it is not portable since it is highly dependent on the operating system and hardware architecture.

shared memory connections

In daily life, we use shared memory in many ways. For example, when two or more people are working on a document at the same time, they are using a shared memory system. Another example is when two or more people are playing a game online, they are also using a shared memory system.

Virtual Memory

What is Virtual memory? And where we use it? Cons and pros of using Virtual memory….

Virtual memory in Operating systems

Virtual memory is a memory management technique that is used by operating systems to provide each process with its own private address space. This address space is then divided into pages and each page is mapped to a physical address in memory.

Virtual memory is often used for datasets that are too large to fit into physical memory or for data that is not frequently accessed. When a process accesses data in virtual memory, the data is read from or written to a backing store. The backing store is typically a file on disk.

Working flow Virtual memory

Virtual memory is divided into two parts: physical memory and virtual memory. Physical memory is the actual amount of RAM that is installed on a computer. Virtual memory is a file on the hard disk that is used as an extension of physical memory.

When a computer needs more memory than is available in physical memory, it uses virtual memory. The hard disk is used to store data that is not being used by the operating system or by programs. This data is then available to be used by the computer when needed.

Virtual memory is slower than physical memory, but it is still faster than going to the hard disk. When a computer needs to access data in virtual memory, it first checks the RAM for the data. If the data is not in physical memory, the computer will look for it in the virtual memory file.

Advantages and disadvantages

There are some drawbacks when we use virtual memory. First, it can be slower than traditional memory management techniques because of the overhead involved in managing the address space. Second, it can use up physical memory resources more quickly because each process has its own address space. Finally, it can make it more difficult to debug programs because the address space is not physically contiguous.

Cache memory

What is Cache memory? And where we use it? Cons and pros of using Cache memory….

751 Cache memory

Cache memory is a type of high-speed memory that is used to store frequently accessed data. It is typically used to improve the performance of a system by reducing the number of times that the system must access slow, main memory.

Working of Cache memory in computers

Types of Cache memory and how it works in computer

L1 Cache and L2 Cache

There are two types of cache memory: L1 and L2. L1 cache is built into the CPU and is the smallest and fastest type of cache memory. L2 cache is slightly larger and slower than L1, but it can still provide a significant performance boost.

When the CPU needs to access data, it first checks the L1 cache. If the data is not found in the L1 cache, it then checks the L2 cache. If the data is still not found, it finally looks in the main memory. This process happens very quickly, and it is why cache memory is so important for performance.

If you’re looking to improve your computer’s performance, one of the best things you can do is upgrade your cache memory. This will give you a significant boost in speed and can help your computer keep up with the demands of modern applications.

Where we use Cache memory?

One common use of cache memory is in web browsers. When you visit a website, your browser stores or caches a copy of the website’s files on your computer. This enables the website to load faster the next time you visit it, since the browser doesn’t have to retrieve all of the data from the server again. Another use of cache memory is in CPU caches. A CPU cache is a small, fast memory cache that is built into the CPU itself. The cache is used to store data that the CPU is likely to need next, so that it can be accessed quickly.

Advantages and disadvantages of Cache memory

When it comes to advantages of using cache memory it can improve the performance of a system by reducing the number of times that the system has to access slow, main memory. This is because data that is stored in cache memory can be accessed more quickly than data that is stored in main memory. But one of potential disadvantage of using cache memory is that it can sometimes be difficult to implement. For example, if data that is frequently accessed is spread across multiple locations, it can be difficult to bring it all together in one cache. Additionally, cache memory can be expensive, so it is not always practical to use it in large systems.

So Quick Review of the virtual, Shared and Cache memories….

Virtual memory is a type of memory that is created by the operating system. It’s a way to use the hard drive as extra memory when the RAM is full. When the computer needs to use information from the hard drive, it is copied to the RAM, which is much faster.

Cache memory is a type of memory that is used to store frequently used information. It’s much faster than the hard drive or the RAM, so it can help the computer to run faster.

Shared memory is a type of memory that can be accessed by more than one program. It’s used to share information between programs or between the different parts of the operating system.

--

--