[MUSIC] So this lesson, this lecture we'll talk about, a little more about operating systems and what they do. We'll talk about tasks and process support really, about how operating system support multiple tasks executing at the same time and how that's useful in more complicated IoT devices. So multiple tasks. So this is actually going back to the last lecture where we were talking about this embedded system that I had my students make. Actually, IoT device, it was a web controlled car. And through the Internet, you could go to a browser, open up a browser and remotely control this car. So you could view what its camera was seeing on your web browser. Also you could hit some buttons forward, back, left, right to control the motion of the car. And so the car itself has its own processor and a web server running on it. A Wi-Fi web server running on it and a camera and it could manage all these tasks. These tests could be managed remotely. But the idea is that on that car, on its microcontroller, it had to do multiple things at once. There are multiple tasks that it had to handle in order to do this that it had to handle at the same time. So let's look at some of these. One thing is sending video data. So this car, if you were connected to it, it was constantly sending video data from its camera to your phone or whatever your web browser was running on. So, it had to do that. Send video data all the time in the background, then servicing the motion buttons. So in the interface, you could go to your web browser. Hit the forward button, the car would move forward. Hit the back button, the car would move back, and so on. So the car, its microcontroller has to service those buttons. So even while it's playing the video at the same time, if somebody presses forward, it's got to respond. Go forward, go backward and all that. So, it has to do that. Detecting obstacles. So this thing has an auto brake feature, so it has to be constantly detecting obstacles. So if there's an obstacle in front of it, it will brake. Regardless of what the commands are, that would get overwritten. So, it's gotta be constantly detecting obstacles while it's showing its video and while it's responding to the control buttons. Also, auto brake. So that's another thing has to happen concurrently, you can be showing video. Somebody can be pressing buttons, you can be responding to them. But if you detect an obstacle, you gotta brake, automatically. Concurrently, with the video and with everything else. So multiple tasks have to be performed by this device. And in a situation like this, it is helpful to have an operating system to handle the multiple tasks to help you handle them. So I just talking about how they can happen together, you get detect and auto brake cannot occur together. So if you detect, then you auto brake. They don't happen together, but everything else can happen concurrently. So in a situation like this, you need to have multiple things running at the same time. Multiple tasks being performed at the same time. Now you could, as a programmer write a relatively complicated program that does all these things at once and checks. While you're sending video data, it's also checking to see if a button is pressed, it's also checking for collisions and so on. But an operating system makes this easier, because you can write each one of these tasks as a separate task and then let the operating system inter-mix them. You can write one piece of code that just sends video data. Another piece that serves as motion buttons, another that takes obstacles. Another one that does auto brake and then you can give them the operating system and the operating system will make sure that they all run at the same time. You don't have to as a programmer, you can write things separately. You can write the sending video data code separately from the servicing motion button code and the operating system can interweave them for you and that relieves a lot of burden for the programmer. So the main job of an operating system is to support a process or a task abstraction. I'm not gonna differentiate them too well right now, but let's just talk about processes. A process is an instantiation of a program, so a run of a program. So if you got a program, PowerPoint, let's say, which is running on this machine right here. When you're running PowerPoint, it has a process running. And so say on my machine, I open PowerPoint ten times, then I've got ten different processes all in different instantiations of PowerPoint. So a process is like a runtime instantiation, execution of a program and you can have many of them at the same time. So the process has to have access to the resources of the processor, the CPU. Meaning, the microcontroller itself, the memory. A process needs to read from memory and write to memory and so on. Other resources, the timers, the ADD converters, the network access, all that. The processes all have to access that, but they have to share that. So there might be only one ADD converter in this microcontroller and there might be three processes that need to use the ADD converter. So the operating system, part of its job is to manage all these resources to make sure that everything gets used fairly, one at a time. So if all three processes wanna use this ADD converter, the operating system essentially put them in a line. Says, okay, you were first, so you go first. You're more high priority, so you go second. The operating system's job is to manage all these resources. The memory and the CPU and I/O, ADD converters. All the resources in the hardware, the operating system takes care of that and makes sure that the different processes can use them in a fair order. Thank you. [MUSIC]