1 00:00:15,353 --> 00:00:17,214 Do you remember when you first realized 2 00:00:17,238 --> 00:00:18,635 that your computer was more 3 00:00:18,659 --> 00:00:20,718 than just a monitor and keyboard? 4 00:00:20,742 --> 00:00:23,301 That between the mouse click and the video playing, 5 00:00:23,325 --> 00:00:25,659 there was something that captured your intention, 6 00:00:25,683 --> 00:00:26,404 understood it, 7 00:00:26,428 --> 00:00:27,880 and made it real? 8 00:00:28,650 --> 00:00:30,246 What is that something? 9 00:00:30,270 --> 00:00:31,983 Is it gremlins? 10 00:00:32,007 --> 00:00:33,769 Let's imagine that we can shrink down 11 00:00:33,793 --> 00:00:35,117 to the size of an electron 12 00:00:35,141 --> 00:00:37,870 and inject ourselves into a click of a mouse. 13 00:00:37,894 --> 00:00:39,507 If you took your mouse apart, 14 00:00:39,531 --> 00:00:42,169 you'd see that it's really a very simple machine. 15 00:00:42,193 --> 00:00:43,420 It has a couple buttons 16 00:00:43,444 --> 00:00:46,723 and a system for detecting motion and distance. 17 00:00:46,747 --> 00:00:48,224 You might have an optical mouse 18 00:00:48,248 --> 00:00:50,844 that makes these measurements with lights and sensors, 19 00:00:50,868 --> 00:00:53,107 but older ones did this with a hard rubber ball 20 00:00:53,131 --> 00:00:54,552 and some plastic wheels. 21 00:00:54,576 --> 00:00:56,301 Same concept. 22 00:00:56,325 --> 00:00:57,890 When you click the button on your mouse, 23 00:00:57,914 --> 00:00:59,692 it sends a message to the computer 24 00:00:59,716 --> 00:01:01,801 with information about its position. 25 00:01:01,825 --> 00:01:03,467 When your mouse click is received, 26 00:01:03,491 --> 00:01:06,856 it's handled by the basic input/output subsystem. 27 00:01:06,880 --> 00:01:09,420 This subsystem acts like the eyes and ears 28 00:01:09,444 --> 00:01:12,029 and mouth and hands of the computer. 29 00:01:12,053 --> 00:01:14,196 Basically, it provides a way for the computer 30 00:01:14,220 --> 00:01:16,419 to interact with its environment. 31 00:01:16,443 --> 00:01:18,066 But it also acts like a buffer 32 00:01:18,090 --> 00:01:21,477 to keep the CPU from being overwhelmed by distractions. 33 00:01:21,501 --> 00:01:23,787 In this case, the I/O subsystem decides 34 00:01:23,811 --> 00:01:25,918 that your mouse click is pretty important 35 00:01:25,942 --> 00:01:28,915 so it generates an interrupt to the CPU. 36 00:01:28,939 --> 00:01:31,075 "Hey, CPU! Got a click here." 37 00:01:31,952 --> 00:01:34,303 The CPU, or central processing unit, 38 00:01:34,327 --> 00:01:36,498 is the brains of the whole computer. 39 00:01:36,522 --> 00:01:39,048 Just like your brain doesn't take up your whole body, 40 00:01:39,072 --> 00:01:41,553 the CPU doesn't take up the whole computer, 41 00:01:41,577 --> 00:01:44,238 but it runs the show all the same. 42 00:01:44,262 --> 00:01:46,482 And the CPU's job, its whole job, 43 00:01:46,506 --> 00:01:48,420 is fetching instructions from memory 44 00:01:48,444 --> 00:01:50,427 and executing them. 45 00:01:50,451 --> 00:01:52,356 So, while you're typing, typing, typing, 46 00:01:52,380 --> 00:01:53,586 maybe really fast, 47 00:01:53,610 --> 00:01:55,064 like 60 words a minute, 48 00:01:55,088 --> 00:01:57,066 the CPU is fetching and executing 49 00:01:57,090 --> 00:01:59,113 billions of instructions a second. 50 00:01:59,137 --> 00:02:02,152 Yes, billions every second: 51 00:02:02,176 --> 00:02:04,958 instructions to move your mouse around on the screen, 52 00:02:04,982 --> 00:02:07,121 to run that clock widget on your desktop, 53 00:02:07,145 --> 00:02:08,868 play your internet radio, 54 00:02:08,892 --> 00:02:11,273 manage the files you're editing on the hard drive, 55 00:02:11,297 --> 00:02:12,876 and much, much more. 56 00:02:12,900 --> 00:02:16,160 Your computer's CPU is one heck of a multitasker! 57 00:02:16,439 --> 00:02:17,589 "But oh my gosh 58 00:02:17,613 --> 00:02:18,885 there's a very important mouse click 59 00:02:18,909 --> 00:02:20,006 coming through now! 60 00:02:20,030 --> 00:02:22,560 Let's drop everything now and deal with that!" 61 00:02:23,207 --> 00:02:24,779 There are programs for everything 62 00:02:24,803 --> 00:02:26,312 that the CPU does. 63 00:02:26,336 --> 00:02:28,034 A special program for the mouse, 64 00:02:28,058 --> 00:02:29,068 for the clock widget, 65 00:02:29,092 --> 00:02:30,279 for the internet radio, 66 00:02:30,303 --> 00:02:33,112 and for dealing with letters sent by the keyboard. 67 00:02:33,136 --> 00:02:35,664 Each program was initially written by a human 68 00:02:35,688 --> 00:02:37,882 in a human-readable programming language, 69 00:02:37,906 --> 00:02:38,741 like Java, 70 00:02:38,765 --> 00:02:39,774 C++, 71 00:02:39,798 --> 00:02:41,195 or Python. 72 00:02:41,219 --> 00:02:43,717 But human programs take up a lot of space 73 00:02:43,741 --> 00:02:47,426 and contain a lot of unnecessary information to a computer, 74 00:02:47,450 --> 00:02:49,212 so they are compiled and made smaller 75 00:02:49,236 --> 00:02:52,629 and stored in bits of ones and zeros in memory. 76 00:02:52,653 --> 00:02:55,386 The CPU realizes that it needs instructions 77 00:02:55,410 --> 00:02:57,387 for how to deal with this mouse click, 78 00:02:57,411 --> 00:02:59,697 so it looks up the address for the mouse program 79 00:02:59,721 --> 00:03:02,072 and sends a request to the memory subsystem 80 00:03:02,096 --> 00:03:04,179 for instructions stored there. 81 00:03:05,287 --> 00:03:07,335 Each instruction in the mouse device driver 82 00:03:07,359 --> 00:03:09,718 is duly fetched and executed. 83 00:03:09,742 --> 00:03:12,089 And that's not nearly the end of the story! 84 00:03:12,113 --> 00:03:14,630 Because the CPU learns that the mouse was clicked 85 00:03:14,654 --> 00:03:16,274 when the cursor was over a picture 86 00:03:16,298 --> 00:03:18,153 of a button on the monitor screen, 87 00:03:18,177 --> 00:03:21,224 and so, the CPU asks memory for the monitor program 88 00:03:21,248 --> 00:03:23,329 to find out what that button is. 89 00:03:23,353 --> 00:03:25,577 And then the CPU has to ask memory 90 00:03:25,601 --> 00:03:27,413 for the program for the button, 91 00:03:27,437 --> 00:03:28,924 which means that the CPU needs 92 00:03:28,948 --> 00:03:30,664 the monitor program again 93 00:03:30,688 --> 00:03:32,836 to show the video associated with the button, 94 00:03:32,860 --> 00:03:34,718 and so it goes. 95 00:03:34,742 --> 00:03:37,463 And let's just say there are a lot of programs involved 96 00:03:37,487 --> 00:03:39,583 before you even see the button on the screen 97 00:03:39,607 --> 00:03:41,355 light up when you clicked it. 98 00:03:41,379 --> 00:03:43,824 So, just the simple task of clicking your mouse 99 00:03:43,848 --> 00:03:46,192 means visiting all of the critical components 100 00:03:46,216 --> 00:03:48,172 of your computer's architecture: 101 00:03:48,196 --> 00:03:49,214 peripherals, 102 00:03:49,238 --> 00:03:51,023 the basic input-output system, 103 00:03:51,047 --> 00:03:52,355 the CPU, 104 00:03:52,379 --> 00:03:53,130 programs, 105 00:03:53,154 --> 00:03:54,116 and memory, 106 00:03:54,140 --> 00:03:56,133 and not one gremlin.