Types of Memory
At a high level, there are four types of memory in a computer — primary, secondary, cache, and registers. Following are some examples for each of the memory types:
Primary: RAM, ROM Secondary: Harddisk, Pen drive, Floppy Disk, CD Cache: L1, L2,L3 caches Registers: Accumulator(AC), Memory Address Register(MAR), Memory Data Register(MDR), Program Counter(PC) etc.
Now, let’s take a look at each of the memory types and try to understand the core differences among all of them.
1) Primary vs 2)Secondary
Let’s take a look at some points for comparing primary and secondary memory!
But wait, how are Primary and secondary memory types related to program execution? Imagine this: When you open any application on your computer, the processor in your computer brings all the data related to your application from the secondary memory into the primary memory and then the processor executes instructions performed by the user.
Is the CPU a Processor? Quoting here from Techopedia: Most people use the word “processor” interchangeably with the term “CPU” nowadays, it is technically not correct since the CPU is just one of the processors inside a personal computer (PC). The Graphics Processing Unit (GPU) is another processor, and even some hard drives are technically capable of performing some processing. To sum it up, yes, your CPU is a processor!
Types of Primary
As discussed earlier, there are two types of Primary memory:
1) Random Access Memory (RAM)
RAM is one of the computer's main memory that allows faster read and writes. Since it’s a kind of primary memory, it’s volatile in nature which means changes made will be lost once the computer is switched off or in case of power failure.
2) Read Only Memory (ROM)
As per Wikipedia, “Read-only memory is a type of non-volatile memory used in computers and other electronic devices. Data stored in ROM cannot be electronically modified after the manufacture of the memory device. Read-only memory is useful for storing software that is rarely changed during the life of the system, also known as firmware.”
Why ROM is a non-volatile memory though it’s a type of primary memory? The crux of the issue lies in the definition of "primary memory." While it's true that ROM is non-volatile, it's also very fast and directly accessible by the CPU, making it functionally similar to RAM in terms of its role in the system.
Due to it’s functional similarity with RAM, ROM is often considered a type of fast, non-volatile primary memory. It typically stores essential system files, like the BIOS (Basic Input/Output System) and firmware, which are crucial for booting up and running the computer. These files need to be readily available for the CPU to access but don't necessarily need to be constantly modified.
Types of Secondary
Hard disk, USB Pen Drive, Floppy Disk, CD etc are all examples of Secondary storages. These storages persist data in them permanently and don’t cause loss in data even in case of power failures. You might have used Pen drive and CD’s extensively if you were born in 90’s ;)
领英推荐
3) Cache
Cache memory is a small chip based computer memory that lies between the CPU and the main memory. It is fast and a temporary memory solution to enhance the performance of the CPU. Because of the cache’s proximity to the CPU, this is also called as CPU memory.
Here are the different types of caches:
The L1, L2 and L3 caches are faster memory access option compared to the main memory. Cache memory stores all data and instructions that are repeatedly used by the CPU for improving the performance of a computer. Moreover, caches are must costlier compared to the primary memory and secondary memory.
4) Registers
Registers are type of computer memory that are built directly into the CPU that is used for storing and transferring the data and instructions to the computer. It is the smallest and fastest memory of a computer. The register memory is 16, 32 and 64 bits in size.
There are different types of registers available and thus may store different type of data such as an instruction, a storage address, or any kind of data for that matter depending upon their type.
Here are some examples of registers with their respective applications in brief:
… etc (there are many more kinds of registers)
Conclusion
To enhance execution speed, a computer's CPU relies on accessing data from memory. Registers, which are shorter in size, conveniently fit into the CPU due to their compact nature. On the other hand, larger memory types, such as hard disks, occupy more space and are situated farther away from the CPU. Consequently, the proximity of registers facilitates faster instruction execution, while the distance and size of disks contribute to slower instruction performance.
Thus, increase in size causes the memory type to be further away from CPU and thus causing slower reads/writes.
That’s it, folks for this edition of the newsletter. I hope this edition of newsletter with the help of images helped you visualize how different types of memory in our computer look like. Please consider liking and sharing with your friends as it motivates me to bring you good content for free.
Senior Software Engineer at Uber | Ex- Morgan Stanley | Ex- Barclays
1 年Well articulated. Thanks for sharing!
Student at Sant Longowal Institute of Engineering & Technology
1 年I give you all answers... please connect me.
Engineering @Myntra (Flipkart) || Ex-PayPal || 120K+ @LinkedIn || Mentor
1 年Insightful ??
Full Stack developer | content creator| open for collabs
1 年Nice one article u have written Vivek Bansal