Bootstrap Process Explained
Transcript
OK so. We said last week about starting up and we'd said that. For many systems like PC or a Mac, what it will do is it will search around looking for some. I. Hardware to make sure it's got enough hardware to actually run something. Once it's then done that. And general, what it will look for is some hardware with a more. Substantial operating system because you could call the bootstrap and operating system, but it doesn't really do all that.
So it goes to look for a hard disk or an SD or USB or something that's got an operating system on it, and it then transfers control to that. That is the operating system that we think of. So when you start up your computer, if you look at the the screen, you'll often see messages saying checking hardware before the Windows thing starts. But. Computers these days are so fast it quite often. Just flushes through. So that's what the bootstrap program is doing. Starting out the computer, checking the hardware and then going and looking for another operating system.
But you can extend that thought. If that's what it's doing. If it's going to look for another program to run and remember, an operating system is a program like anything else somebody'd written it some point. If you're going to look for another program to run, why can't that other program be a program that doesn't run an operating system, but allows you to point to different operating systems?
In other words, a simple menu system that says something like run Windows or run Linux. And there's been comments about struggling to find material relevant so. To give you a hint of where you're going with this one, Google something called grub GRUB. And Groupe is exactly that. It's a bootstrap loader which allows you to choose excuse me, it allows you to choose from a set of operating systems, all of which you're installed. On the hard disk.
Ellie PC couldn't do that LPC's. We are tied to the operating system being on the first part of. The hard disk. And that was built into. The bootstrap loader. More recent operating systems allow you to have the operating system anywhere on the disk. And the question is groups just for Linux, right? And the answer is no, it's not. Grub will work with anything.
So you can install multiple different operating systems and choose for drama. Is that OK with that question? And part of the reason I wanted to talk about GRUB is I'm almost certain. But it was N the. A presentation from last week. And it's definitely in the book. So I'm hoping you've all got the book and that will also point you to other things.
Yeah. So is that OK for that? Question. Yep. OK, I'm seeing some notes, so move on to see Perfect. Thank you. what the next one is. Five services provided by an operating system and again, I'm not going to do this in detail because I definitely remember talking about this last week because we've talked about things like file systems and user interfaces and I/O systems. So it's those kinds of things. So go back to the notes and have a look at all of those different bits. Because remember, we were also talking about them in terms of monolithic operating systems where all of these things are in one big chunk.
As opposed to hierarchical operating systems, where you can load in different bits depending on what you want to run. And we also said things like Windows takes both approaches, so it's quite a lot baked into the main operating system. But those other things that you add in. And you know that you had them in because if you add in a printer or a a. Stream, deck or whatever you add in device drivers so that the operating system can talk to that device.
So. Go back to the materials and look at things like file system. I will system and all that kind of stuff. Remember that diagram we had that was circles. With all the different bets starting at the kernel working its way out to the user interface, have to think of all the things in there. Five major activities of an operating system with regard to purchase management. So I'm not gonna do that because we're doing that today and I don't know why this ended up in the last weeks.
Tutorial so apologies for that. It's. Ohh yes, I do know why it is so. Remember I said we've got out a lot of things. So in the presentation, I don't cover all of this. So we did talk about processes. We did talk about memory management and that that was a sort of things that operating systems do.
But in some of the slides, as more details about what memory management actually needs. So I can remember in the slides we talked about memory management saying things like not letting 1 program. Fashion to another to keep them safer, to decide where it goes in memory, that type of thing. So the there are headings about that in the slides, but there's more detail about it in the book.
Similarly, secondary storage management and again we talked about that we talked about the idea that for Windows you save a file. But the operating system takes care of things like, well, how do you save the name? Where specifically does it go on a device like a hard disk or an SSB? And in fact? How do you set it up so that we as users don't care whether it's going to hard disk or a USB or whatever? And that's just three of the things that it does in terms of storage. It looks after those things for us.
And I just spoke about this, the open and we're talking about a monolithic versus a layered operating system. So monolithic is faster because all the stuff is in one place. But whenever you want to extend it, there's a difficult day because you have to. Rewrite the operating system and then reinstall it a layered approach. Gives you more flexibility, but because you'll get different bits here and there, they have to talk to each other and the talking to each other just that communication means that they're slower. So the more flexible but slower.
OK. I'm just sort of running through these. So if there's questions about my brief explanation, please let me know. What's the purpose of system calls? Another name for a system call is. Interrupt. No. Good idea, but no.
Remember we talked about an API. An application program interface. In order to call the operating system. A system call to create different things. Fees are *****. Gentoo, a monolithic operating system. No Gen 2 is a. There's a version of Unix, specifically a version of Linux, and one of the things about Linux is it is very definitely not monolithic. Linux itself refers to the kernel, so the bit that talks to the hardware, all the other bits are from all sorts of other places.
So no. Gentoos not monolithic. So a system call is that all that stuff that I did a bit API. So you call a system, you make a system call to. Make the most of you. 2. Click on it. All of these things are controlled by the operating system. Those Gen 2 requires to be built each time. I am. I will go and look that up. My recollection was that it didn't, but I am happy to be educated. I'll go and look that up, but not right this second. I'll look it up after.
What's the purpose of system programs? Well, let me give you an example of a system program. When I brought up the command line interface and I typed in, DIRI was running a program. But it's a program that comes with the operating system to list the files endorse. That's a system program. So system programs are there to help you with. System things. Another one might be something called Check Desk where you can check whether your hard disk is working OK.
And you get the same sort of things and all sorts of operating systems. So you've got a hard disk manager. We also run the task manager. That's a system program. It doesn't help you do work as such, but it helps you run the system and understand what's going on in the system. What's the purpose of the command interpreter? To enter programs into the center, commands into the operating system. And it's separate from the channel because you want to be able to run different interfaces, whether that's a command line, whether it's a GUI, whether it's a different command line. And we talked about it specifically in Linux and Unix when we talked about which shelves.
We talked about the Unix shell and we talked about how someone rewrote it. The guy's name was born. And you wrote the shell. It was a born again shell or bash. So we can. Yeah. Fraser was getting now. Ohh guessing that there was a an excluded section but the practice test has a question. Apologies about that if you get me the exact question I will update that and take it out.
I thought I'd go all of those. And final one. What system calls have to be executed by a command interpreter or shell in order to start a new process? And again, we spoke about this specifically for Unix. And partly the reason I keep talking about Unix is of course you're big group report is on a Unix system and what we said for this one for Unix. Can anyone remember the command?
Piece of cutlery. Work. Work. We did talk about it in the lecture. So. Does that help with all of those things? We did cover them. Perhaps not in great detail, but then that's part of the reason we have this cause. Of course. I you saw how long we took last time, just covering things at top level and we're still running late. So. This is part of what you have to do, so I'll talk about things in general, but you then have to go back and look at them in more detail.
Any questions about that tutorial then? After that brief runthrough. And that may be helping future tutorials cause hopefully they are. Going back to some of the stuff that we're covered in the slides and we can hopefully make that connection. OK, if there's. Well, if there's other question for that, is there questions about anything else? So that's the chapter review tutorials. So questions about anything else just now. As there are definite to him as there are difference between our buffer and our cash.
That's a very good question. OK so. What I'm trying to do is decide how. Detailed to be in the answer because when we're talking about things like memory management and CPU, I'm going to go into this in more detail. So can I leave it? Yes for now. Yeah sure. And.
I will. We'll talk more about them later in the course, I promise. All right. Any other questions just now? OK, I'm not seeing anything coming up. Store what we'll do is we'll move on to chapter 3. No, remember. All of the stuff is online.
We're going through it chapter by chapter. We're on to Chapter 3 today. Which is. Processes. So I'll go through it as usual. If you have questions that I'm going through it, please stop me and ask. And I'm happy to take questions as we're going through.
OK, so we talked a bit about processes last week. We at least talked about the fact that processes exist and you'll remember I was talking about. What I think I'm running teams, PowerPoint, OneNote. As against what the systems running and you remember. I brought up my task manager on Windows. And as far as I'm concerned, I'm running 5. Different programs.
But as far as Windows is concerned, I am running hundreds. Of purchases. So all of these things have to be run somehow. And we've only got one CPU now. I know that there are multiple CPU systems. I know that there are multicore CPU systems. We will talk a little bit about those just now, but for the moment we are going to assume we have one computer with one CPU that can do one thing at a time, OK?
And they will broaden it out later on about how we might make use of more Singh, confused and more clothes. So we're going to think about processes what they are. And how we are going to get all these hundreds of processes all running? And how they're going to work together. OK. So. In terms of a process. A process. You can think of as a a running program. So when we talk about program, we're talking about the thing that's sitting on your desk ready to run, but it's not running yet.
Once we're running it, we call it process. And processes have got lots of different attributes. They can also be created in different ways, and again we touched on this last week, we talked about systems where. We would run jobs, scheduled jobs that would run up particular time. I've got a backup system running on this computer. And it doesn't run during the day cause it slows down my machine. And stayed. I've got it scheduled to run at 6:00 o'clock because I'm usually finished by then.
So it backs up my computer to my network server every day at 6:00 o'clock. I don't have to do anything, it just runs that side job. It's a batch job and it will just run on its own and I don't have to think about. Other things will be running at the same time. So I said I've got different. Programs running different user programs. Teams.
PowerPoint. OneNote, whatever happened to be? I've looked at one CPU. So I can't run these things. They're not all running at the same time, so they are timeshare and the time that we're talking about is a CPU type. We're splitting up the time of the CPU amongst all of these processes. So it doesn't matter what we're talking about when we're talking about jobs, it's scheduled or a. Ah.
A process that we've initiated ourselves. The old processes and you, you can think about them as being the same thing. The other thing you'll remember about a process which is a launched program and you'll know this from the LMC and it's part of the reason we do the LMC is that programs run. Construction at a time runs, an instruction goes and gets an instruction, executes it. Who's gets next instruction executes that, and so on.
And all their process is working the same way. So we have the idea. But the process is running sequentially. And. The idea that we've got the program state and again, if you think back to the LMC. The Pilgrims state is that stuff in the middle, the program counter where we are in the pro counter, the registers data that we've brought in. The accumulator, the result of a calculation.
So we've got where we are in our process and we've got the state of the process. It's the LMC, so it's a small computer. It doesn't have much in it. Larger program. Larger systems have more things. Bigger CPU's have more things, but they will all have program counter to know where they are in the program at that point. They will all have an accumulator. They make more than one, but they will at least have an accumulator. Where you get the results of. I arthritic calculations.
But they may have other things, so they might have a stack. We are, we have. Data. That we're going to use again and it's so it's a place we can leave data. But it tends to be short term data, so you use a stack for short term data. We have a data section where we store things that we're going to use all the time global. And formation. And we have a heap.
So these are data. Types and I know that some of you are doing. Some of that in other modules. If you're not, don't worry about it. Just remember that they exist. You have to know that because they're in blue, we said that you these are likely to come up. The difference is stack is short term. So when we got an error. Little mind computer and more entering our two numbers. They're stored in the stack.
But if I'm running a word processor here, my document that I'm creating is stored in the heap. So it's for bigger data that's going to be around longer. So those all these things. Going on all his part of the process. That only happens when we execute the program and it doesn't matter how we execute it. I don't care if it's graphically or command line. It won't happen until we do it.
And in fact executing 1 program. Make create more than one process. I am running Firefox. I don't know if you noticed. But when? I run through these processes. There was a whole set of processes all identifying themselves as Firefox.
Don't have age running, so I don't know why those age processes. One of the things that Firefox does is eat so that again, That's because you're on Windows. sorry. Windows has air flowing secrets. You've got a search option in the search bar. That class is Microsoft Edge. It's it's heading in like that. Of course it does. A turned off the news thing to try and save some system resources, but I do still have the search. You're quite right. So I I didn't. It thinks of itself as a as an instance of edge. In the same way as the each tab that I have running here is a process all controlled by the big Firefox process.
So one program might be lots of processes. They have to exist somewhere. You can't run a program and CPU without it being in memory. You cannot run it from the disk. It needs to be in memory. So it has to be loaded in. And be held somewhere. All of these things that we have. Identified all of these parts. The code.
Actual program itself, which we're gonna call the text section program count on the stack, the heap, they all have to be stored in memory. So we have the code. The actual executable code we have the data. That's global data that's always going to be there and then we have temporary data. And you'll see a couple of things here. Each process is assigned.
A certain amount of memory. Some of it. Is taken up by the text and the data, and that won't change. But some of it. So that stays the same. Some of it changes. So the stack and the heap the temporary. Small bets and the temporary big bits of data will change, not surprisingly, as you're working.
So in order to. Make best use of space. What we do is we start the stack at the top of memory and remember we said memory goes and all these diagrams we go from bottom of memory 0. To top of memory which that's identifying as Max, I said hi last week. You get the idea though. Top and bottom of memory. We're start these two temporary things at opposite ends.
We'll start with that. Stop the stack at the top. And that runs down and we start the heap at the bottom. That goes up, the idea being. We can make as much use of memory as possible, and it's only when we have so much data that these things collide in the middle that we have a problem and run out of memory. So that's the first thing that we're going to try. And make more efficient use of the memory that we have.
OK so far. OK, so we've got these processes. And. We talk about them being in different states. They are identified there, but the diagram here is actually more useful. So let's think about what happens when we run a process. We have a new process.
And. We have processes already running. So when we initiate it at this new party here. What we're really seeing is we've got a new process and if the CPU could run it, that would be lovely. Thank you. But there's lots and lots of processes. We just saw that. O instead of it running immediately, what it does is it goes into a queue saying ready this process is ready to run. If you can give it some CPU time, remember we're talking about sharing a CPU that's a time share system.
So what one of the things that the operating system will do is it will run through this list of processes that are ready to run if they had CPU time. When the CPU is ready. It generates an interrupt and says oh, I'm ready for a new process. Please. At which point the next one in the list. Gets. Dispatched.
To the CPU and starts running. And it starts running away on the CPU. Now there's two issues with this. One is a processes. That have an issue. Let me ask you a question. What do you think takes the most time for processes?
What is the largest part of their execution type? Anybody want to take a guess? Fetch and the instructions. Say it again. Fetching the instructions. Fetching instructions? No, no, it's not. Any other guesses? From the memory. As a dealing with new processes. Dealing with new processes. Again, good guess, but no. On your screen you've got PowerPoint.
And it says diagram of a process state. What's PowerPoint doing right now? Madelyn. Was displaying. Sorry. There's the graphical interface. As a graphical interface, but I, but what's it doing right now? But it's just point. Waiting for an instruction. Was actually showing. It's waiting. It's waiting for me to do something. And in terms of the amount of time it spent with the CPU compared to the amount of time it spent waiting for me to tell it what to do next, there's no comparison.
And that gives us an insight into how this works, because I've got PowerPoint running, but it's not actually doing anything. What is doing something all those other processes that are in the background and we don't see or teams which is doing something, it's updating my screen and I can see your chat and I can see faces. So there's a couple of ways you're process can stop. The first one is. It's waiting. It's waiting for input, output, or an event or something.
So it can if PowerPoint is waiting for an input. There's no point in me saying ohh give it some CPU thing because I won't do anything with it. You'll give it some CPU time and it will go. Yeah, thanks very much. But nobody's talking what to do. Ohh. Do you want me to chat while we're waiting? Absolutely no point. Get rid of it and put it into this box here. This waiting. West. And what that's saying is, look, I'm waiting in something happening.
Do bother coming back to me until something's happened, because I don't have anything to do. And that's something that's happened. Might be me pressing a button. So how a point is currently in the waiting queue. But if I press a button. It says Ohh I've had an IO event. I will move myself back to the ridicule and I will run and what I'm doing is running and putting up this new slide. Ohh, I know, waiting for some more again, so stop again.
And if there's a button, that's what it's doing. It's going into the radio Q. And then get some CPU time when the other processes can give it time and then it goes back into the waiting queue to say OK, I'm waiting for some IO. And only ones that I always happened does it go back into that ridicule to say, OK, can you give me some CPU thing? So that's one of the ways that, uh, process. Can can poise anybody want to think of the other reason?
That the process is going to pose. Today she. Or another reason why we may want the process to pause. Because if it's either one, then there's other processes the CPU can be working on. That's true, but the idling is just another word for waiting. So we've, we've covered that one. Any other reason we might want to take? A process out of the running queue.
To store data like if you save the file well. That's true, but storing data, saving a file is. And to open. So that's the same thing. What? What if something more important comes up? I don't. There's, like, a priority issue maybe. Ohh, something more important. Yes, that might be a reason we might want to do it. If something more important Toms up, we may want to interrupt the process.
We might want to say ohh, something's happening. We've got some data coming in from a network. Can you please go and grab this data? Because otherwise we'll lose it. Or somebody's pressed the key. Can you go grab that key, please? Because otherwise we won't know what they've entered. So you might want to enter up. They're running process to go do something else. OK. So that's two ways that the process might stop. Any others that you might want to identify?
Remembering that we'll get lots of processes, all of which want some CPU time, but our CPU time is limited. Remembering also that would describe these as. Time shared systems. Mohammed said crashing. That comes under the same heading as interrupt. It crashes unimportant thing. So yes, you have to deal with it. And you may have to do something with it, but it's still an interrupt, something unexpected, something.
The final one is this timeshare thing. We have one CPU running lots and lots of processes. So what we see is let's give them all a certain amount of CPU to. You get some technical, you get something, you get some time, you get some time, you get some time, and then you go back to the start. You get some time, you get some time, you get some time. So sometimes what we'll do is take processes out of the running.
Box. And put them into the ready queue to say. Ohh yeah, I still actually need CPU time so I've not finished. I'm not waiting for IO. I could use the CPU you've just taken me out of it. So say you're running something like. So you're rendering something on a video or an image. That would take a lot of processing time. But while you're rendering that image, if it just takes all the CPU time.
How are you going to do anything else? How you going to run all the other stuff that's happened? So instead we use this time share idea, we give it some CPU time and then we go back to the other processes to get something done. Some of you will have seen times where that doesn't happen as well as we would hope it would. We are. The process is grabbing the CPU and you're trying to run. You've tried to change to another. Running program and it doesn't quite work immediately. It takes a better time. You've probably heard me shouting at my computer for exactly that reason because it's not running fast enough.
What's happening is that the background it's running a different process and it hasn't given it up. Because it's got to get to a point where it can stop, it can't stop halfway through an instruction. Because we wouldn't know what it was doing. So it's got to finish. And instruction or sometimes a block of instructions. So that's how it could stop. It could stop because. We're waiting for IO.
Or it could stop because we've given it enough time or it could stop, because as Mohammed said, it might crash. But that would make it terminate O that's when we would exit and say, OK, we're terminating now. It could be because it's crashing or could it could be just because we've stopped the program. In either case, we've got some cleaning up to do. It was using memory so we want to get rid of the memory that it was using and make that available to something else.
It was probably showing something on the screen, so we need to take that off. We need to free up any IO that it was using. You have backed the printer. Give back the. The pen, whatever it happens to be. So. But process state diagram is really important to everything that we're doing. Because that's what people say is do they come in, they're treated as a new process, it goes into the ready queue.
When the CPU has time, it starts running. And then it will pause running, either because it's waiting for IO or because it's lost. The CPU. Efforts because it's waiting for some IO, it goes into the waiting queue once the I/O has happened, it can go back into the ready queue and if it's paused because it's running up CPU time, it goes straight back into the ready queue ready for the next time it gets some CPU time.
Until at some point, as you saw in a little man computer, it stops and we run the halt program. And it can terminate, freeing up all the resources that it's been using resources like. Memory. Is that OK? Because that's really fundamental to everything that we're doing from now on. OK. With that, yeah, I'm getting some thumbs up some noise. That's good. OK.
All right, so we've got all these processes all doing things. So we probably want to know something about them. So unless it's a little man computer, while it's only one process running because we run one program and then we load the next one. So it's one thing going. Most of our systems run lots at once, so we need some information about. That's held in something called the Process Control block, a process control block. It's just a block of memory, sometimes called the task control block. But it's just got information on that task.
Which? Part of this diagram is it's an is it ready? Is it waiting? Is it? Whatever. What's the program counter where actually argue in the list of instructions? You registers like the accumulator. So what's the current state of those registers? Which memory does it have? Which fails? Does it have or anything else? Any other information that you might need to store with? And that's really important, that process control block is really important when we do this switching. So let me give you an example of. Switching. So here we've got two processes, P0 on the left.
And P1 on the right. And then imagine the zero and the one are quite small and your screen, which is why I'm pointing that out. So zero on the left, one on the right. Now think back to the little man computer. Think what you've got there. You've got a. You've got a program counter seeing which. Instruction you're at. You've got the accumulator, you've got registers. You've got all that stuff in the CPU. So that's all stored in the process control block.
Your process is running. It runs out of time with the CPU because you've only given a certain amount of time, so it has to go back to the ready queue. What do we need to do to make that work? Well, what we need to do is. There was a zero is executing. It lands it's run out of time, so we need to store all that information. The program counter the accumulator, the registers, everything that needs it, stores that into.
Process control block. Then we switched to the next process. In this case, process one. So in this case we've saved it. No, we need to load up. Drew says control block one. And then we can start executing. You're safe one. Why executes for a certain amount of time whatever time we've given processes to run, then it stops. We then save the state of process one. And reload.
Who says? 0 despite. And then start executing again over here. So. About any issues with doing that that you can see just from that diagram. Lot of time wasted to just save it and reloading. Alright, so we'll get vets where it's executing here, here and here.
But we've also got a lot of times where it's idle this time where we are. Changing the process control blocks is just Adal team. The CPU still running, but it's running doing something that doesn't actually advance what we want to do. So there is overhead. Attached to this. And I'll say this 1000 times during this course, it's about. Getting a balance.
Of course, there's going to be over overlap. Of course. It's going to be idle states if we have to swap processes, but what's the other side of that coin? Only one running, one process at once. Would you like it if you're only running 1 program? And then you had to stop that program and run something else. So it allows us to do. More than one thing and our heads, it's not really. It allows us to pretend that we're doing more than one thing at once, which is good for once.
The other thing, of course is. Process is already spent a lot of time being idle PowerPoints idle right now it's doing nothing, just sitting there waiting for me to press a key. So we can make use of that. The idea that well, actually processes drew a lot of the time don't do anything anyway. With that, all works out to is we can get a system where we can run multiple processes, seemingly all at once.
Of course it falls down sometimes and again you'll all have experienced that you try to run too many things at once, and your computer just slows down and slows down until all you see in the task manager is a big red line where it says system interrupts because it's spending more time. Swapping between one process and another. Then as actually doing any work. And I can always tell when my systems got to that point because it just feels as if it's stopping.
Of course it's not. It's still doing lots of work, but none of it is for me. It's all to support the operating system. So again, it's about getting that balance. We're OK with that before we move on. Yeah, I'll happy. OK. OK, so we've said that we have a purchase and it runs through its instructions and we have a program counter.
What if we could have? Process. It could run more than one thing at once, and if you've got a system that's got more than one processor and more than one core. That would be really helpful. And I talked to you earlier about rendering. What if instead of rendering one pixel? We could train or two or four at a time, depending on how many CPUs are calls that we had. To do that, we introduce something called threads.
So instead of a single thread of execution, we can have multiple. Threads of execution so. A process. Can be doing lots of things at once. I the lots of instances of the same thing. Or. Instances of different things. So if you're running a. If you've got a writer, a network router which is actually just. I spectacularly dedicated computer is still got CPU, still programming language, it's still got an interface.
You make run threads where one of the threads is and put. And one of the threads is output because remember what a richer is is it takes packets of data, figures out where they're going to go, and sends it out to the right place. So you could run a couple of threads, 1 continually taking the output. One sending the to where it needs to go to. That's so important. We're gonna have a whole chapter dedicated to that. Or a whole week dedicated to that. But that will be next week.
Now again we've got some code coming up. Don't panic about the code. You're not gonna be tested on code you don't have to understand the code. I'll bring you up to try and relate it. To a real life system in this case, specifically a Linux system. We said that we have process control block. We'll some clear in our system, we need to store all that and that's how something's gonna say what we're doing here.
You're. As his how Lennox does it. It has a process ID. It has a state. Ready. Running. Waiting. It hides how much time it gets. It has the time slice, how many microseconds of CPU time am I going to get? Not but is important because of what someone said earlier. Because you said you might want to have prioritization, which is true, you may decide that one process is twice as important as another and give that twice as much time. So there's nothing in the rules that says time slices all have to be equal.
You can prioritize some processes over others and give them more time if that's what you want to do. So you have a whole pile of these things. Some of them will point to other things, parents and children. So I'll get Firefox as a parent and each tab is a child. Parent points the child and the child points back to the parent. OK, so we've got all this stuff and we need to decide how it's going to work together.
So I think the very first question today was about timers. So there's a timer running in the background. All CPU's have a timer, it just runs. And any time the CPU is on, it just runs all the time. And you make decide that you're going to get a process 10 clock cycles is every one of these is a clock cycle, so the process gets 12345678910 next swap process.
Next person is comes in. It gets five time cycles. 12345 Switch process go to the next process and so on and so on. And are very glibly said next process well, which is the next process we need some way to decide and that's what the process. Scheduler does. All of those processes and your ridicule. Which one comes next? And again, we're going to be talking about how we decide that. And again, it's about. Different competing. I priorities.
That, that, that's not this week, not Billy drop. So we've got. A schedule that's going to decide what's coming next, and it also looks after all the different queues. All the processes, all the processes that are ready, all the devices that are waiting for input that would. We or something out of the weight queue. No problem, Mohammed.
And as you saw before the process is move around all these different cues based on how you write your process schedule. And I said that. Her reason? Remember, an operating system is just a program program someone has written. And people have made choices about how they rate that they've decided how the scheduler should work. Is it gonna give everybody the same amount of time, or you going to build in priorities?
It's up to whoever rates the operating system to decide how they're going to do that. So it starts. Taking note of all these things, it starts taking note. All, all the things in the ridicule. With all their process control blocks. It starts taking note of all the devices. Desks. Hamill units display. Mike tape.
It really does depend and you can see here that different processes are waiting in different things. Process 7 process two are in the greater queue and they could run if they had the CPU. He'll say she's 314 and six are waiting for disk access there, waiting for data coming in off the disk. Carol says 5 is waiting for the terminal. It's waiting for me to type a key. So all these different processes will be in different places waiting for different things.
Including. I O. And again, they'll be priorities for those as well. So we have this idea that we have different cues doing different things at different things. Thank you. OK, I don't think you're on camera. You will safe. Do you delivery?
Feels. So we have got. Heron says he's coming in. To the ready queue. They then get some CPU time and then certain things could happen if they've got IO requests. Data off the desk key. Whatever it goes into the I/O Q until that O starts, and then once I was finished it goes back into the ready queue.
Their time that they get could have finished. That's enough from you. Stop. And I can go straight back into the ridicule. Little thing could happen is you could fork a child, which sounds fairly vicious, but all it means is start another process, another child process, and it's the equivalent of saying take a new tab. It will start another process for that new tab, but that new process. Also has to wait and it's wait, it's Tom.
So it doesn't immediately start, just cause you've told it to. It's it's another process that has to go back into their etiquette. So the parent and the child will be in their etique as well. Or you could be waiting for an interrupt. Divide by zero so it crashes and and interrupt for the input and interrupt for whatever. Just to make it even more complicated, there are often multiple schedulers. So you've got a short term scheduler. What we're gonna do next? What? What's the next process that we are going to send to the CPU?
No, you don't always have multiple schedules. It would depend on the system would depend on the load. It would depend what type of operating system you have written for what kind of work. But the short term schedule is talking about short time increments milliseconds, so thousands of seconds. You'll also have a long term. Schedule and my Windows machine has that and I know that it has that because my backup routine that runs at 6:00 o'clock tonight is in the long term scheduler. So that process is there, ready to run, and the long term scheduler will run every few seconds or every few minutes saying are there any jobs that you've said should run at a certain point?
And if there are, stick them into the ridicule. You're also trying to balance different types of processes. If you have that choice, so you may not have the choice, you might be just running whatever the user wants to run, but certain processes have. Something biases. Ohh point here has got an IO. Bias we call our IO bound. It's Ben. And what I'm waiting for me than it is actually calculating anything.
Other things are what we call CPU bound. It spends more time calculating things than it does waiting, so again video rendering or or emitted rendering that kind of thing. It's spending more time working out the stuff. Then as waiting on me. If you can get a mix of those, that's a really good. Schedule. If you can get things that are spending a lot of time on CPU and things that spending a lot of time in I/O, then you're making the best use of the system. So that's what we mean by a good process we mix.
We can get CPU bound and IO bound all running at the same time. And some operating systems keep note of certain processes and try and figure out whether they are CPU or IO bound and use that as part of the scheduling. So we'll get short term schedulers, long term schedulers. Other operating sessions put and what they call a medium term. Schedule.

Ask anything
We've read this whole study set, so questions about it get the best answers.