5.How does data get stored in Computer

Recall the concepts & the block diagram we have framed in our mind so far. Redraw here

5.1 image

Look at the right hand side — we see two boxes ending with memory — Primary Memory & Secondary Memory. What are they? Why are they used?

Well it is easy to answer. It is the container which holds the data either permanently or temporarily. The importance of memory is needless to say, just like importance of container during cooking. It’s like if someone sent you into a kitchen with no cooker, kadhai, plates & glass.

ANALOGY 5.1 — Sam’s mother gave instructions to Sushil. Sushil will take instructions on a paper. So paper is kind of memory which stores the instructions permanently. He may choose to remember the instruction in his brain. That is also a memory.

Secondary Memory — As a user, the instructions you gave in high level language in your program — do you want to give the same instruction again & again? NO right. Secondary memory is the hardware component responsible for storing our instructions as well as data (in fact everything we see on the computer) permanently.We know that computer is an electronic device which works with electricity. Without electricity it is just a dustbin. Once electricity supply is off, there is no way for computer to serve your instruction when electricity supply is on again. The only way is secondary memory. The data (When I say data, it includes everything ranging from instructions in program to any data we see on computer.) which is stored on secondary memory does not get lost even when the electricity supply is cut off. If you have ever worked on a computer & if you have saved any doc file or created a drawing on MS Paint & saved it or saved your game session to resume further because you were tired, in all these cases of examples, the data is getting saved into secondary memory.

Secondary memory is a category under which many hardware devices fall. The first such hardware in this category is hard disk. In olden days it used to be magnetic tape. Nowadays all computers are equipped with hard disk. Think of other secondary memory devices & comment.

Primary Memory: The instruction which CPU is supposed to execute must be present in primary memory. In other words, instructions or data to be executed by CPU is just brought from secondary memory to primary memory. Primary memory is much faster than secondary memory when we compare them with speed which they read or write data. CPU has to work at great speed. That’s why the purpose for which we human have created the computer. But if CPU has to read & write data from secondary device the purpose of computer could not be met.

CPU asks secondary memory — Ok, give me this & next instruction you have stored.

Secondary memory — (like 100 years old human) — OOOK, give me some time.

Secondary memory takes some time to return the instruction to CPU. Till that time CPU is waiting. We the user are waiting & we can’t wait. Primary memory is built of separate hardware technology as compared to secondary memory. It retrieves many instructions from secondary memory well in advance & provides instructions to CPU as soon as it demands.

ANALOGY 5.2 — Sushil went to the market to execute instruction of Sam’s mother. If he is reading instructions from the paper to do the task then he is reading from the secondary memory. If he has memorised all the instructions, then he will be able to shop faster. In this case, he is using primary memory.

Paper ≡ Secondary memory
Sushil’s brain ≡ Primary memory (Sushil)

Caution — Computer can sleep. Human can sleep.

Computer can be switched off & on multiple times. & For each restart, Primary memory nothing remains but the data in Secondary memory persists. Sushil cannot be switched off & on multiple times.

Primary memory — Faster, Forgets
Secondary memory — Slower, Stores permanently

How is data stored in the memory?

As we have already discovered that computer (CPU) understands the language of binary only (i.e only 0 & 1), memory has no exception. All your instructions & data whether it is your girlfriend’s wallpaper, or the favourite game on your Operating System or music or anything you see on computer, is actually stored as combination of 0s & 1s in memory (both primary & secondary). Obviously, when King understands French, should doesn’t his Minister understand French?

ANALOGY 5.3 — Have you ever gone to a temple & submitted your shoes at shoe counter? Or a bigger counter? What do you see? You see shoe rack with a no. assigned to each individual box in the rack. The incharge keeps your shoe in one of the boxes & gives you token corresponding to the no. assigned to that box. Data is stored in the memory in the same way. Just replace one pair of shoe with one digit of binary (either 0 or 1). ✓

You can imagine the memory as a large shoe rack containing millions of boxes with # assigned to each box & each box stores either 0 or 1. Electronically, if current is passing through a box & it is lighted up, it is 1 else 0.

00110100
1 1 0 0 1 0 1 0
1 1 0 1 0 1 0 0

Each box is called memory block in computer terminology. House analogy is same — i.e. box in the shoe rack. So memory block is the smallest unit of memory. Similar to how molecules are the smallest unit of any matter (solid/liquid/gas). $ Memory block cannot be further sub-divided.

Measurement: How do we measure this one memory block? In cm? mm? nm? ml? ng? Well we can measure each block with nanometre like 500 nm. But then it would make things complex. Scientists thought we need to ultimately measure the data one or more memory blocks contain. Then instead of metres, litres or gram, why not use a separate unit for measuring block. And hence they introduced a new unit called bit. So, one memory block is 1 bit. So, one memory block contains 0 & or 1. Whether a memory block contains 0 or 1, how much size of data does it contain? Ans is 1 bit. How much is the size of 1 memory block? Ans is 1 bit.

01

What is the size of above memory blocks?
Ans is 2 bits.

00

What is the size of data above memory block contain? — Ans is 2 bits.

When you go to your local grocery shop, do you say “give me 1000 ml of milk”? NO right? You say “give me 1 L of milk”. Why do you say “like that”? It is because ml is too small unit & for the quantity of milk you need, although you can utilize ml also to ask vendor but you have to append 1000 with it & that becomes cumbersome. As numerical figure keep on increasing, it becomes cumbersome. Hence other units are brought in. Just like like in this case. Same is the case with bit also.

10101110

What is the size of above memory block? It is 8 bits. That’s very common. However scientists have brought the new unit as 8 bits itself. We call it byte. Hence, here we can say that the above memory blocks contain 1 byte of data. When someone may ask — why new unit at just 8 bits? Well when we write program, we will see that we are using 8 bits data more often. Older computers used 8 bits of data most often & hence the scientist decided to have it.

1011011011

Now what is the size of above memory blocks?
1 byte 2 bits.

Similarly, there are higher units —

  • 1024 bytes make 1 Kilobyte
  • 1024 Kilobytes make 1 Megabyte
  • 1024 Megabytes make 1 Gigabyte
  • 1024 Gigabytes make 1 Terabyte

When CPU is executing instructions of a program, it reads bits of data from primary memory & writes bits of data onto primary memory multiple times.

ANALOGY 5.4 — Imagine yourself as CPU when you are cooking meals in the kitchen.You are supposed to use multiple containers to pour & repour & drop the items.

Previous Article
Next Article