How does computer memory work?

964 views

When you physically save a file, like a photo or a word document, how is it physically saved? Where is that document physically? I believe there are two modern memory devices, HDD and SDD, but how do they work? How can a Hard Disk Drive be ‘scratched’ the right way to save my essays? And when I save a file to a flash drive, where on the flash drive are my documents? How can another computer read that flash drive? Is it a series of electrons or switches moved to remember each part of the document, like the 38th word on the 4th page?

In: Technology

4 Answers

Anonymous 0 Comments

A disk drive is kind of like a book. A book has a bunch of pages. At the front of the book is a bunch of pages containing special information: a table of contents. If you want to find where a particular poem starts (let’s say it’s a book of poems), you look in the table of contents, and it will tell you the page to turn to. The table of contents is always stored at the start of the book.

Hard drives and SSDs work the same way. Instead of pages, they will have a bunch of blocks of data. Like a book, a hard drive or SSD will have a special set of blocks which contain the directory, which is just like a table of contents.

Part of the directory is a list of where all the blank blocks are. When you save your photo or document, the computer figures out how many blocks it’s going to take up. It then looks up in the directory where there is an empty set of blocks. It removes those blocks from the empty list, and writes your file to them. Then it adds an entry into the directory containing the name of your file, and what block number it starts on.

Different computers can figure out where your document is stored simply by looking up the file name in the directory.

Anonymous 0 Comments

As /u/MrOctantis said, you are talking about data storage, not “memory”; although effectively, they are both “storage” – “memory” is generally used to refer to short term storage for the purpose of running the computer, while disk “storage” is for long term file storage. Your question is clear that you’re asking about the latter.

First thing you need to know is that computers are digital. That means every file in a computer is ultimately made up of zeros and ones. The HDD uses a magnet to magnetize or demagnetize each spot. Magnetized is a “one” and demagnetized is a “zero”.

In a text document, every keyboard character has a specific code of zeros and ones that mean that character (basically just like morse code but with 0 and 1 instead of dot and dash). So the text “hey” would be saved as “01101000 01100101 01111001” (without the spaces). So a pure text file of “hey” would need 24 “bits” of hard drive space to record (word processor files like Word .docs record formatting and a whole bunch of stuff other than just your words, so they are larger).

A hard disk drive has one or more spinning metal discs inside (google it, and you’ll see them). The data is not “Scratched” on them like a vinyl record. You would not “see” any evidence of them having data on them. The disk is mapped out and divided into tiny spots each representing a “bit” of data. It’s not physically divided, just that the programming of the drive has a “map” and knows where on the disc to look for each bit.

The drive also stores in one particular place a list of every file and which spot(s) of the drive that file is stored in. The computer will try to keep your file in a single consecutive line on the disk, but there isn’t always enough consecutive free space for your file, so it may save it in various pieces across the disc.

An ELI5 analogy would be if you had a big page of graph (grid) paper. You wanted to write out a bunch of words, so you did it in morse code. with dots as empty squares and dashes coloured in. But instead of writing in order, you coloured in random squares. Then you had a separate piece of paper that mapped out which squares made up a word, battleship style (A4, D1, E12, X6, H11, etc.)

The discs are read much like a record player. The discs spin and there is an arm that can move from the outside of the disk to the inside – except instead of following a grove in a continuous line, the arm on an HDD moves in an out rapidly to read whatever spots it needs to to access a file. This constant random motion is part of what makes HDDs wear out (fail).

HOW the drives are controlled to look in the right places is all just computer programming to tell the arm how to move to read or write in the correct location, finding an empty spot to write on.

A SSD is just a large flash drive. It is the same basic technology. Both store files on computer chips. It is “non-volatile” storage, which means the data doesn’t disappear when the computer turns off. These chips have a transistor for every bit of data. It’s not really that easy to simplify, but it’s basically part of an electronic circuit that can be in an “on” or “off” state based on whether it’s electrically charged or not. So “charged” is 0 and “not charged” is 1. So in this case, it does have to do with some electrons (That’s what makes it charged).

The difference between flash/SSD memory and HDD is that SSD memory works based simply on sending electricity through the chip. There is no moving magnetic arm. So it’s generally equally fast to read data from anywhere on the chip, whether it’s together or in random places.

HDDs are faster if the data’s all together because the arm doesn’t have to move very much. But they are also slower in general than SSDs because electricity moves faster than a mechanical arm and spinning disc.

Anonymous 0 Comments

>Is it a series of electrons or switches moved to remember each part of the document, like the 38th word on the 4th page?

Yes, effectively.

I don’t know enough about flash drives to ELI5, unfortunately. It’s a big story, but the cool part is it all comes down to quantum mechanics in the end (you could do it other ways, but your flash drive would no longer fit on your keychain. Not by a damn sight).

I’ll instead tell you about that 38th word on the 4th page – but we’ll forget the 4th page, because the word is enough. It’s up to font size and page size to determine what page it lands on.

So those switches can be set to 1 or 0. Your entire essay can be represented as a string of 1s and 0s. Some information has nothing to do with the paper in your hand once you’ve printed it. Things like the filename. Let’s just focus on the text of the essay, and we’ll keep it simple and pretend it’s all one size, one font, no pictures, basically something you’d type in notepad.

[Take a look here](http://sticksandstones.kstrom.com/appen.html)

Every letter of the alphabet (including capital letters) can be coded by an eight-long sequence of 1s and 0s. You could also use that dumb cipher every kid uses once (A = 1, B = 2, …) to encode it, but remember that the switches can only be 1s and 0s for a computer.

So once I knew WHERE on the storage your essay starts, all I have to do is read groups of eight 1/0s and translate them to letters. And then maybe a special sequence of 1/0s tells me when to stop reading. Let’s just pretend it’s 11111111, for the sake of illustration.

You might notice something though. That list I linked didn’t include spaces. Also how would I know when you start a new paragraph? Or punctuation? Or this jerk: ~

Well, there are 2^8 = 256 ways I can write a combination of eight 1s and 0s. And we only used 26 + 26 = 52 of them for letters. The rest can be used to represent “start a new line” or “space” or “~”.

Does that make sense?

Anonymous 0 Comments

What you’re talking about is called disk or storage. Memory is a different part of the computer, also called RAM.

With a traditional disk drive (HDD Hard Disk Drive) there is a spinning metal disk that is given magnetic charges that represent ones and zeros. Those ones and zeroes can then be read back as data. The charges are wrapped around the disk in a spiral, as if you took a credit card magstripe and layed it along a vinyl record. HDD’s can increase storage space by having multiple spinning disks (platters).

Modern SSD (Solid State Drive) storage use the same technology as a USB flash drive, Non-Volatile NAND flash memory. Simply explained, there are large numbers of tiny no-moving-part electronic switches made from transistors, each switch representing a one or a zero, and the switches being organized such that they can be represented as a linear series of ones and zeroes, just like an HDD.

When you save a file onto a drive, the computer saves the ones and zeroes into a spot with enough room to fit the ones and zeroes, then adds that spot to a table of contents at the start of the drive.

Another computer can read the files off of the drive by looking at the table of contents to find where different files begin and end.