Memory
From ComputingForScientists
Contents |
1. Memory
1.1. Objectives
- To have an understanding about the meaning terms such as gigabytes, megabytes, etc.
- To have an understanding of the relationship between these terms and computer-related terminology encountered in everyday life.
1.2. Motivation
In scientific computing, the two biggest constraints on the types of problems that you can solve are
- how much memory is needed and
- how fast a computation can be performed.
1.3. Types of Memory
There are many ways to store bits. Previously we discussed
- Storing bits and bytes on a piece of paper
- A primitive memory stick
- A DVD or CD
- A hard drive
1.4. Primitive Memory Stick
1.5. CD or DVD
A CD or a DVD has small pits in it. In locations where there is a pit, the sensor stops receiving a reflected signal and this is interpreted as "zero". In locations where there is not a pit (a "land"), there is a reflected signal and this is interpreted as "one". What factors do you think control how many bits can be stored per unit area? What factors do you think control how quickly the bits can be read/written?
1.6. Hard Disk
A hard disk has one or more spinning metal plates. A sensor arm moves to different positions along the radius of the plate. The sensor moves up or down depending on if the plate has a magnetic field pointing up or down in a given location. Below is a hard drive with its cover removed.
1.7. RAM
RAM ("Random Access Memory") does not require any moving parts to work. It is based on many tiny electrical switches (made of transistors) packed into a small volume.
1.8. Computer Specs
When we talk about computer specs, we mostly talk about memory:
- 300 GB Hard Drive - How much data you can store when the power is off (in "slow" memory)
- 1 GB RAM - How much data you can store when the power is on (in "fast" memory)
The human brain has a similar feature. The information in short-term memory is recalled faster than the information in long term memory, but we have more information in our long-term memory.
Informally we say, "The desktop computer has 300 GB of disk space and 1 GB of memory." (The word "memory" is assumed to mean RAM or "fast" memory even though the hard drive is used for memory.)
Note:
- 1 TB = 1 trillion bytes (or 8 trillion bits).
- 1 GB = 1 billion bytes.
- 1 MB = 1 million bytes.
1.9. Computer Specs
There are broadly two categories of memory: "fast" and "slow".
- Slow memory usually requires moving mechanical parts and only electric power is needed. Examples include a hard drive and a CD or DVD. In both cases, a sensor reads bits off of a spinning plate.
- Fast memory usually does not require moving mechanical parts, uses only electric power, and requires less power than slow memory. Examples include the RAM memory used inside of a desktop computer and a USB thumb drive.
In terms of bits that can be stored per dollar of cost,
- Slow memory is usually less expensive.
- Fast memory is usually more expensive.
A 300 GB hard drive costs about $100 while 1 GB of RAM costs about $20. This translates to
- 300,000,000,000 bytes/$100 = 3,000,000,000 bytes per dollar for the hard drive
- 1,000,000,000 bytes/$20 = 50,000,000 bytes per dollar for the RAM
or, RAM memory is 3,000,000,000/50,000,000 = 60 times more expensive per byte.
$$\frac{300,000,000,000\mbox{ bytes}}{$\mbox{100}} = \frac{3,000,000,000\mbox{ bytes}}{\mbox{ dollar}}\mbox{ for the hard drive}$$
$$\frac{1,000,000,000\mbox{ bytes}}{$\mbox{20}} = \frac{50,000,000\mbox{ bytes}}{\mbox{ dollar}}\mbox{ for the RAM}$$
or $$\frac{3,000,000,000}{50,000,000} = \mbox{60 times more expensive per byte.}$$
1.10. Memory types comparison
- Slow memory is cheaper than fast memory.
- Slow memory usually takes up more space. (Smart phones and iPads don't have a DVD player or hard drive.)
- Slow memory is not lost when the power is turned off. Most types of fast memory lose their memory when the power is off (such memory is called "volatile"). An exception is the memory used in a USB thumb drive, which does not lose its memory when unplugged [1].
1.11. Computer Specs
You may have also heard of 32-bit or 64-bit "operating systems". A 32-bit operating system means that the fundamental size of a memory slot used by the software that makes up the operating system is 32-bits. That is, roughly speaking, memory retrieved from the hard disk or in RAM is read, interpreted, and communicated in chunks of 32-bits. (To see why having a fixed size is important, consider how the mail system works. Standard U.S. letters are very easy for the mail system to handle because very efficient machines exist that can quickly process letters of this size. Although the mail system can handle odd-sized objects, they require more time and effort to process.)
Examples of operating systems with both 32 and 64-bit versions include:
Many 32-bit operating systems will not allow you to use more than about 4 GB of RAM. The reason is that each memory slot in RAM requires an address that has a length of 32 bits. With 32 bits, you can create 2^{32}=4,294,967,296 unique patterns (addresses).
2. Problems
2.1. Gigabytes
A gigabyte is roughly equal to one billion bytes. How many bits are contained in one billion bytes?
A. 1 billion bits |
B. 2 billion bits |
C. 4 billion bits |
D. 8 billion bits |
E. None of the above |
Answer |
---|
D. |
1 byte = 8 bits |
$$\mbox{1 billion bytes}\cdot\frac{8\mbox{ bits}}{1\mbox{ byte}} = {8\mbox{ billion bits}}$$ |
2.2. Bytes per dollar
If a 300 GB hard drive costs $100 and a 4.7 GB DVD disk costs $2, which is a better deal in terms of bytes per dollar?
Answer |
---|
300 GB hard drive is a better deal |
Hard Drive: |
$$\frac{300\mbox{ GB}}{100\mbox{ dollar}} = \frac{3\mbox{ GB}}{\mbox{ dollar}} = \frac{3\mbox{ GB}}{\mbox{ dollar}}\cdot\frac{10^9\mbox{ bytes}}{1\mbox{ GB}} = \frac{\mbox{3 x }10^9\mbox{ bytes}}{\mbox{ dollar}}$$ |
DVD: |
$$\frac{4.7\mbox{ GB}}{2\mbox{ dollar}} = \frac{2.35\mbox{ GB}}{\mbox{ dollar}} = \frac{2.35\mbox{ GB}}{\mbox{ dollar}}\cdot\frac{10^9\mbox{ bytes}}{1\mbox{ GB}} = \frac{\mbox{2.35 x }10^9\mbox{ bytes}}{\mbox{ dollar}}$$ |
300 GB hard drive can store 0.65 x 10^{9} bytes more per dollar than the 4.7 GB DVD disk or |
3/2.35 = 1.276 times more bytes with the hard drive than the DVD. |
2.3. Bytes per dollar
If a 2 TB hard drive costs $300 and a 4.7 GB DVD disk costs $3, which is a better deal in terms of bytes per dollar?
Answer |
---|
2 TB hard drive is a better deal |
Hard Drive: |
$$\frac{2\mbox{ TB}}{$\mbox{300}}\cdot\frac{10^{12}\mbox{ bytes}}{1\mbox{ TB}} = \frac{\mbox{2 x }10^{12}\mbox{ bytes}}{$\mbox{300}} = \frac{\mbox{6.67x }10^9\mbox{ bytes}}{\mbox{ dollar}}$$ |
DVD: |
$$\frac{4.7\mbox{ GB}}{3\mbox{ dollar}} = \frac{1.57\mbox{ GB}}{\mbox{ dollar}} = \frac{1.57\mbox{ GB}}{\mbox{ dollar}}\cdot\frac{10^9\mbox{ bytes}}{1\mbox{ GB}} = \frac{\mbox{1.57x }10^9\mbox{ bytes}}{\mbox{ dollar}}$$ |
2 TB hard drive can store 5.1 x 10^{9} bytes more per dollar than the 4.7 GB DVD disk or |
6.6/1.56 = 4.125 times more bytes with the hard drive than the DVD. |
How many DVDs would you need to store the same number of bits as a 2 TB hard drive? |
2.4. Estimate
How many hard drives could you fit in a shoe box? How many USB thumb drives could you fit in a shoe box? Use rough estimates for the size of a hard drive, USB thumb drive, and shoe box.
Show your work at state your assumptions.
How many bytes are stored in the shoe box full of hard drives? How much does it weigh?
How many bytes are stored in the shoe box full of USB thumb drives? How much does it weigh?
What is the storage capacity of a human brain? How much does the average human brain weigh? Cite your sources.
Answer |
---|
1 TB HD = 3.9 x 2.8 x 0.4 inches and 4.3 ounces [2]. |
Each HD has volume of 4.368 cubic inches. 300 cubic inches/4.368 cubic inches 68.7 - estimate is 68 hard drives. |
68 x 4.3 ounces = 292.4 ounces = 18.275 pounds. |
The shoe box will weigh about 18 pounds. |
The shoe box will hold 68 x 1 TB = 68 TB = 68,000,000,000,000 bytes. |
How many bytes are stored in the shoe box full of USB thumb drives? How much does it weigh? |
16 GB thumb drive is 0.8 x 0.6 x 0.3 inches ; 0.3 ounces [3]. |
Each thumb drive has a volume of 0.8 x 0.6 x 0.3 = 0.144 cubic inches. 300 cubic inches/0.144 cubic inches = 2083.33. Estimate is 2083 thumb drives. |
2083.33*0.3 ounces = 625 ounces = 625/16 pounds = 39.0625 pounds. |
The shoe box will weigh about 39 pounds. |
The shoe box will hold 2083 x 16 GB = 33,328 GB = 33.3 TB = 33,000,000,000,000 bytes. |
The human brain stores about 2.5 petabytes (a million gigabytes) of memory. [4] |
The human brain weighs about 3 pounds. [5] |
2.5. 32-bit SSN
Suppose that the government decided to assign every person in the U.S. a 32-bit number (a binary number of length 32) instead of assigning each person a 9-digit decimal number. Would any two people be associated with the same number?
Answer |
---|
The population of the US is about 317 million. 2^{32} is 4,294,967,296, or over 4 billion. No two people would be associated with the same number. Each binary number can be converted to a unique decimal number. So we could also assign each person in the US a unique decimal number. |
2.6. Bit SSN
If we wanted to assign a unique binary number of length N to each person in the world, what is the minimum value of N that would be needed so that no two people had the same number assigned to them?
Answer |
---|
The world population is about 7 billion. From the previous problem we know 2^{32} is 4,294,967,296, or over 4 billion. Increase the binary length to 33 and you get 2^{33} is 8,589,934,592, or over 8 billion. With a binary number of length 33, each person in the world can have their own unique number. |
2.7. OS Memory
If you install a 32-bit operating system twice, do you have a 64-bit operating system?
Answer |
---|
No. Reference [6]. |
2.8. Bits and Bytes
You measure your internet download speed to be 32 Mbits/second. How long (in hours) will it take to download all of the information stored on a DVD? (Assume a DVD holds 4.7 GB).
Answer |
---|
$$\frac{32\mbox{ Mbits}}{1\mbox{ second}}\cdot\frac{3600\mbox{ seconds}}{1\mbox{ hour}}\cdot\frac{1\mbox{ byte}}{\mbox{ Mbits}}\cdot\frac{1\mbox{ GB}}{10^9\mbox{ byte}} = \frac{\mbox{ GB}}{\mbox{ hour}}$$ |
4.7 GB/ = hours or minutes to download. |
3. Activities
3.1. Human RAM
When the instructor says "go," memorize as many digits as possible (in sequence) from the list of decimal digits written on the board. When the instructor says "stop" (after about 30 seconds), write down as many numbers as possible without looking at the board. When you are done, look at the board and compute the number of digits you were able to memorize and write this value on the note card. The instructor will collect the note cards at the end of class and enter the numbers in the "Numbers Remembered" column Spreadsheet. As a follow-up question, the instructor will ask you how many bits per second that you were able to memorize.
How does this compare to how many bits per second a computer can store? (Hint: Think about how long it takes you to copy a file from a thumb drive to a computer.)
Comments |
---|
Assume that you memorized 11 digits in 30 seconds. The next question is how many bits are associated with each digit. If you assume that each digit is encoded using the 7-bit ASCII table, then the answer is that there are 7 bits per digit and you memorized 77 bits in 30 seconds, or 77 bits/30 seconds ≈ 2 bits/second. In class, we used speedtest.net to give us an estimate of average download speed. On the computer in the classroom, the value was about 10 Mb/second = 10·10^{6} bits/second. (The small "b" in "Mb" means "bit"; connections speeds are usually reported in bits/second and not bytes/second because the bits/second number is eight times larger.) Given these numbers, you can conclude that a computer can "memorize" data at a rate that is 10x10^{6}/2 ≈ 5 million times faster! |
3.2. Memory
Every person U.S. citizen is assigned a Social Security Number (SSN) composed of 9 decimal digits. Why isn't the number 5 digits? Why isn't the number 100 digits?
Comments |
---|
In a previous problem you were asked how many patterns a set of three light switches could have. The answer is 2^{3}=8. In another problem you were asked how many patterns a set of 26 light switches could have. The answer is 2^{26}. In the case of the social security number, instead of two possible (on and off) states, there are 10 possible states (the digits 0, 1, ..., 9). So there are 10^{9}= 1 billion possible patterns of social security numbers. Think about the problem this way: You are asked to label 9 boxes (Nboxes = 9) with any one of the ten numbers 0, 1, ..., 9. How many sets of labels could you create? The answer is 10^{Nboxes}. If you were asked to label 3 boxes with any one of the two numbers 0, 1, you could create 2^{3} unique labels. There are 350 million people in the U.S., so each person can have a unique SSN. Bonus question: A license plate is a list of seven numbers and capital letters. How many unique license plates are possible? |
3.3. Computer Specs
Look up the details about your smart phone, laptop, or desktop computer. Which of the specifications listed correspond to memory? Which correspond to fast versus slow memory?
3.4. Better choice
Which is a better deal, a computer with a hard drive that can store
- 50,000 images or
- has a capacity of 100 GB?
Explain your answer.
4. Resources
Articles about how computer memory works: