Skip to main content
Loading Explore guides…
Operating System Processes · Acedra
Home
Explore
Computer Science
Operating System Processes
Sign in to save
Chat
If YouTube asks you to sign in, open the video on YouTube.
Watch on YouTube
Reload player
Transcript
564 segments
Copy
Hide video
0:07
OK so.
0:10
We said last week about starting up and we'd said that.
0:14
For many systems like PC or a Mac, what it will do is it will search around looking for some.
0:21
I. Hardware to make sure it's got enough hardware to actually run something.
0:28
Once it's then done that. And general, what it will look for is some hardware with a more.
0:35
Substantial operating system because you could call the bootstrap and operating system, but it doesn't really do all that.
0:44
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.
1:13
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.
1:23
But you can extend that thought.
1:27
If that's what it's doing.
1:31
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.
1:41
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?
1:59
In other words, a simple menu system that says something like run Windows or run Linux.
2:09
And there's been comments about struggling to find material relevant so.
2:16
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.
2:39
Ellie PC couldn't do that LPC's.
2:46
We are tied to the operating system being on the first part of. The hard disk. And that was built into. The bootstrap loader.
3:02
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.
3:17
So you can install multiple different operating systems and choose for drama.
3:22
Is that OK with that question?
3:25
And part of the reason I wanted to talk about GRUB is I'm almost certain.
3:30
But it was N the.
3:33
A presentation from last week.
3:37
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.
3:51
Yeah. So is that OK for that?
3:54
Question. Yep. OK, I'm seeing some notes, so move on to see Perfect. Thank you.
3:58
what the next one is.
4:03
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.
4:36
As opposed to hierarchical operating systems, where you can load in different bits depending on what you want to run.
4:46
And we also said things like Windows takes both approaches, so it's quite a lot baked into the main operating system.
4:54
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.
5:02
Stream, deck or whatever you add in device drivers so that the operating system can talk to that device.
5:13
So.
5:15
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.
5:24
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.
5:38
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.
5:49
Tutorial so apologies for that.
5:56
It's.
6:00
Ohh yes, I do know why it is so. Remember I said we've got out a lot of things.
6:08
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.
6:21
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.
6:40
So the there are headings about that in the slides, but there's more detail about it in the book.
6:52
Similarly, secondary storage management and again we talked about that we talked about the idea that for Windows you save a file.
7:04
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?
7:17
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.
7:37
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
8:04
talking to each other just that communication means that they're slower. So the more flexible but slower.
8:12
OK. I'm just sort of running through these. So if there's questions about my brief explanation, please let me know.
8:25
What's the purpose of system calls? Another name for a system call is.
8:34
Interrupt. No.
8:41
Good idea, but no.
8:43
Remember we talked about an API.
8:47
An application program interface. In order to call the operating system. A system call to create different things.
8:59
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.
9:21
So no. Gentoos not monolithic.
9:26
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.
9:34
Make the most of you.
9:36
2. Click on it.
9:41
All of these things are controlled by the operating system.
9:46
Those Gen 2 requires to be built each time.
9:50
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.
10:05
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.
10:18
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.
10:32
Another one might be something called Check Desk where you can check whether your hard disk is working OK.
10:39
And you get the same sort of things and all sorts of operating systems. So you've got a hard disk manager.
10:46
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.
11:02
What's the purpose of the command interpreter?
11:07
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.
11:37
We talked about the Unix shell and we talked about how someone rewrote it. The guy's name was born.
11:45
And you wrote the shell.
11:47
It was a born again shell or bash.
11:52
So we can. Yeah. Fraser was getting now.
12:01
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.
12:14
I thought I'd go all of those.
12:19
And final one.
12:21
What system calls have to be executed by a command interpreter or shell in order to start a new process?
12:31
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?
12:48
Piece of cutlery.
12:51
Work. Work.
12:54
We did talk about it in the lecture.
12:58
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.
13:26
Any questions about that tutorial then?
13:30
After that brief runthrough.
13:33
And that may be helping future tutorials cause hopefully they are.
13:39
Going back to some of the stuff that we're covered in the slides and we can hopefully make that connection.
13:48
OK, if there's.
13:53
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.
14:08
That's a very good question.
14:17
OK so.
14:20
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.
14:33
So can I leave it? Yes for now. Yeah sure. And.
14:41
I will. We'll talk more about them later in the course, I promise.
14:45
All right.
14:47
Any other questions just now?
14:56
OK, I'm not seeing anything coming up.
15:00
Store what we'll do is we'll move on to chapter 3. No, remember.
15:09
All of the stuff is online.
15:13
We're going through it chapter by chapter. We're on to Chapter 3 today. Which is.
15:21
Processes.
15:29
So I'll go through it as usual. If you have questions that I'm going through it, please stop me and ask.
15:37
And I'm happy to take questions as we're going through.
15:44
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.
15:56
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.
16:09
And as far as I'm concerned, I'm running 5. Different programs.
16:17
But as far as Windows is concerned, I am running hundreds.
16:27
Of purchases.
16:36
So all of these things have to be run somehow.
16:43
And we've only got one CPU now.
16:46
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?
17:02
And they will broaden it out later on about how we might make use of more Singh, confused and more clothes.
17:10
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.
17:25
OK.
17:26
So. In terms of a process.
17:31
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.
17:45
Once we're running it, we call it process.
17:50
And processes have got lots of different attributes.
17:59
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.
18:12
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.
18:27
So it backs up my computer to my network server every day at 6:00 o'clock.
18:34
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.
18:43
Other things will be running at the same time.
18:49
So I said I've got different. Programs running different user programs.
18:55
Teams.
18:57
PowerPoint.
18:59
OneNote, whatever happened to be?
19:03
I've looked at one CPU.
19:06
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.
19:24
So it doesn't matter what we're talking about when we're talking about jobs, it's scheduled or a. Ah.
19:33
A process that we've initiated ourselves.
19:37
The old processes and you, you can think about them as being the same thing.
19:45
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.
19:58
Construction at a time runs, an instruction goes and gets an instruction, executes it. Who's gets next instruction executes that, and so on.
20:07
And all their process is working the same way.
20:13
So we have the idea.
20:18
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.
20:46
So we've got where we are in our process and we've got the state of the process.
20:55
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.
21:27
But they may have other things, so they might have a stack.
21:34
We are, we have. Data.
21:40
That we're going to use again and it's so it's a place we can leave data.
21:45
But it tends to be short term data, so you use a stack for short term data.
21:53
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.
22:03
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.
22:17
You have to know that because they're in blue, we said that you these are likely to come up.
22:25
The difference is stack is short term.
22:29
So when we got an error. Little mind computer and more entering our two numbers. They're stored in the stack.
22:39
But if I'm running a word processor here, my document that I'm creating is stored in the heap.
22:48
So it's for bigger data that's going to be around longer.
22:52
So those all these things.
22:55
Going on all his part of the process.
23:08
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.
23:18
And in fact executing 1 program.
23:22
Make create more than one process.
23:26
I am running Firefox.
23:30
I don't know if you noticed.
23:33
But when?
23:37
I run through these processes. There was a whole set of processes all identifying themselves as Firefox.
23:50
Don't have age running, so I don't know why those age processes.
23:54
One of the things that Firefox does is eat so that again, That's because you're on Windows.
23:58
sorry.
23:59
Windows has air flowing secrets. You've got a search option in the search bar. That class is Microsoft Edge.
24:07
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.
24:19
In the same way as the each tab that I have running here is a process all controlled by the big Firefox process.
24:32
So one program might be lots of processes.
24:39
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.
24:50
So it has to be loaded in. And be held somewhere.
24:56
All of these things that we have. Identified all of these parts. The code.
25:06
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.
25:17
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.
25:27
And you'll see a couple of things here.
25:34
Each process is assigned.
25:39
A certain amount of memory.
25:45
Some of it. Is taken up by the text and the data, and that won't change.
25:51
But some of it. So that stays the same.
25:58
Some of it changes.
26:05
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.
26:16
So in order to.
26:19
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.
26:31
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.
26:41
We're start these two temporary things at opposite ends.
26:46
We'll start with that. Stop the stack at the top.
26:51
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.
27:08
So that's the first thing that we're going to try.
27:11
And make more efficient use of the memory that we have.
27:19
OK so far.
27:22
OK, so we've got these processes.
27:27
And.
27:30
We talk about them being in different states.
27:35
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.
27:50
And.
27:53
We have processes already running.
27:58
So when we initiate it at this new party here.
28:03
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.
28:13
But there's lots and lots of processes. We just saw that.
28:17
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.
28:33
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.
28:46
When the CPU is ready.
28:51
It generates an interrupt and says oh, I'm ready for a new process. Please.
28:58
At which point the next one in the list. Gets. Dispatched.
29:05
To the CPU and starts running.
29:10
And it starts running away on the CPU.
29:14
Now there's two issues with this.
29:17
One is a processes.
29:23
That have an issue.
29:29
Let me ask you a question.
29:32
What do you think takes the most time for processes?
29:41
What is the largest part of their execution type? Anybody want to take a guess? Fetch and the instructions. Say it again.
29:49
Fetching the instructions. Fetching instructions? No, no, it's not. Any other guesses? From the memory.
29:57
As a dealing with new processes. Dealing with new processes. Again, good guess, but no.
30:07
On your screen you've got PowerPoint.
30:12
And it says diagram of a process state. What's PowerPoint doing right now?
30:19
Madelyn.
30:23
Was displaying.
30:25
Sorry. There's the graphical interface.
30:28
As a graphical interface, but I, but what's it doing right now? But it's just point.
30:33
Waiting for an instruction. Was actually showing. It's waiting. It's waiting for me to do something.
30:39
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.
30:52
And that gives us an insight into how this works, because I've got PowerPoint running, but it's not actually doing anything.
31:00
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.
31:14
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.
31:28
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.
31:40
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.
31:55
And what that's saying is, look, I'm waiting in something happening.
32:00
Do bother coming back to me until something's happened, because I don't have anything to do.
32:07
And that's something that's happened. Might be me pressing a button. So how a point is currently in the waiting queue.
32:15
But if I press a button. It says Ohh I've had an IO event.
32:21
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.
32:35
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.
32:53
And only ones that I always happened does it go back into that ridicule to say, OK, can you give me some CPU thing?
33:01
So that's one of the ways that, uh, process. Can can poise anybody want to think of the other reason?
33:13
That the process is going to pose.
33:19
Today she. Or another reason why we may want the process to pause.
33:25
Because if it's either one, then there's other processes the CPU can be working on.
33:30
That's true, but the idling is just another word for waiting. So we've, we've covered that one.
33:36
Any other reason we might want to take? A process out of the running queue.
33:43
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.
34:18
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.
34:34
So you might want to enter up. They're running process to go do something else.
34:39
OK. So that's two ways that the process might stop.
34:44
Any others that you might want to identify?
34:55
Remembering that we'll get lots of processes, all of which want some CPU time, but our CPU time is limited.
35:12
Remembering also that would describe these as. Time shared systems.
35:21
Mohammed said crashing.
35:23
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.
35:38
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.
35:52
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.
36:05
So sometimes what we'll do is take processes out of the running.
36:10
Box.
36:12
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.
36:33
That would take a lot of processing time.
36:36
But while you're rendering that image, if it just takes all the CPU time.
36:41
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.
36:57
Some of you will have seen times where that doesn't happen as well as we would hope it would.
37:03
We are.
37:05
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.
37:20
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.
37:35
So it's got to finish.
37:37
And instruction or sometimes a block of instructions.
37:46
So that's how it could stop. It could stop because.
37:50
We're waiting for IO.
37:53
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.
38:18
It was using memory so we want to get rid of the memory that it was using and make that available to something else.
38:26
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.
38:36
You have backed the printer. Give back the.
38:39
The pen, whatever it happens to be.
38:44
So. But process state diagram is really important to everything that we're doing.
38:51
Because that's what people say is do they come in, they're treated as a new process, it goes into the ready queue.
39:00
When the CPU has time, it starts running.
39:05
And then it will pause running, either because it's waiting for IO or because it's lost.
39:13
The CPU.
39:16
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.
39:33
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.
39:47
Memory.
39:50
Is that OK? Because that's really fundamental to everything that we're doing from now on.
39:57
OK. With that, yeah, I'm getting some thumbs up some noise. That's good. OK.
40:03
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.
40:19
Most of our systems run lots at once, so we need some information about.
40:24
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.
40:41
Which? Part of this diagram is it's an is it ready? Is it waiting? Is it? Whatever.
40:48
What's the program counter where actually argue in the list of instructions?
40:54
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?
41:07
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.
41:22
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.
41:38
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.
41:53
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?
42:07
Well, what we need to do is.
42:11
There was a zero is executing.
42:14
It lands it's run out of time, so we need to store all that information.
42:20
The program counter the accumulator, the registers, everything that needs it, stores that into.
42:28
Process control block.
42:33
Then we switched to the next process. In this case, process one. So in this case we've saved it.
42:41
No, we need to load up.
42:44
Drew says control block one.
42:47
And then we can start executing. You're safe one.
42:52
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.
43:06
Who says?
43:08
0 despite. And then start executing again over here.
43:16
So. About any issues with doing that that you can see just from that diagram.
43:32
Lot of time wasted to just save it and reloading. Alright, so we'll get vets where it's executing here, here and here.
43:43
But we've also got a lot of times where it's idle this time where we are.
43:49
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.
44:05
And I'll say this 1000 times during this course, it's about.
44:12
Getting a balance.
44:14
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?
44:30
And then you had to stop that program and run something else. So it allows us to do.
44:38
More than one thing and our heads, it's not really.
44:42
It allows us to pretend that we're doing more than one thing at once, which is good for once.
44:50
The other thing, of course is.
44:54
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.
45:05
So we can make use of that. The idea that well, actually processes drew a lot of the time don't do anything anyway.
45:15
With that, all works out to is we can get a system where we can run multiple processes, seemingly all at once.
45:24
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.
45:45
Swapping between one process and another.
45:49
Then as actually doing any work.
45:54
And I can always tell when my systems got to that point because it just feels as if it's stopping.
46:00
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.
46:13
We're OK with that before we move on.
46:17
Yeah, I'll happy.
46:20
OK.
46:24
OK, so we've said that we have a purchase and it runs through its instructions and we have a program counter.
46:33
What if we could have?
46:37
Process.
46:40
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.
46:50
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.
47:02
To do that, we introduce something called threads.
47:09
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.
47:27
Or. Instances of different things. So if you're running a.
47:33
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.
47:47
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.
48:06
One sending the to where it needs to go to.
48:12
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.
48:21
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.
48:43
We said that we have process control block.
48:48
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.
48:56
You're.
48:58
As his how Lennox does it.
49:00
It has a process ID.
49:04
It has a state. Ready. Running. Waiting.
49:10
It hides how much time it gets. It has the time slice, how many microseconds of CPU time am I going to get?
49:22
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.
49:44
You can prioritize some processes over others and give them more time if that's what you want to do.
49:53
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.
50:13
OK, so we've got all this stuff and we need to decide how it's going to work together.
50:19
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.
50:32
And any time the CPU is on, it just runs all the time.
50:36
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.
50:56
Next person is comes in. It gets five time cycles.
51:00
12345 Switch process go to the next process and so on and so on.
51:11
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.
51:22
Scheduler does.
51:25
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.
51:47
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.
52:07
We or something out of the weight queue.
52:13
No problem, Mohammed.
52:18
And as you saw before the process is move around all these different cues based on how you write your process schedule.
52:28
And I said that. Her reason? Remember, an operating system is just a program program someone has written.
52:37
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?
52:49
It's up to whoever rates the operating system to decide how they're going to do that.
52:57
So it starts.
52:59
Taking note of all these things, it starts taking note. All, all the things in the ridicule.
53:08
With all their process control blocks.
53:12
It starts taking note of all the devices.
53:16
Desks. Hamill units display. Mike tape.
53:22
It really does depend and you can see here that different processes are waiting in different things.
53:29
Process 7 process two are in the greater queue and they could run if they had the CPU.
53:36
He'll say she's 314 and six are waiting for disk access there, waiting for data coming in off the disk.
53:45
Carol says 5 is waiting for the terminal. It's waiting for me to type a key.
53:51
So all these different processes will be in different places waiting for different things.
53:57
Including. I O. And again, they'll be priorities for those as well.
54:09
So we have this idea that we have different cues doing different things at different things.
54:18
Thank you.
54:20
OK, I don't think you're on camera. You will safe.
54:26
Do you delivery?
54:30
Feels.
54:34
So we have got.
54:37
Heron says he's coming in.
54:39
To the ready queue. They then get some CPU time and then certain things could happen if they've got IO requests.
54:50
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.
55:00
Their time that they get could have finished. That's enough from you. Stop. And I can go straight back into the ridicule.
55:10
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.
55:25
It will start another process for that new tab, but that new process. Also has to wait and it's wait, it's Tom.
55:36
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.
55:47
Or you could be waiting for an interrupt.
55:53
Divide by zero so it crashes and and interrupt for the input and interrupt for whatever.
56:05
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?
56:22
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.
56:36
But the short term schedule is talking about short time increments milliseconds, so thousands of seconds.
56:47
You'll also have a long term.
56:51
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?
57:12
And if there are, stick them into the ridicule.
57:21
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.
57:35
Ohh point here has got an IO.
57:40
Bias we call our IO bound. It's Ben. And what I'm waiting for me than it is actually calculating anything.
57:49
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.
58:04
Then as waiting on me.
58:07
If you can get a mix of those, that's a really good.
58:12
Schedule.
58:15
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.
58:29
We can get CPU bound and IO bound all running at the same time.
58:34
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.
58:46
So we'll get short term schedulers, long term schedulers.
58:50
Other operating sessions put and what they call a medium term. Schedule.
59:00
Windows is one of those things. Sometimes it can say OK.
59:06
You've got all these things running in theory, but they're not doing anything. So earlier on I ran the copyright video and it's running in a films and TV process on Windows.
59:18
But I haven't used it for the last hour.
59:22
Windows would be quite within its, Reece said. Look, you know you've started this, you've said you need it, you've taken up memory space that could be used by something else. Nah. Let's take it out of memory and put it somewhere like the hard disk, where it's not taking up any resources because you're not using this and you know you're not using this, you're not fooling anybody.
59:45
So it gets taken out memory sticks onto hard disk until such times as it's ready to be used, and that's called swapping. It swaps and and out.
59:56
Of the cache, Alan.
59:59
On her desk.
1:00:04
If you have too many processes running. If the scheduler has to do a lot of that swapping, you will see the system slow down because it's spending more time copying things to and from your long term storage. Then it is actually running the program.
1:00:25
Makes sense?
1:00:29
Other systems do it in a different way. Mobile systems for example.
1:00:36
Don't need to think about it so much so I I can see PowerPoint. I can see teams I can see OneNote.
1:00:44
If you've got four one, you don't need to see multiple. Pure sizes.
1:00:50
So it works at a different way. There's OK, you've got one thing running, because that's the thing that's front centre. The thing that you're looking at.
1:00:59
But you may have multiple things in the background.
1:01:02
Like you're running.
1:01:06
You've got Twitter running on your phone, but actually be quite nice. If you had a background process running that you know took a call, took a text.
1:01:16
So the end memory the running. But they're not displaying until such point as the operating system decides. Ohh actually you do need to display you have a call.
1:01:34
OK, so we've got this idea what processes we've got this idea, the change.
1:01:41
To be running on the CPU, the fancy name for that is context switching.
1:01:47
So that bit where we saved the PCB.
1:01:52
To run the new process. This thing here.
1:01:57
This bet in the middle is called.
1:02:00
Hey I'm pointing at it on the screen that I can see rather than the screen that you can see, which doesn't really help anybody. That's bet in the middle is called context switching.
1:02:13
We're switching from process zero to process one.
1:02:21
Not greens getting worse.
1:02:26
Somebody keep an eye on the transform and see if the cancelled.
1:02:32
So.
1:02:33
This is called context switching, and as we pointed out earlier, it does take time.
1:02:40
And the more complex it is, the more time it takes. Clearly, there's more information needs stored for teams than there is for. I'm a phone dial.
1:02:54
So the more information, the more complex system, the longer it will take to switch.
1:03:02
Some CPUs try and mitigate that, so we've said that some of the things that are saved in the PCB are the accumulator or they're or the registers.
1:03:14
But what have you provided more than one accumulator or multiple sets of registers? You could actually store them on the CPU rather than saving them somewhere. So you could see this sets for pure set zero. This sets for pure sets one. This sets for process two. This set for process 3 and that would speed up the context switching, but that's hardware dependent.
1:03:36
So would append on the CPU and how it prints.
1:03:42
Right. We're all OK with that.
1:03:48
OK, So what does the operating system has to have to do has to allow you to create a process.
1:03:58
Start up a process takes some memory. Give up your SSID, bring something in to run it as a program.
1:04:07
And try to understand where it fits within the hierarchy of processes, so you may end up with something like a process tree.
1:04:22
You stopped the system that's process as you will.
1:04:26
The system starts. Teams process one, but teams also stops.
1:04:35
A meeting window. And that meeting window starts up pull window.
1:04:42
Are you? Stop. I'm doing that again. Point at the wrong screen.
1:04:48
So he stopped teams. This team starts our.
1:04:52
A meeting window. The meeting window starts a pole window. I know. That's what. It's what it says in the screen. I'm just giving the other examples or you start Chrome and Chrome starts two tabs.
1:05:04
So you start having all these processors running all connected.
1:05:11
So the operating system has to allow you to create those you've said before.
1:05:19
If you have a parent, it's going to fork.
1:05:25
You then execute the child process.
1:05:30
Until X.
1:05:35
That then goes back to the parent. And that can continue on.
1:05:42
And again, don't panic. Don't need to know the code. But here's how you might do that in code this is see. So it says process ID is fork, in other words, fork what you're doing and give me another process.
1:05:58
If the ID is less than zero, we had a problem. If the idea ID is 0 as a child process.
1:06:06
Otherwise, wait for the payment to complete, and in other words, all of these things are built into the API of the operating system that has to be something in there for them to run.
1:06:18
That's a similar. Thing for Windows.
1:06:24
And again, if you don't understand programming, that's fine. Just take my word for it.
1:06:32
If it has to create processes, it has to get rid of them as well. So you have to have process termination.
1:06:39
No termination can be tricky.
1:06:42
Depending where you are in the tree.
1:06:46
If you're terminating this process, that's OK you're out of the process. ID. Get rid of the memory and it's gone.
1:06:55
But if you get rid of this process.
1:07:00
It has to get rid of these first, otherwise they are just hanging about with nothing to control.
1:07:08
So if you. Delete something higher up in the tree. You also need to get rid of the ones further down. If you don't, you can start to have issues and again I'm sure some of you will have seen that, but you have memory issues. You get to the point you have no memory left simply because there's been.
1:07:31
Poor control of process creation and deletion. Because you can get rid of it just by restarting your system.
1:07:41
So just like it is in your little mind computer where you run the halt.
1:07:48
Command. You can exit up process.
1:07:56
You can also terminate a child process now. I'll tell you now that some of the. Some of the language that's used in these as changing and evolving because some people are very upset that Linux uses the a bot to get rid of a child process.
1:08:18
Other systems use kill.
1:08:21
And people get upset about that too.
1:08:27
But I'm sure you get the idea. What we're saying is we don't need this anymore. Alex, lose it.
1:08:37
And for a lot of systems, you can't have the child continuing if the parents gone, so you have to have this thing called a cascading termination. Get rid of all this stuff underneath.
1:08:58
You also have the.
1:09:01
Option of the parent getting rid of one of the children. By.
1:09:07
Because it wants to see you make close a tab in Chrome.
1:09:12
And you don't want to do anything else in the payment until that tab is closed. So you say, OK, terminate child and then wait.
1:09:21
What you waiting on? You're waiting in that child stopping.
1:09:24
So you can combine to the main process.
1:09:29
Sometimes. That gets confused and as I said, you've all seen that you've all seen systems where you've used up all your memory and it won't do anything.
1:09:40
If there's no parent.
1:09:46
Then you get zombie processes that are just out there and have nothing in them.
1:09:52
And.
1:09:55
If the parents terminated, the child stole running about, it's an orphan. So it's still there, but it's got nothing to be attached to.
1:10:07
As I've said, lots of systems run like this. Lots of programs run like this, including curl. Chrome runs one start process.
1:10:18
That's the Chrome program. But it runs multiple subprocesses, runs processes for each tab. It runs processes for the user interface. It runs processes for the renderer. How it actually creates the the the display on the screen because you get different things depending on what's in the web page. It runs processes for each of the plugins. So if you get loads of plugins that can take lots and lots of system memory and getting rid of plugins can speed up the system.
1:10:50
OK. We're happy with that.
1:10:57
OK.
1:10:59
O we've got all these things running all these different processes, all in the system and sometimes no need to talk. Whether they are.
1:11:09
Ohh appeal child that need to talk to see what's been happening or whether they are separate processes that need to communicate. So you might have worked process and the printer process and you need to send data from what to printer. So those different ways of communicating.
1:11:29
Thi extends out to the idea of communicating where you have physically different computers.
1:11:38
Like I'm doing here, we're on different computers.
1:11:43
I am sending data to the server. The team server and it's sending data out to you.
1:11:51
And we need some way of identifying that data and we call that a socket.
1:11:58
And some of you will be familiar with this.
1:12:01
Kinda stuff.
1:12:05
The idea that you have an IP address where you can send data from one machine to another.
1:12:15
Using the IP addresses a unique address to send the data to so you know that it's going to where you wanted it to to get to.
1:12:26
Having said that, there are multiple services running on computers. So you might have your browser running. That's fine, but you also might have your e-mail running. How do you know if the data that's coming in is supposed to be displayed on your browser or sent to your e-mail system?
1:12:47
Or is some video to see me making sadly motions with my hand.
1:12:54
Well, you have ports.
1:12:58
So you can think of it like the IP address being the address of a block of flats.
1:13:06
If you're sending a letter to that block of flats, you also give a port number and apartment number. I don't number.
1:13:16
So it gets to the block of flats. And then it gets further subdivided to know which door it goes through. A port works in the same way for the computer. The IP address gets it to the computer, and then the port number says. This is web traffic. This is e-mail traffic. This is.
1:13:34
Game traffic or whatever.
1:13:38
And you'll find that different systems use different port numbers. And quite often, if you're running something that uses a New Port number, it won't work, and you'll have to go to your router to say no. I did actually mean to send data to Port 5555 because that's the port my game uses.
1:14:01
Because of your doing security stuff, you don't want to leave open ports because that can be a.
1:14:09
A way of breaking into other systems. So again, back to that block of flats. If you know that there's nobody in flat #3. You could break into flight number 3 and then go through the wall into flat 2.
1:14:22
So you close down your lock down all the other ports, and you only open up the ones that you need.
1:14:30
So you can connect using sockets using the IP address and using these port numbers and some port numbers are well known.
1:14:40
So put 80 for example is web traffic.
1:14:44
Or 127 is for e-mail.
1:14:50
Some things aren't just street theater transfer. Sometimes you want to actually run a program somewhere else, so say.
1:15:00
Do it. Do any of us ever run it, go into travel agents anymore? Say you're on a website. Trying to organize travel.
1:15:09
And you need.
1:15:11
Light. You need a hotel. You need a car high. While you're there.
1:15:16
What you might do is send a request to a remote system to say I need to go to this place at this time.
1:15:25
For this long.
1:15:28
Can you please run a program in your system to tell me if you have a flight?
1:15:34
That conforms to those parameters I've seen you or whether you have a hotel room, it conforms to that.
1:15:41
So you can send a request for another system to run a program and then the output for that will come back to you.
1:15:51
Again, it uses ports so you know which one you run, so you might have systems.
1:15:56
And running different programs for different A.
1:16:03
Who puts? Excuse me.
1:16:07
And you will decide which one of those you want.
1:16:11
You can have a problem because what happens if you are Matt sending a request to a Windows Server? You might speak different languages. You might work in different ways, so you might need some stuff in the middle.
1:16:28
And there's an example. The other Microsoft interfaced definitional language which.
1:16:34
The old that so that they could also.
1:16:39
See middle, because it works in the middle of the systems to make sure that people can talk to each other.
1:16:45
Sometimes that can be even more.
1:16:49
A tricky.
1:16:52
You're all familiar with binary.
1:16:57
Where you have the ones. The two is the fours. The It's the sixteens.
1:17:07
And most of the time, that's the way you've been taught.
1:17:11
But. Does it have to be that way?
1:17:15
Couldn't that just as well be the ones? Choose fours. It's sixteens.
1:17:24
Because actually matter, as long as everyone agrees. And then there was no, it doesn't matter.
1:17:31
But everyone does agree that thing there that you're looking at is how the CPU itself stores data, and it has. There are other wonderful terms, big endian and little endian. Depending on whether the end is a big side or the little side.
1:17:51
So if you're sending data that's big endian to another system that uses little endian, it is. Swap the stuff about so he knows what you're talking about, and it knows that you're sending a 16 rather than A1.
1:18:06
So you get matchmaker services in the middle just to make sure that all that works.
1:18:12
You may have other ways of communicating. You may have something called a Pape.
1:18:18
So we're back to processes on the same system, sending data to each other. In the example I used was what and the print server.
1:18:27
You can set up a pipe between word and the print server to send data from one process to the other.
1:18:35
That's unidirectional. And unidirectional won't work for that cause one of the other things you want to know is whether or not you've printed it so the printer can send back data saying, well, we're done. Or no paper or.
1:18:50
Tuna out.
1:18:52
So that's a bidirectional pipe, so you can send data both weights.
1:19:00
And everybody's saying data once, can you send data both ways at once or does everybody have to wait you on a certain one set of wires? So send a message, send another message, another words, is it full half duplex?
1:19:14
Is there a an implied relationship? Is 1 master of the other, so do you have a parent child relationship? So you can set up all these things within a system to send data.
1:19:28
Depending what it is you want to do with that system.
1:19:33
And where you have multiple pipes where you're sending multiple things, you can even name them so you can name the. The communications devices that are going between those.
1:19:44
No spaces.
1:19:46
And Unix and a Windows systems all have those named pipes in order to allow you to do that.
1:20:01
And that.
1:20:06
Is that?
1:20:10
Anybody have any questions?
1:20:21
Not seeing any hands. I'm not seeing any.
1:20:28
Not seeing anything in the chat.
1:20:37
And sadly I am not seeing that my trains have been cancelled. So it looks like I can come to Paisley after all.
1:20:49
Hola. Makes sense, yeah.
1:20:53
But I, to be fair, that's from where I'm travelling, where I want to. Glasgow Central, Glasgow Central, Paisley.
1:21:01
Yeah.
1:21:06
Yeah, no problem, Frank. I understand. And and in fact, a family. You'll know it's for exactly the same reason.
1:21:15
Ohh yes, teams. Thank you, Kelly. I completely forgot. So for teams in Lanarkshire. Yes, if you can self organize. If you can't remind Henry that needs to finish off. Getting the teams and I've just reminded myself that I need to finish off creating the teams in Easley as well. So if it's empty, wants to rejoin or join another team, let me know. Otherwise I'll do what I said last week. Find a.
1:21:44
And just assign them randomly.
1:21:52
Any other questions?
1:21:59
OK, let me stop the recording.
Here to help you learn
Sign in to keep a private conversation with your course tutor.
Ask me anything about the material…
Sign in to chat