How Computers Store Data – Intro to Computer Science

[Narrator] Now you understand a little about how to use a complex data structure like a list. I’m going to talk some about how computers actually store data. To use a list you don’t really need to understand this, but it will certainly give you a better appreciation of what’s going on inside the computer. In order to store data you need 2 things: you need something that preserves state and can be in more than 1 state, 2 states is enough, and you need something that can read the state of that thing. One way to think about that is to think about a light switch. Here we have a switch; we have our light bulb, presumably it’s also connected to some power source, and when we flip the switch that turns the light bulb on. It changes its state. The light bulb has 2 different states. It can be off or on, so that means it can store 1 bit of data. In the next lecture I’ll talk more about what a bit means, but something that can have 2 distinct states can store 1 bit, and if we had enough light bulbs well we could store many, many bits, which would be enough to keep track of any amount of data that we wanted. We don’t need just something that can change state though. We need something that can also sense the state. With a light button, well, that could be someone’s eye. You can see if the light bulb is on or off, and then you know its state. You could have a light sensor that would do that if you wanted to make that automatic. The way computers store data is sort of like this, except for it’s using much less energy and much less space than a light bulb to store the state of data, and it’s not using a human eye. It’s using sensing electrons or sensing magnetism to sense the state of something. That’s 1 way to store data is like a switch, and the fastest memory in your computer works that way. The data that’s stored directly in the processor, which is called the register, is stored like a switch that makes it very fast to change its state, to record what the state is, but it’s also like a light bulb. It means that when we turn the power off we lose the state, so it’s not persistent, and it’s a lot more expensive than other ways of storing data. The other way computers store data is more like a bucket. We could represent having a 1 by having a bucket that’s full. We could represent having a 0 by having a bucket that’s empty. Then to check the state of the bucket, we could weigh the bucket or look at the bucket to figure out whether it’s full or empty, and the difference between buckets and light bulbs is– –well, buckets leak a little bit. Water is falling out of the bucket and they also evaporate. If we want to store data using a bucket it won’t last forever. Eventually the bucket will evaporate, and we can’t tell the difference between a 0 and a 1, and I should also point out that the amount of water in the bucket–well, we’re going to have to decide some threshold where if it’s above that threshold we think that it represents a 1. If it’s below that threshold we think it represents a 0. We could certainly imagine having many more levels than just 2 in the bucket. For computing it’s almost always the case that we want to use a digital abstraction where everything only represents 1 of 2 things. That makes it less likely that we get it wrong. As the water evaporates we know it’s still a 1 until it gets really near the bottom, but when it gets near the bottom there’s going to be some left, and we want to know when it becomes a 0. When we’re doing this with electrons we don’t call it a bucket. We call it a capacitor. The memory in your computer that works this way is called DRAM.

Leave a Reply

Your email address will not be published. Required fields are marked *