Understanding Computer Memory System

And All about Memory Utilization in modern-day computers

Nilabh Nishchhal ✍🏻💡
Analytics Vidhya
17 min readFeb 4, 2021

--

Memory is the faculty of the brain by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time to influence future action.

Similar is the function of computer memory, and it has similarities with the human brain. But oversimplification in this regard will be hazardous because the human brain is a very complicated and sophisticated piece of machinery. It has memory and processing, entwined together, along with the capability for feelings and emotions which a computer system lacks.

Here we will focus on the memory part of the brain alone (not physically, only functionally). And try to use it as an analogy for understanding how computer memory works.

Memory is often understood as an informational processing system with explicit and implicit functioning that is made up of a sensory processor, short-term (or working) memory, and long-term memory.

This can be related to the computer memory systems as well.

The sensory processor allows information from the outside world to be sensed. This is in the form of chemical and physical stimuli.

Working memory serves as an intermediate, for understating and retrieving for the brain to process information. Information in the form of stimuli is encoded following explicit or implicit functions by the working memory processor. The working memory also retrieves information from previously stored material.

Finally, the function of long-term memory is to store data through various categorical models or systems.

The above three functions serve as an analogy to the computer memory system, the Input from various input devices goes into the memory, which is processed in the Main Memory (Primarily RAM), and the data is stored in Secondary Memory (Auxiliary Storage) for present or future processing.

Apart from these three are ROM, the hard encoding of computer memory, or the framework. That can be understood as the analogy of human habits, which slowly get encoded in the behavior, and come naturally without conscious effort once they are formed.

Let us dive a bit deeper into the computer memory system, and let’s use the human memory analogy deliberated above for understating it better (and for that purpose only. Human memory systems are much more sophisticated in reality).

Various forms of storage, divided according to their distance from the central processing unit. The fundamental components of a general-purpose computer are the Central Processing unit, Primary Memory, Input and Output channels, storage space, and input/output devices.

Memory Hierarchy:

How computer processes information

This is one layout we all are very familiar with. It’s the most basic of the computer layout which sacrifices some details for ease of understanding.

If you follow the flow of data, it comes as input from input devices and goes straight into Memory, which is represented by Storage Unit. From here onwards the confusion related to how memory is used and what all inside starts. Let’s break this box further.

1. Primary Storage

2. Secondary Storage

The nomenclature creates a hierarchy, where one memory is superior to the other. And there are reasons for the same. Let’s first understand what all kind of memories are in there, and then we will look at the superiority complex (pun intended 😃) of the memory.

In computing, a device that is used to store information for immediate use in a computer or related computer hardware device is commonly called as memory. It typically refers to semiconductor memory where data is stored within metal–oxide–semiconductor (MOS) memory cells on a silicon integrated circuit chip. The term “memory” is often a colloquial short-hand with the term “primary storage”. Secondary storage or memory is often called “storage”.

The two “memories” of the processor, which are housed inside the Central Processing Unit (CPU) are Registers and Cache. Though they are kind-of memories, but generally studied out of the memory system. These are the most expensive, and fastest memory access to the CPU. Let us have a look at them first.

The memory of the CPU:

Registers:

Registers are the small storage locations used by the CPU to store data and instructions. They are built into the processor itself. Hence these memory locations can be accessed by the processor directly. This makes them the fastest accessible memory. Registers are measured by the number of bits they can hold, for example, an “8-bit register”, “32-bit register” or a “64-bit register”. 32-bit and 64-bit are commonly used to describe processor architecture or processor design. A 32-bit processor has a 32-bit register, which can store 232 or 4,294,967,296 values. A 64-bit processor has a 64-bit register, which can store 264 or 18,446,744,073,709,551,616 values.

If you ever wondered, while installing software, what is the difference between the 32-bit and 64-bit versions, now you know.

Cache Memory:

Cache memory is not an original memory, but a copy of some parts of “Main Memory” which is used frequently. Hence cache is a smaller, faster memory, located closer to a processor core, which stores copies of the data from frequently used main memory. When trying to read from or write to a location in the main memory, the processor first checks whether the data from that location is already in the cache. If so, the processor will read from or write to the cache instead of the much slower main memory. This helps to reduce the average cost (time or energy) to access data from the main memory.

The small memories which are closer to the CPU can operate faster than the much larger main memory. Most CPUs since the 1980s have used one or more type of caches.

Primary Memory (also known as main memory, internal memory, or prime memory)

Primary storage (also known as main memory, internal memory, or prime memory), often referred to simply as memory, is the only one directly accessible to the CPU. The CPU continuously reads instructions stored there and executes them as required. Any data actively operated on is also stored therein in a uniform manner.

This one diagram details it all. The two kinds of Primary Memory are ROM and RAM.

Primary and Secondary Memory: Different types of devices used as RAM and ROM.

ROM: Read Only Memory

RAM: Random Access Memory

RAM and ROM are very popular abbreviations, which every student knows from middle school, but I can say for myself, that I was always confused about how they differ in form and functionality. And when I connected the dots, I was excited. Because the new things I learned about them were all about known things, which were never perceived like what they are. So I am trying to make you connect those dots yourself.

Everyone knows that ROM is a read-only memory. But Why? Where is this Memory Housed? What functions does it perform?

Read-Only Memory (ROM)

Opened ROM cartridge for the Game Boy Color. Here: Pokémon Silver. By Simon A. Eugstera — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=17921573

This is a type of non-volatile memory used in computers and other electronic devices. Non Volatile means that no power is needed to keep the memory alive. The data stored in ROM cannot be electronically modified after the manufacture of the memory device.

Now almost every device comes with Factory Reset. Hence I will use this analogy to make understanding ROM easier for you.

The memory of your computer, which is built-in into it, when the computer is being manufactured/assembled in the factory, is the ROM. Data Stored in ROM is not alterable, non-modifiable easily. Hence, that software that is rarely changed during the life of the computer system is stored in a ROM memory device. This kind of software is also known as Firmware. (Firmware is a very common term, and computer or such systems reset to it when factory reset applied. )

Pokémon Gold and Pokémon Silver were released in Japan on November 21, 1999, as the second set of titles in the Pokémon series. https://www.pokemon.com/us/pokemon-video-games/pokemon-gold-version-and-pokemon-silver-version/

Hence, think of it as the most basic and most important memory. Basic because, you can only READ it, but can’t WRITE anything on it. This memory space is not open to the user. The BIOS of your computer is one such example. Another example can be Video Games Cartridges, which are plug and play. They store the Game in ROM. Many game consoles use interchangeable ROM cartridges, allowing for one system to play multiple games. ROM comes before the Operating System. And it allows the computer to have its own Firmware. Everything else comes after that, even the Operating system.

Mask ROM:

Samsung KM23C4000P-15 4M-Bit (512Kx8) CMOS MASK ROM 32Pin P DIP OMA037D

The first ROM was hard-wired. They were made up of electronic components such as Diodes or Integrated Circuits (ICs), which cannot be altered after manufacture. These ROM ICs are also called Mask ROM Integrated Circuits. Thereafter, if there is any up-gradation in ROM is to be made, it has to be replaced. A new ROM with new upgraded firmware can be installed, but old ROM and the firmware cannot be changed. (Hard wired, Remember… )

In the Mask ROM IC, data is hard encoded, physically, during the manufacturing. So it can be programmed only during the fabrication. This creates many hurdles:

1. Because each Mask ROM is programmed during manufacturing, its cost becomes very high, since users must contract with a foundry to produce a custom design. It is only possible to order it in large quantities.

2. Getting a ROM manufactured is time taking process, as each ROM is customized.

3. For R&D use, where the users have to do trial and error or modify and improve the contents in the memory for refining a design, Mask ROM becomes impractical.

4. If ROM is faulty, and the product is shipped, it can’t be corrected without Total Recall.

Programmable ROM (PROM):

Texas Instruments PROM type TBP18SA030N. By © Raimond Spekking / CC BY-SA 4.0 (via Wikimedia Commons), CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=56695971

These shortcomings created a need for Programmable ROM (PROM). These were invented by Wen Tsing Chow in 1956, allowed users to program its contents exactly once by physically altering its structure with the application of high-voltage pulses. This addressed problems 1 and 2 above since a company can simply order a large batch of fresh PROM chips and program them with the desired contents at its designers’ convenience. However, this was also possible one time only.

Erasable Programmable ROM (EPROM):

Erasable programmable read-only memory (EPROM) integrated circuits in dual in-line packages. These packages have a transparent window that shows the die inside. The window is used to erase the memory by exposing the chip to ultraviolet light. By The original uploader was Zephyris at English Wikipedia. — Transferred from en.wikipedia to Commons by TenIslands using CommonsHelper., CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=4560427

In 1971, Dov Frohman of Intel invented Erasable Programmable Read-Only Memory (EPROM). This new ROM, known as EPROM essentially solved the 3rd hurdle in the list above, since EPROM (unlike PROM) can be repeatedly reset to its un-programmed state by exposure to strong ultraviolet light. It’s worth noting that it was still nearly impossible for a user to erase the ROM (Which is exactly as intended), and rewrite it. It only solved problems for well-equipped labs and R&D centers.

The first EPROM, an Intel 1702, with the die and wire bonds clearly visible through the erase window. By Author : Poil 01:10, 17 Apr 2005 (UTC) — Author personnal collection., CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=97658

Electrically Erasable Programmable ROM (EEPROM):

STMicro M24C02 I²C serial type EEPROM, By © Nevit Dilmen, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=30561436

EEPROM was developed by Yasuo Tarui, Yutaka Hayashi, and Kiyoko Naga at the Electrotechnical Laboratory in 1972. This could be programmed even at a remote location (using just a computer and serial cable). This helped the computing industry cross the 4th hurdle as well. Now faulty ROM could be reprogrammed at the consumer’s or user’s place, without the need to bringing the entire device back to the manufacturer.

Flash Memory:

Going forward, Fujio Masuoka at Toshiba invented Flash Memory in the early 1980s and commercialized it in the late 1980s. Flash Memory is a form of EEPROM. This uses the chip area very efficiently and can be erased, programmed, and reprogrammed thousands of times without any damage.

A disassembled USB flash drive. The chip on the left is flash memory. The controller is on the right. CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=179956

But it’s one of the groundbreaking advancement was that now any specific part of the device could be erased. (Earlier ROMs needed to be deleted in totality). This can be done at high speed, hence the name “flash”.

After the advent of Flash Memories as ROMs, the entire ROM scenario has changed from “One-time Programmable” to “Regular Updation of ROM”. The best example of the same is regular updates of the firmware of various computer systems. Earlier, the firmware was not easy to change or upgrade. Now in mobile devices, companies push remote upgrades of the firmware, and the user downloads and updates the same.

Why do we still have EPROM and Mask ROM?

A natural question comes to mind, that after all the advantages of EEPROM, why do we still have the old and less functional types of ROMs?

The answer is simple. COST.

All the advanced technologies increased the flexibility of the ROM chip, but there is a downside of it as well. The technology comes at a very high cost per chip. And many systems do not need ROM to upgrade for their life, making the additional cost burden unnecessary. Hence, as long as the large quantity MASK ROMs are cheaper (economy of scale), they will remain the ROM of choice for many devices for years.

RAM (Random Access Memory)

Random Access Memory is the Volatile Memory of the computer. It means, it forgets as soon as the power is switched off. RAM is an expensive “memory real estate” and hence in normal computing devices, it varies from 512 MB to 8 GB (Some expensive devices, both PC and Mobile have much higher RAM as well). More amount of RAM is associated with the faster working of the computer. The reason for it can be understood if we understand how a computer manages its internal memory for operation (only Volatile one, not ROM).

Example of writable volatile random-access memory: Synchronous Dynamic RAM modules, primarily used as main memory in personal computers, workstations, and servers. By An-d — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=27224495

RAM is essentially super-fast, high-speed storage that the computer and its applications utilize to store and access temporary data. It can be thought of like a computer’s short-term memory. When a program starts ( for example Google chrome browser or Microsoft Excel file), its common data is stored on RAM, and as RAM is much faster than a hard drive (Secondary Memory), the program runs faster by having data directly accessible from RAM. As soon as the program ends (you close the browser or file), the RAM gets free from its data. Hence, the larger the RAM, the faster the computer works with more number of simultaneous programs.

Computers with lesser RAM can not do many things at once. Say for example you are working on multiple video files, and at the same time, open many web browsers. The RAM requirement goes up with each new program being opened. What happens when the amount of “Temporary Memory” requirement of a computer exceeds the RAM? Modern computers use a memory management technique called Virtual Memory.

Virtual memory combines active RAM and inactive memory on DASD[a] to form a large range of contiguous addresses. By Ehamberg — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=8352077

This is a method to expand the RAM capacity. A portion of the computer’s hard drive is set aside for a paging file, and now the sum total of the RAM and Paging file becomes the total “Temporary Memory”. However, there is a catch. The hard drive is much slower than the RAM. And every time the computer relies on to take data from the paging file from the hard drive, it gets a slower response than the RAM would offer.

Hence, the higher the RAM, the faster the computer operations become.

Now the natural question arises again. Why the RAM is in the range of 1 to 8 GB (or at times somewhat higher) but the hard drives are in range of 512 GBs to 2 TBs (Terrabyte = 1024 GB)?

When RAM is so important, why not have higher RAM?

The answer is again, the COST.

The two main types of volatile random-access memory are Static random-access memory (SRAM) and Dynamic random-access memory (DRAM). Commercial uses of semiconductor RAM date back to 1965, when IBM introduced the SP95 SRAM chip for their System/360 Model 95 computer, and Toshiba used DRAM memory cells for its Toscal BC-1411 electronic calculator.

Static random-access memory (SRAM)

In Static RAM, data is stored in a six-transistor (one kind of semiconductor) memory cell which requires a constant flow of power. Because the power flow is constant, it doesn’t need refreshing the memory to remember the data being stored. This is called static because there is no change needed ( no refreshing needed) to keep the data intact. It is used in cache memory.

This requires lesser power and gives faster access and speed. But at the same time, it’s less dense in memory (lesser memory in the same size) and hence has a higher cost.

Dynamic random-access memory (DRAM).

In Dynamic RAM, data is stored in transistor and capacitors (Made of metal and not a semiconductor) pair memory cell. Capacitors discharge energy slowly. And hence data (which is stored in form of energy) is also lost. Therefore a periodic refresh of power is required to keep it functioning. DRAM is called dynamic as it needs a constant change of power (refreshing) to keep the data intact.

This requires higher power consumption and has slower access to data as compared to SRAM. But at the same time, it’s denser in memory (more memory in the same size) and hence has a lower cost.

Many computer systems have a memory hierarchy consisting of processor registers, on-die SRAM caches, external caches, DRAM, paging systems, and virtual memory on a hard drive. This entire pool of memory may be referred to as “RAM”.

Secondary Memory (also known as external memory or auxiliary storage):

Secondary storage (also known as external memory or auxiliary storage) is different from primary storage because it is not directly accessible by the CPU. The computer uses its input/output channels to access secondary storage and transfer the desired data to primary storage. Secondary storage is non-volatile (data is retained even when power is switched off).

Different data storage media, By avaragado from Cambridge — Forty years of removable storage, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=20711777

The access time per byte for HDDs or SSDs is typically measured in milliseconds (one-thousandth seconds), while the access time per byte for primary storage is measured in nanoseconds (one billionth seconds). Thus, secondary storage is significantly slower than primary storage.

Let us have a look at various secondary memory devices being used to store memory. We will list them in the order of the most recent ones first.

Solid-State Drive (SSD)

An mSATA SSD with an external enclosure, By Ralf Roletschek — Own work, GFDL 1.2, https://commons.wikimedia.org/w/index.php?curid=37902393

SSD is a storage device that uses integrated circuit assembly to store data. This typically uses flash memory. Compared to their closed competitor, the Hard Disk Drive (HDD — commonly known as a hard disk), the SSDs are Faster in data read and write, run silently, and are more resistant to physical shock (As they do not contain any moving mechanical device).

SSDs store data in semiconductor memory cells.

Hard Disk Drive (HDD)

Internals of a 2.5-inch laptop hard disk drive, By Evan-Amos — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=27940250

HDD is an electro-mechanical device used to store a large amount of digital data using magnetic storage. The storage is done in magnetic discs on which data is recorded electromagnetically in concentric circles. A head that looks similar to a phonogram arm writes and reads the data on the discs. Each read or write operation has to locate data first, an operation is known as “Seek”. Data is accessed in a random-access manner, meaning that individual blocks of data can be stored and retrieved in any order. HDDs are a type of non-volatile storage, retaining stored data even when powered off.

USB Flash Drive:

A SanDisk Cruzer USB drive from 2011, with 4 GB of storage capacity

A USB flash drive is a data storage device that includes flash memory with an integrated USB interface. It is typically removable, rewritable, and much smaller than an optical disc. Most weigh less than 30 g. they were first commercially introduced in the market in late 2000. As it happens with most of the developing technology, the storage capacity has improved over time and the prices have dropped. These are the most common portable memory devices being used nowadays by people at large.

The front and rear side of a USB flash drive with the casing removed, By Graham Beards — At home, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=87863271

Optical Disc Drive (ODD)

Optical points towards things related to light. Optical disc drives are those discs that use light (laser or other electromagnetic waves like light) to read or write the data on the disc drive. There are 3 most popular optical discs which are used for the storage of data. They are Compact Disk (CD), Digital Versatile Disc (DVD), and Blu-ray Disc (BD). CD is the lowest and Blu-ray disc has the highest storage capacity. The normal range is 700 MB of Data for a CD, about 4.7 GB of data for DVD, and about 25 GB of Data for a Blu-ray Disc.

An optical disc is designed to support one of three recording types: read-only (e.g.: CD and CD-ROM), recordable (write-once, e.g. CD-R), or re-recordable (rewritable, e.g. CD-RW).

Although optical discs are more durable than earlier audio-visual and data storage formats, they are susceptible to environmental and daily-use damage, if not handled properly.

Floppy disk

The Floppy disk is a magnetic storage device, where data is stored in a thin and flexible disk of a magnetic storage medium.

Floppy disks were so common in the late 20th-century culture that many electronic and software programs continue to use save icons that look like floppy disks well into the 21st century. However, as they were able to hold a very small amount of memory (800 KB to 2.8 MB), and with the advent of more advanced memory solutions like optical discs and flash drives, they have gone out of use from day to day computer usage.

Magnetic tape data storage:

IBM 729V, CC BY-SA 2.5, https://commons.wikimedia.org/w/index.php?curid=1717519

Magnetic tape data storage is a system for storing digital information on magnetic tape using digital recording. The tape was an important medium for primary data storage in early computers, typically using large open reels of the 9-Track tape.

Tape remains viable in modern data centers because:

1. it is the lowest cost medium for storing large amounts of data and

2. as a removable medium, it allows the creation of an air gap that can prevent data from being hacked, encrypted, or deleted and

3. Its longevity allows for extended data retention which may be required by regulatory agencies.

Conclusion:

The human memory system and computer memory system have some similarities, like modern memory of the computer is created, deleted, and maintained by electrical signals. Kind of the same way the human memory system is functioning, through the signals using neurons. All our senses which create memory start with sending some input in form of sensory signals.

But as I said at the very beginning, the human memory system is much more sophisticated and advanced than anything humans have created to date. Barring the passing similarity, let’s see how they differ in real-life utility.

The basic purpose of either human or computer memory are two — one is to remember things, and the other is to quickly process the data for the functioning of the machine.

One of the remarkable things about human memory is that it “Forgets”. It may sound like some defect, but in reality, it’s a wonderful feature. We usually do forget few things completely over time (Maybe not so important memory after all) but mostly we forget the “finer details” and remember the gist of things for a longer time(eg. A Face looks familiar but can’t remember the name). Such “streamlined” memories are not side effects of flaws or constraints on memory power, as pointed out by Frankland and Blake Richards in a paper on Neuron in 2017. They wrote that such simplification “is an essential component of adaptive memory,” “Simple memories that store the gist of our experiences and avoid complicated details will be better for generalizing to future events.” Getting the gist, and just the gist, is, therefore, valuable as an aid to making smart decisions.

However, a computer memory doesn’t have this “feature”. They work in binary. Either they know something, or they don’t. Barring some catastrophic event that causes failure, they do not forget. Humans are different, as we can “recognize things” and still can’t recall their names (the gist of memory). We can recall memory and feel it all over again (pain, angst, happiness, or fear) and also create memories (Imagination, dreams, and making up stories) which a computer memory system is incapable of. At least, incapable of as yet. With the advent of machine learning and Artificial intelligence, who knows what the future of computer or machine memory beholds.

--

--

Nilabh Nishchhal ✍🏻💡
Analytics Vidhya

✍🏻 Author of Python Made Easy. Machine Learning and Artificial Intelligence enthusiast. Marketing Professional. https://www.authornilabh.com/