 In this video we are going to explain another element of a computer system that is the input output subsystem. As we can see here is the subsystem connected to the rest of the components but is in charge of interacting with all these devices that are responsible for either entering information within the system or are being used to store or show information coming from the system. So let's talk about the input output. So as we can see if we enumerate the typical devices that are connected to a computer some of them are very obvious the type of operations they do in terms of input output like for example the keyboard. Clearly this is an input device because it is used to enter keystrokes in the computer. We can represent that with an arrow like this. Something similar with the mouse it's another device that notifies the computer or informs the computer certain movements so that the computer can move an arrow on the screen and therefore this is also an input device. Another very easy to imagine is the display. In this case the display is an output device and let's represent it like this. It's a device that is used by the computer system to relay back to the user certain information visually. In this case through the representation on a screen. A more generic device that is also an input output device is a disk. In this case the operations we can do here are both input and output because the computer system can store things on that disk and vice versa it can read things previously stored on that disk. So we would represent this device like this. Another option would be the device that is in charge of connecting the system to internet and in this case as in the previous one what we have here is an input output device which will also represent like this. And this list can be on and on specifically if we think of anything that can be connected to a personal computer through a USB connector which can be a disk, can be a joystick, a USB disk, any other device you can think of it's also an input output device. Now given the complexity and the variety of all these devices the way this is tackled within a computer system is defining or designing a specific circuit which is what we call the input output subsystem. This circuit is obviously connected to the bus and through this bus it maintains a communication both with the microprocessor but also this is a bi-directional communication but also with another important block in computer system which is memory. So this subsystem over here it is in charge of handling the communication among all the different devices that can produce input and output events in a computer system. So in a way we do have here the keyboard as we mentioned before. We have also the screen, we also have a disk for example and many more. Now the reason why this is called a subsystem is because the complexity of all these devices or the instructions that they require to exchange the information between them and the rest of the computer system are all handled through this circuit over here. Now this circuit has to have three properties, it has to allow this configuration to grow. In other words to accommodate this is desirable more devices. Of course there is a limit to everything but this type of circuits are prepared so that they can accommodate an increasingly large number of devices and even some of them that can be connected and disconnected while the rest of the computer system is working which is the case for example for the USB devices. Another responsibility of this circuit is to somehow order the operations that are required to take care of all these devices and all the operations over here. So in case of the keyboard let's represent it as an input device, screen as an output device, disk as an input output device, all these operations need to be ordered or need to be supervised by this circuit so that the relevant data is then relayed back to the microprocessor or to memory as we will see. And of course this circuit has to handle multiple devices at the same time. And this is also very important to make sure that the computer system overall is capable of manipulating all these input-upload devices. Okay, from the point of view of the microprocessor, the input-upload operations can be done in two different ways. The first one is what is called input-upload based on special instructions. What this means is that this microprocessor has at least two type of instructions, let's call it in and out. Each one of them has some sort of at least location as a parameter. And these two instructions are the ones used by this microprocessor to establish a dialogue with these devices. So for example, if a microprocessor wants to read a key that the user pressed on the keyboard, it would use the in instruction with a specific location here pointing to the keyboard. Analogously, if the microprocessor wants to visualize certain character in a specific location on the screen, it would use the out instruction to make sure that this data is communicated to the input-upload subsystem and visualized on the screen. So this is one possible strategy to have the microprocessor manipulate the information that comes from the input-upload system or that has to be sent to the input-upload system. But there is another alternative, which is known as the name of memory mapped input output. And the concept here is a little bit counter-intuitive because it uses the memory, another block of a computer system, and what it does is out of all possible locations in memory, some of them, in fact, they do not contain memory, but what they contain instead is the input-output location of all these devices. So this is a way of making sure that the microprocessor perceives input-output operations not as something different that requires special instructions, but as some operations that can be performed directly over memory. And therefore, what we have here is that from the point of view of the microprocessor, there are only two instructions that are used for input-output, which are load and store, but these operations are already present on the microprocessor. Therefore, there is no special provision for input-output. Now these two options, they have advantages and disadvantages. The big advantage of this option over here is that it doesn't occupy any specific location in memory. The disadvantage is that we need two extra instructions, and these are the opposite for this option B. In this case, we do need to map the input-output operations in memory. However, we lose some positions there because they cannot be used to store data. They have to be used only for input-output operations. However, the microprocessor does not need specific instructions for input output, but it can recycle two of the instructions that it already has, which is load and store a value from memory. Okay, but independently of these two options, the microprocessor still needs to perform these input-output operations. Let's see one example. Let's suppose that in the keyboard, the user presses and in the screen, the character, the appropriate character, has to be shown. This is something very intuitive that we do every day. We press a keyboard and somehow the input produced by this device is also used as an output produced and visualized on the screen. So here are the steps that need to occur and the units that take part on this event for something so intuitive like this to occur in a computer system. So the first step is for the keyboard to somehow catch. And what we mean by that is that whenever the user touches a key, that key needs to be collected and stored. And it's typically stored in some specific registers that are part of the keyboard. This is step number one. Step number two is for the microprocessor to input that character. Or in other words, this value is handled by the input-output subsystem and at some point the microprocessor needs to catch that value from the input-output subsystem. Now what it occurs here is the microprocessor checks that character. It sees the type of key that has been pressed and it has to consult the rest of data stored in memory to make sure that the character is visualized in the right location of the screen. Suppose we have on the screen several windows open and we touch a key in one of the windows, therefore that key needs to be or that character needs to be visualized in the correct window, which is the one selected by the mouse. And this information is stored in memory. Therefore, in step number two, the microprocessor needs to take this information, process it, consult its data, make sure that the right window is identified and then perform an output operation. So step number three would be for the microprocessor to decide how to proceed. In this case, it would be selecting the right window. And step number four finally would be for the microprocessor to output the character. And finally, step number five, screen shows. So this sequence over here is showing us the role of each of these elements in a computer system. Keyboard is in charge of detecting this key. It is then communicated to the input output system. In the input output sub system is stored until the microprocessor checks that value, checks the rest of annotations regarding the screen or what to do with that key. And then it decides to eventually give some additional orders to the input output system so that this character is visualized on the screen. Typically, these screens are control, but what we call the video card. Video card is a digital circuit that receives information from the rest of the system and translates that information into a video signal that is then hooked up to screen and produces the image we see in the monitors. If this is the type of operations that occur, and this is the type of processing that needs to be carried out by the microprocessor, we do have a problem here. And it's that when does the microprocessor know that a keyboard has been pressed and needs to be processed? In other words, since behind the keyboard, typically there is a person here, the microprocessor has no way to anticipate when it is appropriate to ask the input output system for the next key pressed by the user. Now, one initial option which would be highly inefficient would be for the microprocessor to ask the input output system every once in a while and see if there is any sort of key that has been pressed and therefore needs to be processed. This would be the microprocessor proactively asking the input output system, but this is very inefficient because it would waste a long time because most of the time when you ask the input output system, the answer would be no, I don't have any key. The user didn't press any key. So typically what it occurs here is that this type of communication is handled by a mechanism which will be described in another video and it's called interruptions. Interruptions work in input output very intuitively. Rather than having the microprocessor talk to the input output subsystem every once in a while, it occurs exactly the opposite. So whenever key is pressed, then the input output subsystem interrupts.