কম্পিউটার বিজ্ঞান · বই 1 · শ্রেণি 1–9

Primary & Middle School Computer Science

এই বইটি এখনো বাংলা ভাষায় পাওয়া যায় না। সংস্করণ: English।

Primary & Middle School Computer Science · শ্রেণি 1–9

8Memory and Storage

Mia has been playing a game for an hour. She has crossed three rivers and opened two castles. Suddenly the lights go out: the power is cut in the whole street. When it comes back and she starts the game again, she is back at the first river, where the game last saved her progress. The computer forgot everything since then. Why does a computer forget some things and keep others?

You already know

The processor carries out the instructions; the memory holds the work in progress and forgets it when the power goes off; the storage keeps the saved work (Chapter 6).

8.1 RAM: fast, and emptied when the power goes

Definition 8.1 (RAM)

RAM (random-access memory) is the memory of a computer: chips on small boards that hold the information the processor is working on. The processor can read and change any part of it very fast, in any order (this is what “random access” means), but everything in it is lost when the power goes off.

RAM keeps information as tiny electric charges, which must be refreshed many times a second. When the electricity stops, the charges leak away within a moment, and the RAM is empty. That is what happened to Mia’s game: her progress since the last save was only in the RAM.

What Mia’s computer holds before and after the power cut. Only what was saved to the storage is still there.
What Mia’s computer holds before and after the power cut. Only what was saved to the storage is still there.

8.2 Storage that keeps everything

A computer also needs a place where information stays without electricity. There are two main kinds.

Definition 8.2 (Hard disk)

A hard disk stores information on spinning metal disks covered with a thin magnetic layer. A read–write head, at the end of a moving arm, flies just above the surface: it writes by making tiny areas magnetic in one direction or the other, and reads them back.

The head never touches the disk: it floats on a cushion of air thinner than a hair. The disks turn thousands of times a minute, so a hard disk hums and gets warm, and a hard knock while it is running can make the head scratch the disk.

A hard disk seen from above, and the head seen from the side (the gap is drawn far larger than it is).
A hard disk seen from above, and the head seen from the side (the gap is drawn far larger than it is).
A real hard disk with its lid removed: the shiny disk, the arm with the head at its tip, and the pivot at the bottom. Photograph: Zzubnik, public domain.
A real hard disk with its lid removed: the shiny disk, the arm with the head at its tip, and the pivot at the bottom. Photograph: Zzubnik, public domain.

Definition 8.3 (Flash memory and SSD)

Flash memory keeps information as electric charges trapped in tiny cells of a chip, so tightly that they stay without electricity for years. An SSD (solid-state drive) is a storage made of flash memory chips, with no moving part.

USB sticks and the memory cards of cameras and phones are made of flash memory too. Phones, tablets and most new laptops have an SSD instead of a hard disk.

hard diskSSD, USB stick, memory card
how it keeps informationmagnetic layer on spinning diskscharges trapped in chips
moving partsyes: disks and an armnone
speedslower: the head must movefaster
noisea soft humsilent
if dropped while runningthe disk can be scratchedusually no harm

8.3 Measuring size in bytes

How much work can a storage hold? We count it in bytes.

Definition 8.4 (Byte)

The byte is the unit used to measure the size of information in a computer: one byte holds one letter of plain text.

Definition 8.5 (Kilobyte, megabyte, gigabyte, terabyte)

A kilobyte (kB) is 10001000 bytes. A megabyte (MB) is 10001000 kilobytes. A gigabyte (GB) is 10001000 megabytes. A terabyte (TB) is 10001000 gigabytes.

Each unit is a thousand times the one before, as a kilometre is a thousand metres. Let us compute a few sizes.

Example 8.6 (A page, a photo, a film)

  • A page of a story has about 20002000 letters and spaces: about 20002000 bytes, so about 2 kilobytes.
  • A photo of 10001000 by 10001000 coloured dots has 1 000 0001\,000\,000 dots. If each dot is kept as 3 bytes (one for each of three colours), the photo takes 3 000 0003\,000\,000 bytes: 3 megabytes.
  • A film shows 25 pictures every second. If each picture were kept like that photo, one second would take 25×3=7525 \times 3 = 75 megabytes, and one minute 60×75=450060 \times 75 = 4500 megabytes: 4.5 gigabytes. Real films are packed much more tightly; how this works comes in a later year.
The ladder of sizes, from one letter to a terabyte. Each step is a thousand times the one below. A book of 250 pages of 2 kilobytes takes 500 kilobytes, so a terabyte holds two million such books.
The ladder of sizes, from one letter to a terabyte. Each step is a thousand times the one below. A book of 250 pages of 2 kilobytes takes 500 kilobytes, so a terabyte holds two million such books.

Remark 8.7 (10241024 instead of 10001000)

Some programs count a kilobyte as 10241024 bytes instead of 10001000, for reasons we meet in a later year. The difference is small, but it is why a storage sold as 500 gigabytes may be shown by the computer as a little less. The careful name for 10241024 bytes is a kibibyte (KiB).

History — Five million letters on fifty disks

The first hard disk sold for a computer was shipped in June 1956. It was a cabinet about 1.5 m1.5\,\mathrm{m} high and 1.8 m1.8\,\mathrm{m} wide that weighed, with its air pump, more than a tonne. Inside, 50 metal disks, each about 61 cm61\,\mathrm{c}\mathrm{m} across, turned 12001200 times a minute. All together they held five million letters: less than 4 megabytes, the size of a single photo today.

The stack of disks of a 1956 hard disk, in a museum. Photograph: Arnold Reinhold, CC BY-SA 3.0.
The stack of disks of a 1956 hard disk, in a museum. Photograph: Arnold Reinhold, CC BY-SA 3.0.

8.4 Why keep a backup

Storage keeps work when the power is off, but it is not safe forever. A hard disk can wear out, a laptop can be dropped, lost or stolen, a file can be deleted by mistake.

Definition 8.8 (Backup)

A backup is a second copy of files, kept on another storage, in another place, so that they can be brought back if the first copy is lost.

Backing up the family photos on an external disk.
Backing up the family photos on an external disk.

Safe use

Keep a backup of the work you care about, on another device and in another place (a disk kept at home for a school laptop, for example). Update it often: a backup only holds what was there on the day it was made.

8.5 Exercises

Exercise 8.1 ★

The power goes off. Which keeps the work: the RAM or the SSD?

Solution

Solution of Exercise 8.1.

The SSD. The RAM is emptied when the power goes off.

Exercise 8.2 ★

Give two differences between a hard disk and an SSD.

Solution

Solution of Exercise 8.2.

For example: a hard disk has moving parts (spinning disks and an arm), an SSD has none; an SSD is faster; a hard disk hums, an SSD is silent; a hard disk can be scratched if it is knocked while running.

Exercise 8.3 ★

How many kilobytes are there in 3 megabytes?

Solution

Solution of Exercise 8.3.

3×1000=30003 \times 1000 = 3000 kilobytes.

Exercise 8.4 ★

A page of text takes 2 kilobytes. How many such pages fit in 1 megabyte?

Solution

Solution of Exercise 8.4.

1 megabyte is 10001000 kilobytes, and 1000÷2=5001000 \div 2 = 500 pages.

Exercise 8.5 ★

Put these sizes in order, from the smallest to the largest: 3 GB, 500 kB, 2 TB, 40 MB, 900 bytes.

Solution

Solution of Exercise 8.5.

900 bytes, 500 kB, 40 MB, 3 GB, 2 TB.

Exercise 8.6 ★

Why should a backup be kept in another place than the computer it copies?

Solution

Solution of Exercise 8.6.

If the computer is lost, stolen, or broken by a fire or a flood, a copy kept next to it may be lost at the same time. A copy kept elsewhere survives.

Exercise 8.7 ★

Read the ladder of sizes: how big is one photo? About how many such photos fit in 1 gigabyte?

Solution

Solution of Exercise 8.7.

3 megabytes. 1 gigabyte is 10001000 megabytes, and 1000÷31000 \div 3 is 333 with 1 left over: about 333 photos.

Exercise 8.8 ★

A USB stick holds 64 gigabytes. Each photo takes 4 megabytes. How many photos fit on the stick?

Solution

Solution of Exercise 8.8.

64 gigabytes are 64×1000=64 00064 \times 1000 = 64\,000 megabytes, and 64 000÷4=16 00064\,000 \div 4 = 16\,000 photos.

Exercise 8.9 ★★

A story has 12 00012\,000 letters and spaces. How many kilobytes does it take?

Solution

Solution of Exercise 8.9.

12 00012\,000 letters and spaces take 12 00012\,000 bytes, and 12 000÷1000=1212\,000 \div 1000 = 12 kilobytes.

Exercise 8.10 ★★

In the story at the start of this chapter, which part of the computer forgot Mia’s progress? Where was the progress she found again?

Solution

Solution of Exercise 8.10.

The RAM forgot it: her progress since the last save was only there, and the RAM is emptied when the power goes off. The progress she found again (the first river) was the game’s last save, kept in the storage.

Exercise 8.11 ★★

The class keeps all its work on one school computer. Make a plan of backups: on what, where, and how often.

Solution

Solution of Exercise 8.11.

Many plans are good. For example: every Friday, the teacher copies the class folder onto an external disk; there are two such disks, used in turn, and one of them is always kept in another room or at home. A good plan says on what the copy is made, where it is kept (not next to the computer), and how often (at least once a week).

এই অধ্যায়ে সংজ্ঞায়িত পরিভাষা-শব্দ

পরিভাষায় সব 1050 টি শব্দ দেখো