Hardware - CS50's Understanding Technology 2017

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[MUSIC PLAYING] DAVID J. MALAN: Odds are, you use a computer most every day. But what's going on inside of that laptop or that desktop. Well, inside of a computer are all these 0s and 1s. And you may have heard, indeed, that computers only understand 0s and 1s, or the, so-called, binary system. But if computers today can do so much, how can they do so much if they can only speak 0s and 1s and not even the entire alphabet that we humans have. Well, consider this. Back in our human world, you might recognize a pattern of symbols like this as the number 123. But why is that? After all, all I did was draw three shapes, really, three glyphs, or three symbols or digits on the screen. But each of these digits has some predefined meaning. If, in fact, if you went to grade school like I did and you learned numbers in this way, odds are, you might recall, that this rightmost column is the so-called one's column or one's place. Then this is the ten's place. And then this is the hundred's place. Now why is that significant? Well, the reason that 1, 2, 3-- that pattern represents the number we humans know is 123 is that there's a bit of arithmetic going on here. This, after all, means that you should do 100 times 1 plus 10 times 2 plus 1 times 3. That, of course, gives us 100 plus 20 plus 3 or 123. In other words, there's a pattern to these digits, and there's a meaning behind each of their places. Well, it turns out that computers only, indeed, understand 0s and 1s. They can't count as high as 2 and 3 and 4 in the same way we humans can. But they use those 0s and 1s in exactly the same way. In fact, consider this. If we consider this pattern 0, 0, 0, to be inside of a computer, and that's what the computer is thinking, well, what number might this be. Well, the spoiler is that this is actually going to represent just 0, thankfully, just like in our human world. But why is that the case? And how can we count higher than 0? Well, in the computer world, realize that these places are just a little different. This is still the one's place, but this next one is not the ten's place anymore. It's, instead, the two's place. And this next place is not the hundred's place anymore. It's, instead, the four's place. And if you think about this, there's still a pattern. Previously, it was 1, 10, 100, and then if we kept going, 1,000, 10,000 100,000, and so forth. And here, too, there's a pattern. 1, 2, 4-- and if I kept going-- 8, 16, and 32. And so, in our human world, we tend to use powers of 10. 10 to 0 is 1, 10 to the 1 is 10, 10 to the 2 is 100. And in the computer world, this is 2 to the 0, which is 1, 2 to 1, which is 2, 2 to the 2, or 2 squared, which is 4. 2 to 3 would be 8 and so forth. So all we're doing is changing the base that we're using, so to speak. Instead of powers of 10, we're using powers of 2. And so why is this number 0, 0, 0 the number we humans know as 0 itself? Well, again, if we just do the math, 4 times 0 plus 2 times 0 plus 1 times 0 is, of course, 0 plus 0 plus 0 or the number we humans know as just 0. Well, what if we do another number altogether? Suppose we do this pattern 0, 0, 1. Well, what number does this represent? Well, if you consider the same columns-- 1, 2, and 4-- this means we have four times 0, which is 0, 2 times 0, which is 0, 1 times 1, which is 1. So this is the number we humans know as 1. All right. So not all that interesting yet, but what about the number 2? How, in binary, bi meaning two, and the 2 being a 0 and a 1, how, in binary, can I now count as high as 2? Well, if this is my one's place, this is my two's place, and this is my four's place, what digits do I want to put below those places if the only digits I have at my disposal now are not 0 through 9, but just 0 through 1? Well, I don't need a 4, so I can make that a 0. I do need 2 if I want to count to the number we know as two, so I'm going to put a 1 there. And I don't need an extra 1 because an extra 1 would give me 3. So I'm going to do this. And so a computer, to store the number we humans know as two in decimal which store it in binary as 0, 1, 0. Because that's 4 times 0 plus 2 times 1 plus time 1 times 0, which, of course, is going to give me the number 2. What about 3? Well, in the world of computers, if we again have our one's place two's place and four's place, how do I now arrange my zeros and ones to give me the number we know as 3? Well, let's see I don't need a 4. That would be too big. I do need a 2, and I do need a 1. And that is now going to give me 3. Because 2 times 1, 1 times 1 is 2, 1 times 1 is 1, 2 plus 1 is 3. Now what about 4? How do I count as high as four? Well, it's even easier, perhaps because we just need a single 1 in this case. We just need 1, 0, 0. Because now I have one 1 in the four's place. And now let's skip ahead. Suppose I want to count up as high as, let's say, 7? What do I do? Well, 7, let me take a byte out of that. So this gives me 4. Let me take a two, that gives me 4 plus 2, that's 6. Let me give myself another 1. 1, 1, 1, in binary, equals 7. Now what about a number like 8? I can't seem to count as high as 8 unless I give myself another bit. But that's OK because, just as in the human world, if you have not a three-digit number, but a four-digit number, you simply add another place. So it might be the ones column, the tens, the hundreds, the thousands. In this case, though, it's going to be the ones, the twos, the fours, and the eights. And so if we want to count as high as 8 in binary, we might do 1, 0, 0, 0, which, of course, gives me 8 times 1. And then everything else is 0. So that gives me the number 8. So even though computers only speak 0s and 1s and only understand the so-called binary system, they can still count as high as we humans can. And they fundamentally do it, really, in the same way. It's just that they have a smaller vocabulary. But why do they have a smaller vocabulary, especially when they can do so much? Well, it turns out that, in the physical world, it's just convenient to be able to represent only two states instead of 10. And by states, I mean digits, in this case. It's a lot easier in the human world, not to represent 10 possible values 0 or 9, but just two-- 0 and 1. And we could have called those digits anything we wanted, but we humans just standardized our numbers like that. But 0 and 1 is nice because if you think of one of these binary digits or bits as just being a light bulb-- it's either off or on. You can think of a 0 as a light bulb being off and a one as being a light bulb being on. And light bulbs, of course, in our human world just need electricity to run. And so, if we somehow get electricity into our computer laptop, desktop, or whatnot coming from the power outlet in the wall or some battery, well, that would seem to be sufficient input in order to turn a light bulb on or off, to turn a switch, really, on or off. And indeed, that's what's inside of our computers-- transistors, otherwise known as switches. And these transistors, which now number in the billions in the most modern of computers are tiny, tiny, tiny little light switches, if you will, that, if turned on, allow us to store 1s, if turned off, allow us to store 0s. And using those many, many, many transistors, can we store values, can we store data, can we compute, and can we actually do everything we can today with our modern computers. Let's make this more real and try out some actual light bulbs. So here are some light bulbs clamped into these desk lamps. And suppose now that I have these light bulbs here to represent bits or binary digits. So each of these light bulbs can represent a 0 if it's off or a 1 if it's on. And if we think about the same system that computers use, let's think of this bulb here as being the one's place, this bulb here as being the two's place and this bulb here as being the four's place. So what number am I currently representing if all of these light bulbs are off? Well, that's like having 0, 0, 0. Since they're all off, so that's the number we humans know in decimal, dec meaning 10, as 0. What about if I turn on just this one light bulb here? What does that represent? This, again, is the one's place, the two's place, and the four's place. So this, of course, represents the number we know as 1. Now, if I go ahead and simultaneously switch these, this is still the one's place, the two's place, and the four's place. So what is this? This, now, is the number we know as 2. How do I count as high as 3? I don't want to keep going down the line. Instead, I want to turn this 1 back on because that means I get a 1 plus a 2. I don't need the 4, which is great, because now I have 3. How do I get to 4 then? Well, let me turn both of these off, turn this one on, and now, of course, this is the four's place. So this is a 4. If I turn this one back on, now we're up to a four's place and a one's place, so that gives me 5. If I turn this off, this on, that gives me a 4 plus a 2, or a 6. And finally, if that turns on, I have now a 7. Unfortunately, I can't count as high as 8 unless I go get myself another desk lamp, but for that we just need another bit. But this is all very fine and good, but all I can represent thus far, it seems, are numbers. How, though, do I represent letters of the actual alphabet, A through Z? How do I represent words or paragraphs, let alone emails, and any number of other features that computers today support? Well, for that, we're going to need to make a decision. We're going to need to decide what patterns of bits to use to represent those higher level notions like letters words and paragraphs. So for that, I've got an idea. So at the end of the day, all computers can store is, indeed, 0s and 1s. And from those zeros and ones, of course, can we count higher so long as we have a mapping from binary to the numbers we know as decimal. But, of course, we want our computers to do more. We want to be able to express words and even other types of data. So how do we do that? Well, we need to come up with a standardization, a mapping, from 0s and 1s, or really just numbers, to the letters that we want. And it turns out, that some years ago what humans decided to do was this. Now, at first glance, this might be a little overwhelming. This is just a screenshot of a chart from asciichart.com. An ASCII chart is a chart of ASCII characters, American Standard Code for Information Interchange. And this is simply a mapping from decimal numbers to letters. And so on let's notice a few of these. Notice here that 65 apparently maps to A, 66 maps to B, 67 maps to C, and so forth. Meanwhile, 97 maps to lowercase a, 98 to lowercase b, 99 to lowercase c, and so forth. And there's also mappings from punctuation symbols to all the letters of the alphabet that you may know. So why is this significant? Well, it turns out that even though computers only store 0s and 1s, we, of course, use them in different ways. We have programs like Notepad on PCs, or TextEdit on Mac OS, or Microsoft Word on both platforms, or Google spreadsheets, or Google Docs, or the like. And so we have all these different programs that is designed to do one thing or the other. And so those programs essentially decide, in their own context, whether to display patterns of bits as numbers or as letters or, in turn, words and paragraphs. So it's entirely context-dependent. At the end of the day, all the computer is storing is 0s and 1s, but it's up to the program to interpret those 0s and 1s in a certain way. And so, if a program like Microsoft Word or Google Docs sees a pattern of bits in a file that represents the decimal number 65-- it's still pattern of 0s and 1s expressed in binary, but of course, we've seen how we can convert that to decimal. So if a computer is ultimately storing a pattern of 0s and 1s that represents the decimal number 65, the computer, in this case Microsoft Word, or Google Docs, and the program running there, is going to interpret that pattern, not as the number 65, and not as a whole bunch of 0s and 1s alone, but as the capital letter A. And that's what you'll see on your screen. If it, instead, sees a pattern of bits that represents the decimal number 66, Microsoft Word or Google Docs is going to show, instead, the capitol letter B. If the pattern of bits instead represents the decimal number 97, that program is going to display the lowercase letter a or any number of other letters from the alphabet. And so we just had to decide in advance what mapping to use, what code to use that maps numbers to letters. And in fact, you'll notice that quite a few characters are absent from the screen here. In fact, if you speak some language and write some language other than English there might be some characters that you can express with just this range of values. In fact ASCII originally only used 7 bits total. Or if you round up, 8 bits total, for what's called the extended ASCII. And it turns out, that's not nearly enough patterns of bits, 256 maximally, that you can use to express characters that you might see in certain Asian languages or symbols that just simply are not depicted even yet on the screen here. So there are other systems, not just ASCII. Something called Unicode, for instance, is a superset of what you see here. And that actually allows us to express any number of characters from English and Asian languages and beyond and, in fact, even things like the emoji characters-- the smiley faces, and other such characters that you might now use increasingly on your phone, your desktop, or laptop. Those two are expressed ultimately as just patterns of bits. And the world, for the most part, has simply standardized on what pattern of bits represents a happy face, what pattern of bits represents a sad face, and beyond, in that system there is Unicode. So let's take an example. Suppose that you see this pattern of bits somewhere in a file. And you, in this context, say are Microsoft Word, or Google Docs, or some program designed to display, not numbers like a calculator, but words and letters like a word processor or a text editor. Well, what is this pattern of bits? Well, we haven't seen this many bits before, but it looks to be like two patterns of eight. And in fact, it turns out that anytime you have eight bits here or eight bits here, humans generally refer to this as a byte, B-Y-T-E. So a byte is just eight bits. And it's a slightly more useful measure because it's a lot bigger than a single bit, which can, of course, only represent 0 or 1. A byte can actually count higher. So what are the columns here if we look only at this number at left? This is my 1's place, 2's, 4's, 8's, 16's, 32's, and 64, and then 128. So 64 plus 8, if I do that arithmetic, that gives me 72. Now let's consider the pattern of bits on the right. Again, my 1's place, 2's place, 4's 8's, 16's, 32, 64, 128. Now notice, these patterns are actually almost identical. We've got a 1 in the 64's place, we've got a 1 in the 8's place, but we've also got an extra one in the 1's place. So if this was 72, and this pattern is identical except for this last bit here, which adds 1, this must be 72 followed by 73. And I've put a space here, visually, just to separate the fact that these are, indeed, two separate bytes. And I claim now that, yes, while you could interpret these as two decimal digits, 72 and 73, it turns out, per the ASCII system, we could map 72 and 73 to alphabetical letters. What might those letters be? Well, if we consider our chart again, 72 apparently gives us a capital H. 73 gives us the capital I. And, voila, 72 followed by 73 in a computer's memory, apparently, is how a computer would express HI. And of course, if we used more bytes, and therefore more bits, and therefore more numbers, we could represent even larger words than just H I, or HI. But that's exactly how a computer, underneath the hood so to speak, would store a word like HI. Now what is indeed using these patterns of bits? And what is a computer actually doing at the end of the day? Well, for that, we need to take a look under the hood, so to speak. This is what Intel inside means. If your Mac or your PC comes with an Intel Inside, as goes the marketing slogan, that means that your computer has inside of it a CPU, a Central Processing Unit that looks a little something like this. It's a pretty small device. It's not quite as big as this. This, of course, is not to scale. It wouldn't fit in your actual laptop or desktop. But what you see is two sides. This is just a mental case and a nice big logo there. And then, if you flip this around, you see the other side, which generally has a whole bunch of golden pins that actually interconnect to a device inside of the computer. And now what is that device? Well, that device, we'll soon see, is something called the motherboard. A motherboard is a circuit board, so a big piece of silicon or plastic-like material that has a lot of lines running back and forth on it, and often has sockets, essentially, a bunch of tiny little holes into which devices like this fit so that you can put this inside of a computer and actually have it clamped down on something. Now what does it mean to be a CPU? Well, the CPU is the brains of your computer. It's the thing in your computer that does all of the work, all of the thinking. Now what kind of thinking does a computer need to do? Well, if you're feeding it all of these numbers, and you're feeding it all of these letters, you want to maybe perform math on those numbers. You might want to display those letters on the screen. You might want to add or delete those letters if the user is using a word processor and typing new characters or hitting delete. And so a computer needs to do all of that thinking and work for the human. And the peace inside of the computer that does most of that work is, indeed, this device here called the CPU. Now, it turns out, that CPUs today are actually getting pretty fancy. And inside of a CPU, typically, is one or more cores, so to speak. And a core is really what's doing the work. And it is the device inside of this device that actually can do addition, and subtraction, and multiplication, and division, and other operations still loading information from memory, saving information to memory. And so a CPU like this might have one, or two, or four or more cores, which means it can do one, or two, or four or more things at a time. And that's great because, these days on my Mac or my PC, I might double-click a whole bunch of icons. I might be running multiple programs. I might be chatting with a friend over here. I might be working on my homework over here. And so I might have a lot of programs and a lot of files open simultaneously. And thanks to multiple cores inside of a CPU, can each of those programs continue running in parallel. Maybe one is printing something to my printer. Or maybe one is playing back a video. Maybe one is spell-checking a file. Any number of operations can literally be happening simultaneously. Now moreover, it turns out that the fanciest of use today, from Intel especially, also support something called hyperthreading, which means you might just have one CPU or one core, but thanks to some technology built into the CPU itself, it will present itself to the computer, to the operating system, Mac OS or Windows-- more on those in a bit-- as though it's actually two CPUs or two cores. And so, thanks to technology, can your computer actually think it has even more computational power than it actually has, thereby allowing it to take advantage of downtime or slow running programs that might still allow you to run multiple things simultaneously. But we'll come back to that in just a bit. Now, not all devices have just a CPU connected to a motherboard. Some devices, instead, have a CPU and more all interconnected all at once. And these things are generally known as systems on a chip. And they're especially popular in things like tablets or iPads these days, game consoles like Xboxes or even things like the Raspberry Pi, which is a very small computer that looks pretty much like this. Also not to scale, this thing could fit in the palm of my hand. And this has, not only one of these silicon circuit boards-- generally green, and you'll see there's very fine lines or traces that interconnect all of the chips and technology that's plugged into this thing-- and it also has, well, first and foremost, no case. There's no pretty plastic case that protects all of these components. It really is just a raw piece of hardware that computer technophiles like to use to build their own machines and programs. But it has a whole bunch of ports-- as we'll return to in a bit-- a whole bunch of places you can connect other devices. But these systems on a chip all come together. And they do many things beyond just the CPU's task alone. But what else is inside of your computer? Well, the CPU is the brain. And the CPU on a system on a chip is thereto the brain. But there's other components necessary inside of a computer so we can do actual work. And one of those things is called memory or random access memory. And random access memory looks, physically, like this. This is a chip that you might slide into a little slot inside of your computer specifically on the so-called motherboard, again, a big greenish board into which all of your computer's components connect. And there's usually a little divot here, a little bump to make sure you put it in the right way-- instead this way, instead of, for instance, that way. And then on this green circuit board are all these various chips that actually store your data. Specifically, they store your data in a volatile way, only when the power is on, when your laptop has battery and is running or when your laptop is plugged in and is running. Which is to say, when you double-click an icon on the screen or run some program, open some file, those files are loaded into the little black chips that you see on this stick here. They're loaded into RAM or Random Access Memory. And this memory is pretty fast. And it is where those files and programs live, so long as you are using them at a given moment in time. Now other devices have slightly different looking sticks of RAM. This is a smaller stick here that's actually found, typically, in laptops or certain desktop models, but it's the same idea. It's simply a different form factor. Now you can actually see in your Mac or PC sometimes exactly how much RAM you have, especially if you bought the computer without knowing this concept or were given the computer and didn't think to ask. In fact, on Windows, if you open up the so-called Task Manager and look at the CPU tab, you might see a little something like this. You'll see one, a nice little chart that shows you what your CPU has been doing over the past few seconds. And the higher these peaks are, the busier it was. Maybe you double-clicked an icon or played a video or sent a really big email or something like that. But more interesting, down here, is the speed of your CPU. This one is 1.9 for gigahertz. And a gigahertz means 1 billion things per second. So a you that's 1.9 for gigahertz means that this computer, this CPU can do 1.94 billion things per second-- additions, subtractions, multiplications, printing to the screen, any number of other things. But if we look, odds are this is marketed, frankly, as 2 gigahertz, and maybe it has burst technology whereby it can actually go even a little faster, maximum speed 2.81 gigahertz by maybe using a little more energy for some amount of time and therefore generating a bit more heat. But you'll see that there's only one socket in the computer from which I took this screenshot from Windows, which means there's one CPU. But that CPU has two cores, which means that the computer can do literally two things at once because it has really two brains inside of that device that we saw a picture of a moment ago. But logically, it actually seems four. So this particular windows computer has a CPU with two cores, each of which supports that technology called hyperthreading, which means that each of those cores will present itself to the Windows operating system as though it's two. Which is to say each core will do two things simultaneously, thereby giving me four logical processors or, really, the ability to do 4 total things at once. So perhaps lower level detail than is perhaps germane, but these are the kinds of things that you end up paying for in a store or when you buy a computer online. This is what distinguishes a less expensive computer from a more expensive computer is just how fast the CPU or CPUs are and just how many cores the CPU has and, therefore, just how much work you can get done at a given moment in time or just how quickly you can work more generally. Now, in a Mac, if you open up your System Profiler, you'll see a different kind of interface, but similar information. This is taken here from a MacBook Pro. You can see that this CPU is 3.1 gigahertz, so faster, but it has one processor, total number of cores is two. And so, here, we see no mention of hyperthreading, which generally windows is a bit more detailed on, but this does mean that this CPU is pretty darn fast, 3.1 billion things per second. And it actually has two cores, so it can do at least two things at once. All right. So that's my CPU, which does all the thinking and all of the work. That's RAM or random access memory where all of my data and programs are stored while I am using them. So what else do I need? Well, where are those programs and files stored when the power is not on or when my battery is dead or when my computer is not even plugged in. Now, odds are, if your computer is like mine, you don't lose all of your files and all of your programs just because your battery dies or you move a computer, and therefore, unplug it from the wall. It would not be a very useful device. Computers do have nonvolatile memory that sticks around even when the power is lost, but it uses a different technology than RAM for that. It tends to use a disk or a hard disk, as in this case. So this is a device that a PC desktop or Mac desktop might have inside of it. And it actually stores quite a bit more information than a stick of RAM. A stick of RAM might store one gigabyte, two gigabytes, maybe even 16 gigabytes. But a hard drive, as this thing is called, will actually store 256 gigabytes, or maybe 1,000 gigabytes, AKA a terabyte or even two terabytes or four terabytes, which is an order of magnitude more than our sticks of RAM. Inside of this device, though, meanwhile is something that feels kind of old school. It's actually one or more metal platters that literally physically spin around mechanically. And on those platters is your data actually stored. So in RAM, there were no moving parts. There is no fan, there's no motor, there's nothing to move back and forth. It's entirely electronic. It's all electrons at the end of the day. But a hard drive is a mechanical device that actually has one or more of these platters spinning and spinning and spinning. And that's what allows the computer to access different areas of those platters. And, in fact, you'll see one or more of these little reading heads, not unlike old school phonograph or record players that actually move back and forth and read the data from that device. And what's nice about this device is that it's nonvolatile. It uses tiny, tiny magnetic particles, little specks of magnetic particles, that, if you orient them this way might represent a 1. If you orient them this way it might represent a 0-- so north to south pole, south to north pole if you remember some of your electronics. But all that is to say is there's tiny, tiny, tiny little particles on here, billions or more perhaps, that, depending on their orientation up or down, represent a 1 or 0. And if you have enough of those particles, you can represent bytes or megabytes or gigabytes or terabytes or more or anything in between. And so you have the ability to store data this way or this way, even when the power is off. The power is used just to read the data or to write or change the data. It doesn't need to stick around to persist the data. So in fact, why don't we take a look at what this motor looks like when actually running. This is a short video from the Slow Mo Guys, which gives us a sense of what the hard drive looks like when its lid is indeed removed like that there. [VIDEO PLAYBACK] [END VIDEO] DAVID J. MALAN: Fascinating. I know. Well, now let's actually take the hood off of an actual hard drive, albeit via animation, and actually see and hear what it is that's going on. And in this depiction here, you'll see that the magnetic particles ultimately are represented as red-blue, or blue-red particles, which represent precisely those magnetic particles that represent your 0s and 1s. [VIDEO PLAYBACK] - The hard drive is where your PC stores most of its permanent data. To do that, the data travels from RAM along with software signals that tell the hard drive how to store that data. The hard drive circuits translate those signals into voltage fluctuations. These, in turn, control the hard drive's moving parts-- some of the few moving parts left in the modern computer. Some of the signals control a motor which spins metal-coated platters. Your data is actually stored on these platters. Other signals move the read-write heads to read or write data on the platters. This machinery is so precise that a human hair couldn't even pass between the heads and spinning platters. Yet, it all works at terrific speeds. [END VIDEO] DAVID J. MALAN: So where are those particles? Well, for that, we're going to have to zoom in even closer because they're not visible to the human eye. [VIDEO PLAYBACK] - Let's look at what we just saw in slow motion. When a brief pulse of electricity is sent to the read-write head, it flips on a tiny electromagnet for a fraction of a second. The magnet creates a field which changes the polarity of a tiny, tiny portion of the metal particles which coat each platter surface. A pattern series of these tiny charged up areas on the disk represents a single bit of data in the binary number system used by computers. Now, if the current is sent one way through the read-write head, the area is polarized in one direction. If the current is set in the opposite direction, the polarization is reversed. How do you get data off the hard disk? Just reverse the process. So it's the particles on the disk that get the current in the read-write head moving. Put together millions of these magnetized segments, and you've got a file. Now, the pieces of a single file may be scattered all over a drive's platters kind of like the mess of papers on your desk. So a special extra file keeps track of where everything is. Don't you wish you had something like that? [END VIDEO] DAVID J. MALAN: Now, anytime you have a physical device like this that's spinning all day long or for months on end, if you use your computer a lot and for quite a long period of time, something could go wrong. Maybe you accidentally bump the desktop or the laptop, the result of which is that this reading head might actually strike the platter and make a dent in it or some kind of scratch which actually will corrupt, not only some of the data perhaps, but might even stop the whole device from working if the reading head no longer functions properly. Moreover, anything that's physical like this isn't going to spin all that fast at the end of the day. Now technically, a hard drive like this might spin 7,200 times per minute or even 10,000 times per minute, but that's much, much slower than the speed with which electrons travel as they would in something like RAM. Well, fortunately, it turns out that there's something in between those technologies that doesn't have moving parts, but that's not quite as fast as RAM, but that is non-volatile, whereby it will store your data persistently even when the power is off. And this is so-called flash memory or a Solid State Disk, SSD, in this case here. It's a smaller device, whereas typical hard drives that have moving parts are very often 3 and 1/2 inches, although 2 and 1/2 inch versions do exist as well, in diameter. A solid state drive tends to be only 2.5 inches in width so that it actually fits inside of computers in the same slots that older more mechanical hard drives might fit. But it doesn't have moving parts. In fact, if we open it up, you'll see something very reminiscent of the RAM we saw earlier. But the technology inside of this device is such that the data persists, even when your battery dies or you unplug your laptop or desktop. But the upside of an SSD, being entirely electronic, is that it's much faster. And so this means that your programs will load faster when you double-click them, your files will open up faster when you double-click on them. Anything you might do or save to your hard drive or solid state drive, in this case, will actually get saved much more quickly, which means you might see a little hourglass or spinning beachball much less frequently. And your computer is going to behave and certainly feel faster. Now the catch is that solid state drives, theoretically, won't necessarily last as long, depending on the quality of the brand and the technology being used whereby they only have a finite number of writes. You can read from them nearly as much as you want. But over time, they'll degrade in terms of how many times you can keep writing to them. Now, for many people this might be a non-issue, but to mitigate against this, has the industry also introduced what are called hybrid drives-- hard drives that might be the same size as this or the same size as a 3 and 1/2 inch drive like the spinning mechanical device we saw a moment ago in our animated form-- but they might have both some solid state memory and some mechanical hard drive memory so that you might have a few megabytes or gigabytes of solid state memory. And you might have a few gigabytes or terabytes of traditional hard disk space. And the device itself moves your data around in a clever way so that it tries to keep as much of the data that you want to use, at a given moment, on the solid state part of the device so that it's readily accessible for you. And the data that you might not need, right then and there, stays on the slower, more mechanical device where, nonetheless, you have a lot more storage. Now flash memory is something you might have heard about before now, but in the form of these things here, USB sticks that might store 1 gigabyte or 16 gigabytes or more. But it's data that you might want to carry around on your keychain or in your pocket or keep around on your desk simply for transferring files from one computer to another or keeping some data with you. They tend to be slower though, than solid state drives. They tend to be less reliable. But they also tend to be much less expensive, but also smaller in capacity. But the technology is very similar in spirit. If you need more storage space than that, you might actually carry around with you a solid state drive externally. So it might be a little bigger, and a little heavier, and not something you want to put on your keychain. But this might store 256 gigabytes of space or even a terabyte of space, all of which is now carried around externally. And via some kind of cable can you plug this device into your laptop or desktop or maybe a friend or colleague's computer so that you can share files without having a local network. If you need even more storage than that, 1 terabyte, 2 terabytes, 4 terabytes, or more, you might actually have another type of external hard drive inside of which is one of those older more traditional mechanical drives, the 3 and 1/2 inch disk devices, that might store much, much, much more data. But the price you pay is that it's a mechanical device. It might be, therefore, a little bit slower. And so ultimately, there's this trade-off between how much space you get, how much money you're spending, and how quickly you can get data from and to that external device. In fact, there's this whole series of trade-offs that we've seen thus far. And you can actually think of these various types of memory inside of a computer like a funnel of sorts whereby you have a pretty big opening where you keep a lot of your data on the biggest of your devices. But the goal is to get that data closer and closer and closer to your computer's brain where it can do some actual work. Indeed, if you think of the CPU as being at the bottom of this funnel, that's to whom you want to get all of this data. So throughout this funnel, you might have your hard disk or your solid state disk up here which stores a lot of your files a lot of your programs persistently in a nonvolatile way so that it's permanent even when the power or battery no longer works. But that hard disk or solid state disk ultimately feeds information down to your computer's RAM. But the ram is not the last stop before the computer's CPU. It turns out that there's other types of memory that a computer has that you might even see mentioned on your computer screen. So if up here you have your disk, whether it's a hard disk drive or a solid state disk drive, you might have quite a bit of this. This might be in the order of gigabytes or terabytes, billions of bytes or trillions of bytes. That gets fed into, ultimately, your computer's RAM, which probably exists on the order of these days of gigabytes, but fewer gigabytes than your actual disk. Down here you're going to have your CPU. And indeed, the goal is to get your data to the CPU. And the CPU, of course, is measured not in bytes but in gigahertz-- the number of billions of things it can do per second with that data. But there's also tends to be something in between RAM and CPU. There's often something called Level 3 cache, which might exist in the form of megabytes worth. Then it goes into what's called Level 2 cache, which is another type of memory, which also might be in the kilobyte or thousands of bytes or megabyte range. And then there might be L1 cache, which doesn't quite fit on this on the screen. But that's OK. Because it hints at just how small of a physical device this is, which might be on the order of, say, kilobytes. So these values will vary. And they'll certainly change over time. And so what's the pattern, then, among these various types of memory leading to the CPU? Well, the disk, whether a hard disk or solid state disk, is not only nonvolatile-- sticks around permanently, and it's where your files and your programs are stored when the power is off-- that's the biggest of these various types of memories, but it's also the slowest. Even solid state is slower than some of these other memories below it on the funnel here. Meanwhile, RAM tends to exist, still on the order of gigabytes, but maybe 1 gigabyte, 4 gigabytes, 16, maybe more if you've splurged on a really nice computer. But RAM recall is where programs and files live when you double-clicked or opened them in order to use them on your computer at a given moment. Meanwhile though-- and this is values you don't really control because they tend to be associated closely with the CPU or the motherboard that you've bought as part of your computer-- that RAM feeds information into Level 3 and/or Level 2 and/or Level 1 cache in turn so that it's less memory there, but it's super, super fast. And that ensures that, even though there's less of this memory-- Level 1 cache exists in smaller quantities than Level 3-- that funnel is just always filled. There's always something at the bottom of the funnel ready to be fed into the CPU. So the CPU never, theoretically, has to wait for any data-- to get numbers to crunch, or text to display, or the like. Meanwhile, there exists, turns out, tiny little pieces of memory in a computer that we'll give a name to called registers. And these registers typically only hold 1 byte or 4 bytes or 8 bytes total. So they're the smallest unit of memory. But it's in those registers that the CPU stores values like numbers like those decimal numbers we discussed earlier. And if it wants to perform arithmetic of any sort, it stores those values in these registers, actually performs the math, stores the result in another register, so it's, then, ready to be loaded back through this funnel into something like the computer's RAM or ultimately saved back to disk. But there's another trade-off here. Besides the top of this funnel being bigger and slower, and the bottom of this funnel being smaller and faster, the bottom of the funnel also tends to be more expensive, which also explains, in part, why you see less of this memory inside of a computer. The Level 1 cache might be more expensive than ram, so you have less of it and, technically, you don't even need as much of it so long as there's enough to keep data waiting for the CPU. But cost is certainly another trade-off as well. But the types of numbers that you, as a consumer, might care about, really, would be how big the disk in your computer is and how much data and programs and files you can store, how much RAM your computer has. Because that correlates with just how much work you can do at once, how many files and programs you can keep running simultaneously without having to quit any of them. And so cache, finally, which is more closely tied to the CPU and the motherboard in your computer and, therefore, isn't really a number you have as much control over as the consumer, just ensures that the data is actually ready. Now this might all sound fairly technical. But these caches, whether Level 3 or 2 or 1 are actually quite similar to techniques that we humans use in the real world, for instance, even at your local candy store. Here's my candy store, and I'm open for business. SPEAKER: Candy, please? DAVID J. MALAN: Let me get you some candy. [FOOTSTEPS] Thank you. Come again. Now that was not very efficient to have to go all the way and back into the store room to get the candy. Much more efficient would be to keep it closer to me in a place that's faster to access much like a cache of candy right here on the counter. In fact, let me go ahead and ready that cash. [FOOTSTEPS] And now, with this cache of candy am I open for business again. SPEAKER: Candy, please? DAVID J. MALAN: Thank you. Come again. Now this is a small cache of candy, but it's fast. And, with it, can I provide my customers or really my CPU with information much more quickly. Now we can actually see the sizes of these caches in that same output that we saw earlier from Windows and Mac OS. For instance, if we look again at the Windows Task Manager and look down here, you can actually see that this particular laptop had L1 cache on the order of 128 kilobytes or thousands of bytes. It had 512 kilobytes of L2 cache, and 4 megabytes of L3 cache. Meanwhile, if we take a look at that same MacBook Pro from earlier, you'll see that it has 256 kilobytes of cache, 4 megabytes of L3 cache, doesn't happen to mention L1 cache, but odds are, it's indeed there on the CPU, just not reported by this program. Now what else is inside or really outside of a computer? In fact, let's start to take a look at things, perhaps, more familiar. Now these are just graphical depictions of connectors or sockets on the back of your computer into which you might have very well plugged in various devices. In fact, this collection of ports here are all related to monitors or displays. So a computer, like a desktop computer, tends not to come with a monitor built in. And if it does, indeed not, you might need to plug-in an external monitor using something like mini DisplayPort-- very commonly found on laptops, especially if you want to have, not just your primary laptop display, but a secondary, a bigger monitor on your desk-- DisplayPort, which is the same idea, but a larger connector that you might typically have on a desktop plugging into a monitor-- HDMI, which you might have, not only on your laptop or desktop, but possibly even on your TV at home because this is also the type of cable that you would use to plug a TV into some kind of set-top device in your living room. And then, lastly, VGA-- still on the list, even though it's super, super old and not nearly as featureful as these other technologies. But you'll very often find at universities like this and companies that have long had projectors installed in their rooms, this older technology, and so it, too, is still pretty common. Now, what else might we want to plug into a computer? Well, any number of devices as well-- in fact, if you've ever seen this symbol, that means you have a port on your computer, desktop or laptop, into which you can plug a whole range of devices. If you've ever needed to plug a printer into your computer, you might use the port label with this-- a scanner, a digital camera, any number of other peripheral devices might be connected to your computer by way of this device here. Even your mouse and your keyboard, if they're not already wireless, would be plugged in with this device here. And it might actually take any number of shapes, though thankfully, some of these are more common than others. This is the universal serial bus-- where a bus as a term technologically that refers to some kind of medium along which data can travel, much like a bus travels down a street. So USB has a whole bunch of different connectors as depicted here. And the most common of which is just this rectangular one that, rather annoyingly, only 50% of the time do you, if you're like me, plug the cable in the right way because it can only go in one certain way. So you might have to flip it around. But on the other end of that cable might be another type, not USB A, but USB B, which is commonly used to plug into the back of scanners and printers and beyond. More recently, though, have companies like Apples and others started using using USB C-- a third type of connector that, thankfully, can go either top down or bottom up, thereby, not having to think as much when you want to plug in a device. But there's any number of other variants of these connectors commonly seen on cell phones, in fact, for chargers and data cables, all of which support USB. Now the USB standard, itself, has evolved over time. So the latest and greatest version of USB devices and connectors are actually much faster than some of the historically older devices and cables. And so it actually does matter what kind of cable you have and what device you have as to whether or not it will transfer data as fast as you might like. Now why is this important? Well, one of the devices you can connect to a computer, typically via USB cable, is something like an external hard drive. And even if you have a super fast external hard drive that is, say, an SSD underneath the hood, if you're using a slower older USB cable or technology, you might not, nonetheless, be able to transfer that data off a very fast device over a slow cable to your computer. So keeping an eye out for the latest versions of these technologies like USB can actually be quite important. But, of course, you might not need cables at all for certain devices. Of course, if you want to use Wi-Fi or wireless internet in your home, in the airport, in Starbucks, or elsewhere, your computer just needs to support Wi-Fi, which odds are, it very much does these days. And you might see a symbol somewhere in your computer like this depicting as much. But not everything operates over Wi-Fi. In fact, devices that you might want to plug into or connect to your computer without a cable would tend to use not Wi-Fi, but another wireless technology called Bluetooth that Windows computers and Macs alike support these days. So in fact, if you have a wireless keyboard at home or at work, or a wireless mouse, or if you have any number of other devices that, somehow, are wirelessly communicating with your computer, perhaps even your headphones these days, odds are, those are using a technology called Bluetooth, which have a limited range of just so many feeds. They don't afford you nearly as much distance as something like Wi-Fi does, but that's a good thing. Because generally, this technology is used to interconnect your personal devices to your personal computer and not really to others around you. So with all of these various devices inside of and, potentially, connected outside of my computer, what is it that ensures that they can all intercommunicate? And what is it that ensures that all of this works? Well, at the end of the day it's the, so-called, operating system whether it's Mac OS or Windows, which is simply software, that either you or, more likely, some manufacturer pre-installed on the computer that you bought. And that software is installed on your hard drive or your solid state disk so that it's there persistently. And so that, even when you unwrap that shrink-wrapped box that has had no power for some time, the operating system is ready to go. And, indeed, when you hit the power button on your laptop or desktop, it's the operating system, ultimately, that is loaded into RAM from disk, and is what you ultimately see. In fact, it's the operating system that gives you, literally, the graphical windows that you see and the icons and the buttons that you can click. But more importantly, it's the operating system that knows how to talk to your keyboard and your mouse. It's your operating system that knows how to display information on the screen. It's your operating system that knows how to move things around in memory and disk and reading and writing all of that information. And that's all thanks to software that comes with an operating system called device drivers-- special software designed to talk to a certain model of printer, to a certain model of camera, or scanner, and the like. And, in fact, even when Windows or Mac OS or Linux or any other operating system doesn't recognize some device-- maybe because it didn't exist when Windows or Mac OS or Linux was installed on your computer-- well, you can very often download new software device drivers from the manufacturer's website of the manufacturer that made that new technology. And that can teach Windows and Mac OS and Linux and others to understand that new hardware. And so there is a future-proofing built into these operating systems because, at the end of the day, they're just software. And so it's this intersection of hardware and software that makes these computers just so powerful. Now, it's all fun and good to talk about hardware and see it depicted on the screen. But let's actually get our hands dirty here and actually enter into our own laboratory and take a look on the outside and inside of some actual computers. I'm here now with Dr. Colton Ogden for a look inside a couple of computers. COLTON OGDEN: Happy to be with you guys today. We have an IBM ThinkPad laptop here. Nobody really needs to use it anymore. So I figured we'd show you guys what a computer looks like on the outside before we start digging in on the inside. So you want to start off by maybe showing what some of these ports are here on the laptop? DAVID J. MALAN: Yeah. Sure. So here's one of those older ports. And, indeed, this is an older laptop. This is a so-called VGA port into which you would plug a cable to connect it, either to an external monitor, or more realistically, on a campus or in a workplace. It's like a projector so that other people can see. If you can believe it, this is an RJ11 jack for an old school modem or a phone cable. So that you could actually dial up to AOL. COLTON OGDEN: Old school. DAVID J.MALAN: Here's an RJ45 connector, which actually looks like this here, as sort of a fat network cable. And that's what you would use to get online with wired internet. Here, we have a microphone jack, if you have an external mic, headphone jack if you want to listen to music at work, USB to connect any number of external devices. And oh. What's this one we've got over here? COLTON OGDEN: It looks like we've got a DVD port. You don't see these very often anymore. It's not going to work because the laptop is off. But we also have a couple of USB ports here on the side. And I think that's pretty much all we have on this guy. DAVID J. MALAN: Yeah. A DVD or CD drive is what's known as optical storage. And it really is just a piece of plastic, the CD or DVD, with some reflective material on it and little divots or pits that are created with a laser that gets, then, read with the laser so that you can actually write 0s and 1s by, essentially, having a smooth surface or little bumps. But it's increasingly falling into disuse as Flash Media of various sorts is being used instead. Well, why don't we not gut this, although, I do see it's power cable sitting here. So you'll notice that most laptops like this have power cables that one go into the wall, then some other proprietary or standard connector that goes into the laptop, and then a brick. Sometimes that gets a little bit warm. And what this brick is doing is it's actually converting the 120 volts or 240 volts coming out of your wall to far fewer volts that your laptop can actually tolerate. Shall we take a look at the desktop next? COLTON OGDEN: Yeah. Perfect. So let's go ahead and take a look at the internals of a computer with this guy here. So I'm going to go ahead and just take off the casing's lid here. DAVID J. MALAN: And this is an older PC-- COLTON OGDEN: Yes. DAVID J. MALAN: --desktop right? An older Windows PC. And so you find that Mac computers aren't so readily taken apart. In fact, that's one of the features of Apple computers is that they have far fewer user serviceable parts, but the price you pay, of course, is that you can't upgrade them or reconfigure them, often using magnets to. COLTON OGDEN: Indeed. DAVID J. MALAN: All right. So what do we have inside of here? COLTON OGDEN: OK. So we have, in here, a lot of the parts you were just talking about in your lecture. We have a CPU with its heat sink here, right in the middle. DAVID J. MALAN: That's a huge heat sink. And that does what? COLTON OGDEN: It dissipates heat. A CPU is very hot. It's oscillating very fast. And so the purpose of this is to, with all of these planes, disperse the heat equally and then get rid of it alongside the fan as well, which acts in tandem with it. DAVID J. MALAN: Yeah. It's a big fan, like you would have in the summertime. COLTON OGDEN: Oh, yeah. Definitely. DAVID J. MALAN: All right. And what about these green sticks? COLTON OGDEN: These green sticks, we only have one in this laptop. But this is actually a stick of RAM, so random access memory where computers' programs are stored as they're loaded. DAVID J. MALAN: OK. And that's connected to this bigger green sheet, which is-- COLTON OGDEN: This bigger green sheet is the motherboard. It's sort of like the central hub for all the parts working together with the computer. It acts as sort of a messaging interface for everything. DAVID J. MALAN: OK. And now, doctor, can I take a look at that piece of RAM? Do you need it? COLTON OGDEN: Absolutely. No. Let's take it out of here. DAVID J. MALAN: All right. So that just snaps right out. COLTON OGDEN: Snaps right out. DAVID J. MALAN: Ah. So it looks pretty much like the image we had earlier with a bunch of black chips here, each of which store some number of megabytes or gigabytes probably. And then the little gold pin, so to speak, that could actually get plugged in. And they can only go a certain way. In fact, I've done this blindly before where I've accidentally plugged it in the wrong way, only to realize, it actually goes this way. And that's why this little divot here is asymmetric. COLTON OGDEN: Indeed. DAVID J. MALAN: I'm done with this, doctor. OK. We're not going to put that back in. And what's this big thing in the back of a PC? COLTON OGDEN: So this is the Power Supply or PSU. It essentially just powers everything up with electricity in the computer. DAVID J. MALAN: I see. And so if this is the extent to which you've actually played with the inside of your computer before-- this, of course, is the power cable. And this is actually a standardized plug that goes back into the device. You can actually use this or any number of other cables on your own computer. COLTON OGDEN: Indeed. DAVID J. MALAN: All right. So where is my data stored when not in RAM persistently? COLTON OGDEN: When not in RAM, you have, here, an external Hard Drive, an HDB, or an internal hard drive in this context. DAVID J. MALAN: OK. So this is older and bigger probably than something like an SSD? COLTON OGDEN: Yes. Older and larger, but probably stores less since this is an older computer. And it's connected to the motherboard using what's called the SATA cable, S-A-T-A, which hooks right into the motherboard. DAVID J. MALAN: Oh, yeah. Can we can we pull that out without that much damage here? COLTON OGDEN: Yeah. Absolutely. So it's a pretty small cable, it plugs right into the motherboard there. DAVID J. MALAN: Ah. OK. So it's got kind of a nice angled shape so that it only goes, in it would seem, one way. All right. And actually, it looks like a different type of cable is used for this older technology. We seem to have another DVD or CD drive up there? COLTON OGDEN: We do. We do. We have a DVD drive. And actually it does you SATA as well. DAVID J. MALAN: Oh, Yes. COLTON OGDEN: It plugs right in with the hard drives. DAVID J. MALAN: Oh. But it has a special power cable that drives that. COLTON OGDEN: Yep. Exactly. DAVID J. MALAN: --just like the hard drive does too. So actually, we have, in advance, taken apart and 3.5 inch mechanical hard drive that you previously had a whole bunch of screws on it and probably previously had a whole bunch of data on it. But now that we've exposed it to the air, and therefore all of the dust particles here in the theater, probably not going to be very reliable anymore. But what's really cool now is that we took off all but one of the screws so we can actually pull this off. And you can see what's been inside your own hard drive perhaps all this time. So this is, again, is 3 and 1/2 inches across, which is a standard size, at least, for these older larger mechanical drives. There's also a 2.5 inch version of this commonly found in laptops or even higher-end desktops these days. And there's that mechanical arm that won't move now because there's no power going into this. But if there were, we'd be plugging it in to the back of the device here and then that SATA cable, which actually runs the power. And how many-- it looks like there's two platters here. Two platters. So the data store probably on the top, on the bottom, and then on the other top, and the other bottom, thereby fitting even more data in here. And if this were an even newer bigger hard drive, we could probably fit even more platters, and therefore more data. And increasingly, is the data being stored closer and closer together, so all those magnetic particles are packed ever more densely, which also means we can store more bits and thus bytes and thus files and programs. All right. So what we also have here a motherboard. Can we take a closer look at this outside of the box? COLTON OGDEN: Yes. DAVID J. MALAN: So this one looks a little bit different. And, in fact, I don't see a CPU. Where's our CPU gone? COLTON OGDEN: Well, this one does not have a CPU. It's been taken out in advance. But most of the other components are still in place here. We have RAM, we have a heat sink, and we have a lot of other ports and such that we've seen on the other motherboard and was looking. DAVID J. MALAN: And these internal ports, what gets plugged into those? COLTON OGDEN: So these are PCI slots. You'll see oftentimes graphics cards, sound cards-- other things that aren't necessarily always with a computer, but are optional-- those get plugged into these ports here. DAVID J. MALAN: And it looks like if we plug this into the back of a computer just right, these things should stick out the back of the plastic case? COLTON OGDEN: Yes. These are ports that are often user-facing, so you can plug-in peripherals such as keyboards, mice, monitors with VGA ports, maybe headphones or speakers with these ports here, headphones, microphones line out, and a few other ports, maybe-- DAVID J. MALAN: Do you want to talk to them in some of these older ports? These are really from my day. So the parallel port, which is where we used to put our printers or serial ports-- I don't know what voice that is-- but our serial ports where we used to put our joysticks for playing the games, a VGA port, of course, and then a whole bunch of USB ports there, which we can actually take a closer look at a cable. So here's a common end of a USB cable. This is Type A, and so that's probably the most common type. But the white plastic on the inside suggests that this is an older cable. If you look at newer cables, you'll actually see that the inside is blue, which means its USB 3.0, which generally means faster, which means you can move data back and forth all the more quickly. But on the other ends of these USB cables-- you see, like the Type B connector here-- this is commonly found in the back of a printer or a scanner. So it's a slightly different plug. It keeps one end straight from the other. But you will actually see sometimes smaller cables like this one here, mini or micro USB, commonly found on phones or just smaller devices where it would be annoying to try to plug-in something as big as this. Well, I think we have just a couple of other things here. Here we have-- this came from a computer. No CPU attached, but this is one of those heat sinks? You were talking about? COLTON OGDEN: It is. It's a combo of a heat sink and a fan for a CPU. DAVID J. MALAN: I see. So Intel Inside might also mean you have an Intel fan, it would seem, and heat sink. And then lastly, we've got one of these things here. What's this here? COLTON OGDEN: This is a solid state hard drive, which actually uses flash memory very akin to microSDs, if you're familiar. It's essentially what a hard drive is. But instead of having a movable mechanical arm that looks at the different bits on the platters, as we talked about, it's almost like RAM. It's just storing the data in electricity, hence solid state, no moving parts. DAVID J. MALAN: But permanently. COLTON OGDEN: But yes. It's nonvolatile, which means, unlike RAM, you can actually store this whether or not you turn your laptop off or whatever. DAVID J. MALAN: All right. And it looks like-- and I'm told I've got to be extra careful with this-- this is a 4 terabyte SSD. So this is a huge amount of data, 4 trillion bytes. So we're just going to put this safely over here. Less expensively, though, we have this little USB stick. It's still 128 gigabytes, but it's a little gimmicky. But this thing slides out here, and then you can plug it into your laptop or desktop or really any device. And it's a really convenient way, ultimately, just like moving files back and forth between each other. All right. Well, Dr. Ogden, thank you so much. I'm sure you're going to want to take care of putting this all back together. And this was hardware.
Info
Channel: CS50
Views: 121,345
Rating: undefined out of 5
Keywords: cs50, harvard, computer, science, david, j., malan
Id: 6mbFO0ZLMW8
Channel Id: undefined
Length: 59min 3sec (3543 seconds)
Published: Wed Jan 31 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.