Every computer has multiple places where data - 0’s and 1’s - can be stored. Each place serves a different purpose.
Secondary Memory or secondary storage is the part of a computer where data lives when it’s not being directly used. In most computers this will be a hard drive or solid-state storage. This could also be exterior storage such as CDs, DVDs, USB Flash drives, SD Cards, video game cartridges, and so forth. This memory is slow, but usually cheap (relatively), and is persistent, which means that it will continue to hold data even when power is disconnected. 2.1.5
Image credit: https://www.slideshare.net/rahulbandhe/basics-of-semiconductor-memories-presentation
ROM (Read Only Memory) is a tiny piece of medium-fast memory built into the main structure of the computer (but not directly into the main processor chip). It is usually small and contains only the tiny bit of software needed to actually start a computer, before the operating system takes over. If you’ve ever “flashed a firmware update” on your computer, router, or phone, you have edited the ROM. This is the only part of primary memory that is persistent.2.1.2
RAM, or Random Access Memory is the part of the computer where data is stored that is being actively used by running programs. It is generally much smaller than the secondary storage, but much faster. A modern computer might have 16 Gigabytes of RAM, but 500 or more GB of hard disk space, for example. 2.1.2
Cache is an even faster and smaller section of memory that is used by the computer to store things it knows it may need again soon. It is usually directly connected to the computer’s “brain” (CPU), which gives it extreme speed. From the perspective of a programmer, the cache and RAM are essentially interchangeable, but they make a huge difference at the low level; computer processor designers spend lots of time optimizing cache usage, since the cache can be up to 100 times faster than the RAM!. It is very expensive, however, so most computers have less than a gigabyte of cache total, and often significantly less of the fastest level 1 cache.2.1.3
CPU Registers are the smallest, fastest memory, but they are usually considered as part of the CPU architecture. They are used only for values involved in the current operations of the processor. We will discuss them more in Lesson 2.3
As a programmer, we mostly only worry about the persistent storage (which we tend to call the disk or the files) and the RAM (which we tend to call the memory.) The CPU and programming language handle the movement between RAM, cache, and registers for us, while the ROM does its own thing when the computer starts and is otherwise not our concern.
Though the different storage types all works very differently at a physical or chemical level (hard drives use magnets, dvds use lasers, etc), for a programmer it is reasonable to think of memory as holding a giant series of 0
’s and 1
s. This is another example of an abstraction!4.1.17
Each 0
or 1
is called a bit.2.1.9 By itself, a bit can’t convey a lot of meaning, since there are only two options. But if you combine the 0
s and 1
s into groups, you can get more interesting combinations. A group of 8 bits is called a byte and provides \(2^8=256\) possible values, from 0000 0000
to 1111 1111
.
Given a single byte (or more than one) we can train our programs to interpret it in different ways. For example, the byte 0011 1011
might be interpreted as the integer 59
, or the text character a
, or the percentage 23.13%
, depending on the interpretation instructions we are using. Later in this course we will explore some of these encoding schemes in detail.
Occasionally, a computer will completely run out of available cache and RAM to keep track of all of the running programs. In that situation, the operating system, which is the primary software that controls how the computer works, may allow programs to use virtual memory, or swap space, which allows the programs to use space on persistent storage in the same way they might use RAM.
The advantage of this is that the computer can continue to run all of the programs on the computer without causing any sort of error caused by insufficient RAM, and extremely large programs can run even on devices with less RAM.
The disadvantage is that persistent storage solutions are MUCH slower than RAM (often by 50 or 100 times or more!) so the computer will run the programs much more slowly. Faster secondary storage options, such as modern Solid State Drives, are much faster than older drives and make virtual memory more feasible, but RAM is still significantly more efficient.
What is the difference between RAM and ROM?
RAM means Random Access Memory, and it is the section of primary memory that holds the data the computer is using as it works. ROM stands for Read Only Memory, and is the special part of primary memory that holds the important information needed to get the computer started, sometimes called the firmware. Other than their acronym, they have almost nothing in common!
8
ROM, RAM, Cache, and CPU Registers
Without persistent memory, the computer would have to start over from scratch every time its power was removed! Things like documents, photos, settings, and so forth require persistent storage to exist in a digital world.
The ROM is persistent; it has to exist between power cycles or else the computer won’t be able to start.
Identify two characterists of RAM
State the purpose of persistent storage on the computers.
May 2019, problem 5, HL (HL only!) Outline one advantage and one disadvantage of using virtual memory.
Award [1] for an advantage, [1] for a disadvange, and [1] EACH for outlines (additional details) 4 marks total
Potential Advantages
Allows more applications to run than there is available physical memory; By the use of page/swap files/part of hard disk as primary memory;
Larger application can run With less real RAM;
Potential Disadvantages
Applications run more slowly;
Uses hard drive memory as primary memory / takes more time to switch between
applications;
When a computer’s virtual memory resources are overused /Reduced amount of
hard drive space available for your use;
programs lock-up/do not run/disk thrashing;
Create flash cards or a quizlet deck with the following words on one side and a quick summary on the other.