Hello everybody, welcome to this second section about computer architecture and networks. We saw what a computer was made of, now we are going to look at how a computer technically executes a program. First of all, you need to remember that the computer's heart is the processor. and it does not possess intelligence, it just has an instruction list it has to execute, like a cooking recipe, and it is going to follow that recipe without thinking, just by dumbly executing the instructions. But that cooking recipe needs to be thoroughly detailed. The computer cannot guess what's missing, so if it is given a cooking recipe saying that it needs to Whip egg whites to a light mousse, it must also be told that it needs to break the eggs and separate the egg whites from the yellows. So if the processor handled a cooking recipe, what would it do technically? First, it is going to fetch the recipe book from the cupboard, and it would open the book on the right page to find the program, and the recipe it has to execute. Then, it would go to the fridge or the cupboard to find the ingredients and draw them closer to him, so in the memory. And then, it is going to take each line of the recipe and execute it, so first it is going to try to read and understand the line, then it is going to fetch the useful ingredients to put them in the salad bowl, or the tool it is going to use to prepare the recipe, so it will mix the ingredients up, apply what the recipe line says, and finally the result, so the mix, for example, it will either be put aside and keep it for later, or it will keep it and used it for the next recipe instruction. So the processor executes all the instructions one after the other until the end of the recipe, and then it will put the recipe book back into the cupboard, put the ingredients away in the fridge or the cupboard and store the cake where it wanted it to be stored. So that's a cooking recipe, but now let's have a look at what actually happens inside a computer. So I did not connect the peripherals, I only installed the hard drive, the memory and the processor, but if the data was coming from the network, it would be the same, it's just that generally, the data comes from the hard drive, so let's just do it this way. So we start with data coming from the hard drive, that's where programs can be found, and their data, when the computer starts, the processor doesn't know what to do, so it is going to get instructions from the hard drive. So it's going to load the program in the memory and start executing it. In addition to loading the program, the processor will also load in the memory the data it needs, for example, if it was asked to display an image, it is going to load that image in the memory before trying to display it. So once all this is in the memory, the processor is going to start working technically, it is going to look in the program, which is the recipe, so the succession of instructions it has to execute, it is going to load the first instruction and start working on it. As an instruction, it is going to receive a pack of binary data describing the tasks that need to be done for this step of the recipe, so that's machine code, like what Sylvie was talking about earlier. So that's binary coding explaining in the first part what kinds of operations need to be done,like addition and a multiplication,and in the second part, the 0 or 1 bits will explain on which data that operation needs to be applied. For example, if you want to do an addition, where is the data that needs to be calculated, and where does the result of that addition need to be stored? The processor actually decodes the instruction to understand what it has to do, and then it does it. To do that, it is going to take input data that can be found in the memory, and it will then perform the operation, so perform the calculation, or the comparison or something else. Once that calculation has been done, it generates a result and stores it in the memory, for example. Technically, it can also store data in small special boxes of the processor called registers, but those are basically a peculiar sort of memory. So that's how the recipe unravels, so the same thing will be done for the following instructions until the end of the recipe. So it looks for the instruction, it decodes it and then starts again. At the end of the recipe, it will have executed everything it needed to, the result will have been stored in the memory, and so finally, it will just take the result stored in the memory and send it back to the hard drive to save for example an image or a document that may have been modified. Some orders of magnitude to go further into this, how it works. So a modern processor executes approximately 1 billion operations per second, they are just simple operations, multiplications, and additions, but those operations can involve huge figures. Humans can perform operations with a few digits, a bit more if you work on a sheet of paper, but they can only perform a few operations per second if there aren't too many digits and very few operations if there are many digits. A computer performs 1 billion operations per second with very high numbers, up to 64 bits. 64 bits being 16 billion, so it can perform calculations on billions of billions very quickly. It is also going to manipulate lots of data to make these calculations, so that means potentially reading and writing billions of bytes in the memory which it will manipulate to perform calculations, and finally store the result in the memory. If needed, it will also access the hard drive, but the hard drive being slower than the memory, the quantity of data handled will rather amount to megabytes or hundreds of megabytes, so tens or hundreds of millions of bytes, which it is going to read and write in the hard drive if necessary. So most transfers happen towards the memory, but some may go to the hard drive if needed. But the processor is capable of handling a huge amount of calculations, and technically the computer's performance will be far below that. The reason is that the processor may be able to make a lot of operations, but it still needs to be given data to process, and the hard drive is very slow, the memory's faster, but still not fast enough to feed the processor enough data to process. So the processor will often have to wait for the memory for data to process, so there are many instructions the processor should execute, but that will actually have to wait before being technically executed, so the number of operations per second does not always reach 1 billion, it mostly depends on what the computers are asked to do. And what's more, the computer is not intelligent, it can perform simple calculations, but the recipe needs to be very precise, complete and, of course, not incorrect, if there's a bug, it won't work. Now a few figures on what the computer is going to handle. First, is the operating system, so for example Linux or Windows or Mac OS X, those programs contain approximately ten million instructions. It's a huge program containing rather classical instructions that the processor is going to execute. 10 million instructions are huge, that's because the operating system has many things to do to handle the computer, in particular, it has to handle many peripheral drivers, because those systems work on computers with different network boards, different graphics boards, different keyboards, different mouses, etc. There has to be a lot of code to handle all those different models. An office suite like Libre Office or others will hold several hundred megabytes. There are also a lot of instructions in those, but then many are used for the graphical interface, which means reacting when clicking on a window, etc., displaying what's needed, and also many data in that office suite will be used to display images like button icons, etc. That software is smaller than operating systems, but they are actually bigger because they come with many things related to graphics and related to the fact that there is an interface we need to manipulate on-screen. Finally, in the case of video games, it varies a lot, but we can consider its amounts to about ten gigabytes, or several tens of gigabytes, of course, it's mostly graphics and videos, and still a bit of code, but far less than in an office suite or an operating system. What you need to remember about this sequence, it's first that the processor executes the program like a cooking recipe: it takes all the instructions one after the other, it takes the ingredients it needs, processes them, and then it stores the result. It does this witlessly, so it really needs to be spoon-fed by giving it a very detailed recipe, it won't be able to guess what's missing. But on the other hand,it will do so very quickly,billions of operations per second,and while handling a lot of data, much more than a human could handle, but again it does it witlessly, without intelligence.