WEBVTT 1 00:00:02.100 --> 00:00:09.599 William Cheng: Okay, this is the second part of lecture 28 so we just finished talking about virtual machine. So that's one way to 2 00:00:10.200 --> 00:00:15.509 William Cheng: shrink the size of the Colonel, because the real colonel in this case is going to be the virtual machine monitor. OK. 3 00:00:16.289 --> 00:00:22.920 William Cheng: So, the other way to do is is to do micro kernels. So the basic idea here is that you just want the colonel to be a smallest possible 4 00:00:23.400 --> 00:00:30.480 William Cheng: You want to move everything into the user space. Okay, so what can you move into the user space, right. So, you know, you can try to move everything into the user space. 5 00:00:31.050 --> 00:00:38.820 William Cheng: So, for example, file system, you know, because move the entire process of entry user space networking stuff. Since then move into user space. 6 00:00:39.690 --> 00:00:47.790 William Cheng: You know line discipline modular moving through the user space. So something still need to stay inside the Colonel, right. So, so what what good to stay inside a kernel. 7 00:00:48.420 --> 00:00:53.670 William Cheng: So you can look at all the other stuff and see anything that you think that doesn't belong to the colonel you're throwing the user space. 8 00:00:54.270 --> 00:00:57.270 William Cheng: Process Management, does it make sense to keep it inside, Colonel. 9 00:00:58.140 --> 00:01:07.890 William Cheng: You know when you try to create process. Do you want the user provided great process in the user space. That seems a little weird. Right, so therefore process management is still done inside a colonel. What about virtual memory. Memory management. 10 00:01:08.370 --> 00:01:12.930 William Cheng: Yeah, it's probably a good idea to keep that instead of Colonel. So again, these are reasonable thing to say is that a colonel. 11 00:01:13.560 --> 00:01:19.620 William Cheng: device driver. So as it turns out, device driver. If you put into the user space the performance is going to be so poor. 12 00:01:20.520 --> 00:01:26.400 William Cheng: The micro Colonel people they keep trying to do that. They, they try to move the divisor winter user space, but in the end it was too slow. 13 00:01:27.210 --> 00:01:31.050 William Cheng: So, you know, and the reason is that device driver. Pretty much every line of code. 14 00:01:31.590 --> 00:01:40.020 William Cheng: You are going to the bus to talk to the device. So in that case, it's our privilege instruction. So move into the user space you're gonna come trappings that occur every time. 15 00:01:40.440 --> 00:01:43.380 William Cheng: You do anything. So again, that's why the performance going to be so forth. 16 00:01:44.160 --> 00:01:51.720 William Cheng: Right. So, India, typically people will keep the device driver in the kernel, even though those people will keep trying to move it into user space. Yeah. 17 00:01:52.380 --> 00:01:56.130 William Cheng: So I think there's something called the user space drivers. So again, people try to do that user space. 18 00:01:56.730 --> 00:02:00.180 William Cheng: So in this case, you know what you need to do that. You also need to add something inside the Colonel. 19 00:02:00.510 --> 00:02:12.120 William Cheng: Okay, so what's added inside the corner over here is called message passing because now you have all the season user space, right. So if you're a user space there like user processes, how to use their processes, talk to each other. 20 00:02:13.320 --> 00:02:18.690 William Cheng: Well, they can't really talk to each other right because they're protected from each other. So in this case, they have to send messages to each other. 21 00:02:19.140 --> 00:02:28.770 William Cheng: Okay, so he's that Colonel the primitive, they will provide something called message passing. So this way if you if you're in one part of the user space program. You want to talk to another part of user space where 22 00:02:29.010 --> 00:02:35.460 William Cheng: You want to go through some, you know, some kind of mechanism that can be that should be as efficient as possible. 23 00:02:36.000 --> 00:02:45.750 William Cheng: Okay, so part of the support is that a kernel is that a they have to use message passing to support them. So we're going to take a look at what these are, to the world. What this message passes are pretty soon. Okay. 24 00:02:47.220 --> 00:02:52.230 William Cheng: All right. So why do people do micro kernels. So the first answer over here is that it's cool. 25 00:02:52.740 --> 00:02:59.160 William Cheng: Because people have tried this for many, many years. Right. And everybody failed. So if you're working on micro colonel. You must be really good. 26 00:02:59.610 --> 00:03:07.680 William Cheng: Okay, you must be a really good programmer, because nobody would dare to try to do what Michael Colonel, so therefore it's cool to get involved in trying to get Michael Colonel to work. Yeah. 27 00:03:08.310 --> 00:03:15.720 William Cheng: I'm the real reason is that we're going to assume that they're always coders are in competence malicious or both. Okay, so 28 00:03:16.410 --> 00:03:23.100 William Cheng: You know, so, so, so the the OS, you know, no matter, especially when we talked at the beginning of virtual machine. 29 00:03:23.520 --> 00:03:32.190 William Cheng: We talked about, you know, the weakest part of the operating system is going to be the device driver, because the device driver running the privilege mo if they if they bring down the operating system or the 30 00:03:32.460 --> 00:03:37.290 William Cheng: Entire operating system is dead. Okay, so how do you isolate those codes from the rest of the operating system. 31 00:03:37.590 --> 00:03:43.500 William Cheng: Right, so the operating system, you know, coder. I mean, now these are these are not the super hacker, there are really good. 32 00:03:43.800 --> 00:03:49.800 William Cheng: Colonel hacking is anybody who implementing things that kernel or some of them are incompetent. Some of them are capable be malicious 33 00:03:50.430 --> 00:03:59.280 William Cheng: So therefore, we certainly we need to, you know, isolate the real Colonel from this malicious code. So the colonel need to be as small as possible so they can be completely trusted. Yeah. 34 00:04:00.060 --> 00:04:05.010 William Cheng: All right. And also, you know, this is kind of a really great idea, right, if everything can be pushed onto the user space. 35 00:04:05.220 --> 00:04:11.640 William Cheng: At some point we're going to be able to freeze the Colonel, we can actually freeze the colonel would say the current. Perfect. Now, nobody has to modify any day. 36 00:04:11.910 --> 00:04:17.760 William Cheng: Whatever you want to do, you do it in user space, right. You want to experiment with a new networking, you know, stack doing a user space. 37 00:04:17.940 --> 00:04:25.860 William Cheng: If you want to experiment with the neck. The, the, the new graphics subsystem doing a user space. If you want to implement a new file system, doing a user space. 38 00:04:26.310 --> 00:04:33.510 William Cheng: Right. That would be a great idea. Okay. So so the so that's why people think microphone are such a great idea because it because it is that extends ability 39 00:04:33.720 --> 00:04:40.140 William Cheng: Once you have a perfect operating system that makes it really easy to add modify or extend the user level a component 40 00:04:40.620 --> 00:04:47.820 William Cheng: Okay, because modifying the colonel is requires special skills and you know you'll be very, very careful. Whatever you do inside carnal. 41 00:04:48.210 --> 00:04:53.910 William Cheng: Yeah, user space program. I mean, if your file system died. Right. So the first. Some of us in the user space. What if it dies. 42 00:04:54.390 --> 00:05:03.570 William Cheng: Well then just means that if you try to use that file system that fosters and is not available, you can still use other file systems. Okay. So, therefore, you know, in this case, again, it's not a big deal right 43 00:05:05.550 --> 00:05:11.760 William Cheng: All right, so the sort of implementation issue for the micro Colonel is that now you have these user space program. 44 00:05:12.210 --> 00:05:19.680 William Cheng: Okay, how do they, how do they talk to each other right i mean you know before we have the reason for the race and called redefined the fastest them. 45 00:05:20.010 --> 00:05:29.220 William Cheng: One. Now can you make a read and write system call it doesn't make sense anymore. Right. So what you need to do is that you need to find the file system that you want to talk to and you need to send message to that file system. 46 00:05:29.460 --> 00:05:36.660 William Cheng: Because how do you send a message to the house is that you need to find out what kind of language that file system speak right if you don't speak the same language. How do you 47 00:05:38.130 --> 00:05:47.250 William Cheng: How do you actually make a request, right, just make a request to say, I don't know what you're talking about like that case doesn't work. Right, so, so, so of course we're not talking about, you know, human language, we're talking about, you know, sort of protocol. 48 00:05:47.640 --> 00:05:53.280 William Cheng: So you need to sort of find out every file system. What kind of protocol today a support and what kind of protocol. 49 00:05:53.640 --> 00:06:00.240 William Cheng: You know, cake, cake, cake, can you use in order for you to talk to talk to these device. Okay, so in that case would be very, very different. 50 00:06:00.690 --> 00:06:05.790 William Cheng: No longer will be using read and read to talk to us and we're going to, we're going to send messages. And when we get responses. Yeah. 51 00:06:06.690 --> 00:06:11.460 William Cheng: And also you need to sort of find out, you know, which causes of support why. So again, there needs to be some kind of a 52 00:06:11.910 --> 00:06:19.920 William Cheng: Sort of a database that you can actually look up and say, oh, you know, this process and on the on my machine they use this kind of protocol. So therefore I can actually talk to this file system. 53 00:06:20.430 --> 00:06:21.720 William Cheng: Guys, and also 54 00:06:22.410 --> 00:06:33.300 William Cheng: In a way, it's kind of really good right you have different kinds of forces them, some of them are more secure than the other. Because, you know, have better crypto and stuff like that. So you can actually pick and choose to find the best file system, you can use for your machine. 55 00:06:33.930 --> 00:06:38.010 William Cheng: Okay, so that's actually a great idea. Right. But it was there, you know, realistic issues. Yeah. 56 00:06:38.460 --> 00:06:48.720 William Cheng: And also, you know, how's the data is going to move around efficiently. Right. You need to pass from one application to the other, we mentioned in the last lecture, right, that you can actually do you know share memory access 57 00:06:49.200 --> 00:06:59.580 William Cheng: We need to talk to a file system is a really good idea to share memory, right, that might be too dangerous because that's, that's like somebody else can modify your address space. So in that case. So yeah, it is very tricky. 58 00:07:01.200 --> 00:07:09.810 William Cheng: Alright, so the original Michael Colonel idea was invented by a CMU regime, use a very, you know, famous computer science for a place 59 00:07:10.380 --> 00:07:15.240 William Cheng: They are the one that invented mark or as a mark is the original micro kernels is them. 60 00:07:15.810 --> 00:07:21.690 William Cheng: So later on I think CMU sort of gave it up. So right now, they're the maintenance are done in University of Utah. 61 00:07:22.230 --> 00:07:28.080 William Cheng: University Utah you. I don't know if you heard of them. But, you know, they are one of the very well known a Unix place. 62 00:07:28.590 --> 00:07:35.910 William Cheng: When you know internet first got started my that was 1969 or something like that right at the, at that time, you know, not only has four notes. 63 00:07:36.390 --> 00:07:43.560 William Cheng: One of them UCLA. One of them at Stanford Sri one of them UC Santa Barbara, and the fourth know is a University of Utah. 64 00:07:44.130 --> 00:07:53.520 William Cheng: Okay, so they have been very, very well known for, you know, Unix. So again, you know, I shouldn't be very surprising that the mark codes and I was maintain a university, Utah. 65 00:07:54.420 --> 00:07:58.710 William Cheng: Alright so mark is sort of the most famous you know Michael Colonel, you know, 66 00:07:59.520 --> 00:08:08.340 William Cheng: An operating system out there, the earlier version is shared the same kernel with Unix right so people who would guess CMU, they also do Unix so so they 67 00:08:09.030 --> 00:08:19.830 William Cheng: Do both they are the basis for the next operating system. I don't know if you remember the company called next right that's the one that Steve Jobs went to the last company that he was at right before he come back to Apple 68 00:08:20.490 --> 00:08:29.160 William Cheng: Okay, so next operating system. They're very famous for the graphical user interfaces and also there's a bunch of CMU grads out there and they they they actually did develop the operating system. 69 00:08:29.400 --> 00:08:38.880 William Cheng: Based on the Mac operating system. Okay, so when Steve Jobs went back to Apple, he brought back the user interface, he also brought back the operating system, the operating system is a Unix operating system. 70 00:08:39.090 --> 00:08:44.790 William Cheng: It also has the influence of Mark inside the operating system kernel. Okay, so one of the reason that the next computing 71 00:08:45.210 --> 00:08:50.580 William Cheng: That can really compete very well against other Unix places and also you know windows and stuff like that. 72 00:08:51.000 --> 00:08:58.170 William Cheng: Is that, you know, I guess they will play around with Mark, and in the end it was kind of slow so you know they're operating system doesn't really take off. 73 00:08:58.950 --> 00:09:02.340 William Cheng: But the graphical user interface is really great. That's, that's why I would love, love company. 74 00:09:03.240 --> 00:09:15.660 William Cheng: Okay. So, later on, you know, the assures us to share the same kernel with Unix. They are the basis for OSF one or SF one is one of the the UNIX standards that were developed by a bunch of Unix company. 75 00:09:16.170 --> 00:09:24.000 William Cheng: In the 1990s, the UNIX system has really bad even add that really bad reputation because they all call themselves Unix, but they're all different. 76 00:09:24.630 --> 00:09:33.270 William Cheng: Okay, so all these companies have decided to come up with one standard and everybody will implement that standard. So that's called OSF one turns out it was, I guess it wasn't very successful. 77 00:09:33.720 --> 00:09:42.360 William Cheng: They become the basis of mock the Mac OS X, Y. So Mac OS. So again, they based on the next. Oh, so therefore you know they're running mark and those are those running Unix. Yeah. 78 00:09:43.380 --> 00:09:52.110 William Cheng: So, so I guess, you know, this is why, you know, at the beginning of apple. You know, when Steve Jobs went back to Apple, they have a lot of, you know, people will know about mocking people from CMU, yeah. 79 00:09:53.100 --> 00:09:57.930 William Cheng: The later later version. They were actually function as a working micro Colonel, they are only the 80 00:09:58.230 --> 00:10:04.050 William Cheng: There's no production system they're actually using micro Colonel only people who are is we're running experimental project with that. 81 00:10:04.410 --> 00:10:13.590 William Cheng: One of the group over here is the new to hurt people. So can you they're famous for the Free Software Foundation. Rather, the one that to all the free software. 82 00:10:14.010 --> 00:10:22.410 William Cheng: Have your special, you know, copyright notice and stuff like that. So, only they are continue to play with the with the idea of Michael carnal. Yeah. 83 00:10:23.220 --> 00:10:26.310 William Cheng: So still today, people don't want to use it because the performance is actually not very good. 84 00:10:26.580 --> 00:10:35.550 William Cheng: Okay, so they're hoping you know one day the performance. Performance, it will be it will be good enough. And then people will start using it because they have all the other advantages that I just mentioned. Yeah. 85 00:10:37.170 --> 00:10:43.740 William Cheng: Alright, so let's talk a little bit about, you know, how do you actually pass messages right so so happens that inside the colonel there this message passing 86 00:10:44.220 --> 00:10:52.110 William Cheng: Message passing services. So you're going to create these things called the message port. Okay. So for example, here in order for me to talk to the file system. 87 00:10:52.350 --> 00:11:01.620 William Cheng: I need to find the message port inside of current also here's the message for right, this one's a request for. So if you want to talk to the PA system, you need to send a message into the request for 88 00:11:02.160 --> 00:11:04.080 William Cheng: Okay, so when you send a message into a request for 89 00:11:04.350 --> 00:11:07.530 William Cheng: The file system over here will be able to pick it up. So, so in this case. 90 00:11:07.710 --> 00:11:16.110 William Cheng: It's kind of look like a Unix pipe, right, if you have a Unix pipe over here, right, one and one of the places for writing and the other one is the other end full, full, full, full, full reading 91 00:11:16.260 --> 00:11:23.160 William Cheng: So this case the application profile will right into the right end of the pipe or the right of the message, poor and the file system over here will be able to pick up 92 00:11:23.490 --> 00:11:30.960 William Cheng: On this message for ok so the main difference between the message poor, you know, and the UNIX pipe is that the UNIX pipe has no name. 93 00:11:31.830 --> 00:11:36.510 William Cheng: Okay. So in this case, if you want to share you unexpired you can only share it between the parent and the child process. 94 00:11:36.870 --> 00:11:42.750 William Cheng: You can't really create a Unix pipe and then tell the another process and say, Come and uses pipe. If the other process is not a parent or child. 95 00:11:43.380 --> 00:11:46.380 William Cheng: Okay, because there's no way to communicate as they were this pipe. This then 96 00:11:47.010 --> 00:11:57.060 William Cheng: So, so, so, so in the the monsters them either these requests or you can actually find it. You can say, you know, find me the request poor for this file system and then the operating system will return to your handle 97 00:11:57.300 --> 00:12:01.440 William Cheng: As in this case, you can actually start writing into the message poor and the process and we'll be able to pick it up. 98 00:12:02.340 --> 00:12:10.740 William Cheng: And similarly, when you know when you need to come to the device driver. So if the device drivers inside the colonel in order for the fastest and to talk to the device driver. 99 00:12:10.920 --> 00:12:17.310 William Cheng: The file system will also ask avenues to them, say hey you know what is the request poor for the device driver. So this way I can actually, you know, 100 00:12:17.940 --> 00:12:24.000 William Cheng: Right message to the request for. OK. So again, why is it that you know you don't you are, you don't actually make a system call 101 00:12:24.840 --> 00:12:33.930 William Cheng: Right. The reason you don't make the system call in order for you to talk to me by a driver is that because what if one day the device driver moving to the user space. Well, in that case, in order for you to talk to it. You need to find a message for 102 00:12:34.590 --> 00:12:42.210 William Cheng: Okay, so therefore they sort of have this uniform design that whenever you do want to talk to any component, whether they're in the operating system or they are in the user space. 103 00:12:42.990 --> 00:12:50.670 William Cheng: user space. Well, in that case what you need to do is they use a find the message or send a message to it and then you need to wait for response because how do you wait for response right 104 00:12:50.940 --> 00:13:01.980 William Cheng: If you want to wait for a response. You need a second pipe. Yeah. So therefore, the idea is, is like this around when you send a request is going to go like this into the device driver when it come back over here, you need to create a port. 105 00:13:02.700 --> 00:13:11.910 William Cheng: Okay, so for the file system. Are we here. What does she do, is that before he sends a request into the request port for the device driver, it needs to create a response port inside the kernel. 106 00:13:12.150 --> 00:13:20.670 William Cheng: And then what it will do is that it would tell that the other this driver just they will you will you finish what you're doing. If you want to send me a response, send it through this port and then that will pick it up. 107 00:13:21.600 --> 00:13:27.000 William Cheng: Okay. Similarly, when the application, talk to the house. Is that what you will have to do is to say that when the file system is done. 108 00:13:27.510 --> 00:13:29.640 William Cheng: You know, here what it will do is it will create a 109 00:13:29.970 --> 00:13:38.610 William Cheng: Response for so this way you will send that information to the fastest and whether buses, then I'll get the response. He was right, they, they, they're responsible for and the application will be able to pick it up. 110 00:13:39.480 --> 00:13:47.010 William Cheng: Okay, so therefore the final picture will look like this. Right. So this page will also show you why the Mac operating system is so slow, right, because 111 00:13:47.340 --> 00:13:54.660 William Cheng: Before the way that you talk to the file system is that you go into the kernel wise. Right. And then when you return and then you have the data that you're looking for. 112 00:13:54.960 --> 00:14:02.640 William Cheng: OK. So now, how many times do we have to go inside of Colonel right we go inside a colonel one time, two times three times. How many times do we return from the user. 113 00:14:03.030 --> 00:14:11.700 William Cheng: Into the user space we reach about the user space one time, two times and three times. Okay. So, simply by doing this, you're going to be three times slower. Every time you make a system call 114 00:14:12.690 --> 00:14:23.430 William Cheng: Okay, so this is what does this. The main problem, you know, with the, you know, with the with the micro Colonel is that is that, you know, everything is going to be three times a slow. So in the end, performance is not going to be acceptable. 115 00:14:24.510 --> 00:14:35.520 William Cheng: Alright, so. So the basic idea here is that, you know, if you want to talk to the file the file system. It's almost like talking to a file server that are sitting on the other machine, right, because when you're sending messages and receive messages. 116 00:14:36.270 --> 00:14:45.480 William Cheng: Then basically you're using client server model, right. So in a way, the mock system even within the same machine you're using the client server model we have clients over here that's going to, you know, 117 00:14:46.680 --> 00:14:55.650 William Cheng: Talk to the server over here. Yeah. And then the server over here will send the data that they did. They did it back to the client or bye bye bye bye bye bye using a sort of a reverse connection. 118 00:14:56.100 --> 00:15:05.940 William Cheng: For those of you who are familiar with our programming right now programming you create the socket that you saw can talk to each other. So over here, it's the same thing. You, you send a request, you know, through some kind of a port. 119 00:15:06.120 --> 00:15:11.520 William Cheng: And then when you get a response value received from from different port. Well guys, it's almost like you know communication codes. 120 00:15:12.120 --> 00:15:15.540 William Cheng: Or maybe exactly the same as communication code. Yeah, and also 121 00:15:16.260 --> 00:15:24.840 William Cheng: You know when you try to receive data over here, right, this this particular port city inside of Colonel, anybody can actually be able to write to data right data into the sport. 122 00:15:25.140 --> 00:15:27.510 William Cheng: Okay. What if I have a malicious program over here that are 123 00:15:27.930 --> 00:15:38.610 William Cheng: Running over here in the user space what it can do, is that he can actually, you know, right, the data over here into responsible and will you pick up the data and you thought that this was from the file system. Well, in that case, it turns out it was not 124 00:15:39.690 --> 00:15:45.720 William Cheng: Okay, so in this kind of system, you got to be really careful because, you know, anybody can actually be able to write to the response for 125 00:15:46.050 --> 00:15:51.750 William Cheng: Okay, so therefore, their security models. A little different, right, because in the typical operating system, the security model is what right 126 00:15:52.290 --> 00:16:02.850 William Cheng: Anybody who created the file gets to have get get to decide who who can access the file, right. So that's the case for for, you know, Linux, Mac, and it's also for Windows gay whoever the CO creative 127 00:16:03.270 --> 00:16:10.470 William Cheng: Get to decide who who who can access the file. Okay, so now you if you have a concert like this, they typically use a different kind of model. 128 00:16:11.040 --> 00:16:19.890 William Cheng: So this model over here. No as capability. OK, so the mark system is a capability basis, then. So what you would do is that whenever you create a response for 129 00:16:20.130 --> 00:16:28.920 William Cheng: Along with the response for. They also create a bunch of capabilities, together with the together with the responsible. Yeah, so the Kevin really is kind of like a credential. 130 00:16:29.310 --> 00:16:37.440 William Cheng: Okay, so what you want. So what you can do is, is that, you know, if you are the process that create this poor you will receive the credentials for the opportunities and always capabilities. 131 00:16:37.650 --> 00:16:43.440 William Cheng: And then if you want to have the file system right into this particular poor, you need to grant them access 132 00:16:44.070 --> 00:16:48.510 William Cheng: Okay, so what you would do is that, will you send a message to the server over here, you know, 133 00:16:49.110 --> 00:16:56.760 William Cheng: In addition to the request message you will also pass the capability to the server. So now the server become capable of writing to the sport. 134 00:16:57.420 --> 00:17:06.810 William Cheng: Okay, if you are a another process over here. Will you try to write to this particular poor you don't have the capability. So therefore we should write this right to this for your access will be tonight. 135 00:17:08.430 --> 00:17:15.660 William Cheng: OK. So again, this is a sort of a different way to provide a security. So one of the funny thing about the capability system is that over here is that once I pass 136 00:17:16.140 --> 00:17:23.070 William Cheng: The once I pass the capability to the server, who is preventing the server from passing that can build out to other user processes. 137 00:17:23.520 --> 00:17:28.860 William Cheng: Well, the answer is nobody right if the server pass the capability to this user process or maybe there's a 138 00:17:29.280 --> 00:17:37.020 William Cheng: There's a way for the user process to steal the the the the the capability from the server. And now this other process can also write to the responsible 139 00:17:37.410 --> 00:17:41.370 William Cheng: Okay, so this is also almost like you know if you if you have a plumbing problem at home. 140 00:17:41.880 --> 00:17:51.600 William Cheng: You call the plumber and then you're not at home. So you give the plumber, a copy of your key. And why is it getting Palmer a copier he look at the key to to to to do 141 00:17:52.290 --> 00:17:58.920 William Cheng: To other people. Okay, so something we should consider the capabilities of one simple way to implement capability is that they can be done using encryption key. 142 00:17:59.160 --> 00:18:05.880 William Cheng: Yeah, so this way you will pass encryption key to the server. So when the server right to this particular responsible, it will encrypt the data. 143 00:18:06.000 --> 00:18:15.300 William Cheng: Will you pick up a data, you try to decrypt it. If you can decrypt that one, then you are set there. If it turns out that it was encrypted with the wrong key word in that case, you won't be able to decrypt that you can actually sort of data way. 144 00:18:16.350 --> 00:18:18.090 William Cheng: OK. So again, that's sort of a simple way to 145 00:18:18.510 --> 00:18:27.150 William Cheng: To implement a capabilities, is that, but again you have to worry about if this is the encryption key. It can be passed around to other you know processes one in da going to end up with a security problem. 146 00:18:27.600 --> 00:18:36.690 William Cheng: Okay. So, okay, we're not going to get into the security problem with the capabilities is them. So if you want to find out about that you probably have to take a security class that. All right. 147 00:18:40.800 --> 00:18:46.080 William Cheng: Alright, so I guess over here is an exit the bottom over here. So this is a company slide right 148 00:18:46.290 --> 00:18:54.750 William Cheng: Successful Microsoft Colonel sister, the answer's no, there's no successful micro kernels is them even though it's a good idea, but in the end the performance is going to be bad. 149 00:18:55.200 --> 00:19:03.060 William Cheng: Many people have tried it. They have tried the idea in Windows NT 3.1 they put the entire graphic subsystem into the user space. 150 00:19:03.660 --> 00:19:08.340 William Cheng: Can you imagine putting the graphics. I'm saying to users page. Pretty soon they realized this is a terrible idea. 151 00:19:08.730 --> 00:19:15.150 William Cheng: So Windows a 4.0 they move the entire graphics apps isn't back about a back end side of carnal yeah for Mac. 152 00:19:15.780 --> 00:19:21.720 William Cheng: OS X, X right and initially they were based on Mark, but pretty soon, right. So, so when Steve Jobs coming 153 00:19:21.930 --> 00:19:28.680 William Cheng: Come back to Apple. There was there in the beginning of they're trying to play with MMA, but as soon as they have to compete with Microsoft as soon as they have to compete against 154 00:19:28.980 --> 00:19:33.960 William Cheng: Against Linux. What are they have to do one then performance become a big issue and they have to put everything back inside. 155 00:19:34.890 --> 00:19:40.470 William Cheng: That so heard the new her is the only Assistant There are based off of. So how come they didn't give up. 156 00:19:41.430 --> 00:19:47.940 William Cheng: We don't really know. My I'll maybe one day they expect the CPU and the hardware to be so fast that it doesn't matter anymore. 157 00:19:48.480 --> 00:19:54.330 William Cheng: Okay, so even though your offices in a little slow, but the hardware is so fast. You won't actually be able to see that these happening system or so. 158 00:19:54.600 --> 00:20:00.420 William Cheng: Okay, so maybe at that point the functionality is going to be more important than people would like the idea of mock right so so we don't we don't know that. 159 00:20:00.960 --> 00:20:12.150 William Cheng: That's going to happen or not. Yeah. Alright. So that's a quick introduction, you know, to the micro colonel. Okay, so now we're done with chapter four. And we're going to move to the last part of chapter five. 160 00:20:12.780 --> 00:20:20.580 William Cheng: Chapter five, we saw the first two parts. Right. The first one is tell you how to implement threads. And the second is how the how to implement interrupts the 161 00:20:21.720 --> 00:20:28.470 William Cheng: I guess there's also the last part over here talk about scheduling that. Alright, so, so, so we're going to talk about scheduling. 162 00:20:28.890 --> 00:20:33.930 William Cheng: You know, you play around with schedule a little bit right in the weeks off and uses them. The schedulers first come first serve. 163 00:20:34.440 --> 00:20:43.560 William Cheng: So it's pretty straightforward, right. So what are the other kind of scheduling policy out there. Why would they make a difference, right. So we're going to sort of take a look at what are the choices you have. Yeah. 164 00:20:44.130 --> 00:20:55.320 William Cheng: The first one is, take a look at the goals of these schedulers. Alright, so, so, so, as it turns out that there's no one size fit all for the scheduler. Okay, different kinds of system needs a different kind of scheduler. 165 00:20:56.010 --> 00:20:58.710 William Cheng: So, so, so the first question will be what kind of system are out there. 166 00:20:59.430 --> 00:21:11.220 William Cheng: Okay, so, so we're going to start with a really, really. Oh, Sam. So this is IBM right idea has a simple batch system. So what you do is that you send me your job and you go take a coffee break. Half an hour later, you come to the printer and you get your result. 167 00:21:11.430 --> 00:21:17.370 William Cheng: Right. And the reason it takes so long. Is that because there are many people in front of you. They all want to run programs. Right. So these are called batch systems. 168 00:21:17.760 --> 00:21:28.560 William Cheng: You submit your job as a batch. And then, you know, whenever is your turn. You get running out of CPU. And we are done. You know, then, then, then the, the, you get to use a see the print up there. 169 00:21:29.010 --> 00:21:39.780 William Cheng: And then they come up with something called a multi program, you know bash. So the simple batch over here. When it's time for your program to run you your seat you know your program is the only one that's using the entire machine. 170 00:21:40.110 --> 00:21:48.360 William Cheng: Okay, so you are using the CPU you're using all the IoT devices. I mean, clearly when you're running your code, you cannot use your CPU and our device at the same time. 171 00:21:49.200 --> 00:21:54.840 William Cheng: Okay, so therefore, in that case, you know, when you are using iOS device you're not using the CPU. So in that case is total waste. 172 00:21:55.290 --> 00:22:06.210 William Cheng: So they are already coming up with the multi you know the multi program, you know, a batch over here. So basically I do over here is that if you're a threat is using the iOS device. So maybe we should give the CPU to another threat. 173 00:22:06.780 --> 00:22:19.740 William Cheng: Okay, or another or another process. So, this is called multi programming, right, both of programming is allowed the multiple, you know, multiple processes to use the same CPU by juggling that ok so again this is 174 00:22:20.820 --> 00:22:29.010 William Cheng: You know, this is so this is good old days, and there's only one CPU, but you run, you know, you, you're going to switch from one process to another so fast, it looks like they're running parallel 175 00:22:29.880 --> 00:22:37.620 William Cheng: OK. So again, typically again for the horror people at this is called concurrency, you can really call this parallel. Is that because there's only one CPU. So again, in our class. We don't really 176 00:22:38.310 --> 00:22:50.160 William Cheng: Distinguish that. Alright. So those are the two releases them and then while we talk about the time sharing system right the time sharing just means that there's an interactive user. So we have an interactive user why the system going to be different. 177 00:22:50.820 --> 00:22:59.280 William Cheng: Okay, so, so in this case the jobs that are running inside the system. There's the interactive jobs and they're also the batch jobs so people can still send me the same job. 178 00:22:59.520 --> 00:23:07.680 William Cheng: Right, because the interactive user typically the interactive user doesn't do anything right you guys sitting in front of a computer, you're not typing all the time, right, you, you're looking at your computer screen you're thinking 179 00:23:07.920 --> 00:23:18.630 William Cheng: Well, in that case, you know, the CPU can be given to somebody else. Okay, but but anytime you know the interactive user start interacting with the computer, you want to make the interactive user as happy as possible. 180 00:23:19.680 --> 00:23:29.370 William Cheng: Okay, so this means that inside the CPU, the scheduler has to change. Right. You want to give the interactive user higher priority and give all the batch jobs lower priority. 181 00:23:29.910 --> 00:23:37.290 William Cheng: Okay, so in that case the you know the scheduling display is going to change. You're going to start using a priority queue up a party and scheduling system. 182 00:23:38.220 --> 00:23:48.810 William Cheng: OK. So again, this will, you know, largely sort of affect the scheduler. And then we talked about, you know, inside the data center, right, you're going to have these giant, you know, 183 00:23:49.470 --> 00:23:53.160 William Cheng: You know, virtual machine monitor or the hypervisor. You know, the running multiple virtual machine. 184 00:23:53.550 --> 00:23:58.800 William Cheng: So in that case, we want to make sure that you know if you if you pay for one 20th of that virtual machine. 185 00:23:59.100 --> 00:24:08.640 William Cheng: So one 20th of the virtual machine monitor, you're going to get 120 percent as one 20th of all the hardware, right, you're going to get 101 20 of the CPU one 20th, the memory one 186 00:24:09.030 --> 00:24:15.360 William Cheng: This one already have everything. Okay, so how do you have a schedule and I can guarantee that you get one 122 CPU. 187 00:24:15.600 --> 00:24:24.930 William Cheng: Right, because if others if other people running on the same machine if they're a CPU hog. They want to use a lot of the CPU cycles over here. How do you prevent that they don't take that, you know, 188 00:24:25.860 --> 00:24:28.320 William Cheng: Sort of one 20th of the CPU away from you. 189 00:24:28.890 --> 00:24:40.050 William Cheng: Okay, so we're also going to talk about, you know, these kind of partition server over here. We want to make sure that all these virtual machines are completely isolated. Right. What kind of schedule or do we need, you know, you know, in order to make sure that 190 00:24:40.440 --> 00:24:43.380 William Cheng: They have performance isolation, right, as well as we're going to see that. 191 00:24:43.680 --> 00:24:51.840 William Cheng: And then there's a general purpose operating system that's what we use today in your laptop or your desktop. So again, you know, do they all kind of operating system, they'll kind of schedule. Do they need 192 00:24:52.290 --> 00:24:59.970 William Cheng: Okay, so we're also going to examine what this window run. What is Linux run. There's also another kind of system over here. I've known as the real time system. 193 00:25:00.870 --> 00:25:04.350 William Cheng: Okay, so these are the kind of a specialized operating system, but they're actually 194 00:25:04.920 --> 00:25:10.620 William Cheng: You know, sort of a general enough. I think if you're an Eastern that you can actually take a classical real time system class. 195 00:25:10.890 --> 00:25:20.070 William Cheng: I think in computer science. They probably offer real time system classes once in a while, but typically the offer. I think they're offered by the W department. Yeah. Alright. So. So in this case, you know, 196 00:25:21.600 --> 00:25:27.270 William Cheng: You know, the, the scheduling policy is going to be a little weird, right. So typically when you try to you know like Unix a 197 00:25:27.660 --> 00:25:34.650 William Cheng: Assignment when you get on the run queue. Right. You just wait for the CPU. What does he do become available. You know, if you're the next thread inside the run kill you start running 198 00:25:35.280 --> 00:25:41.820 William Cheng: Okay, so therefore, all you do is that when you add a threat into the wrong. Q All you do is you. The only thing that you add to the monkey is the thread itself. 199 00:25:42.450 --> 00:25:54.030 William Cheng: Okay. In a real time system every thread is going to come with a deadline. OK, so the deadline is to say this job has to finish running out of CPU by this deadline otherwise bad thing is going to happen. 200 00:25:55.500 --> 00:26:05.880 William Cheng: Okay, so. So again, you know, so, so this is kind of a very strict requirement. Right. So, so, you know, so the threat when it comes out of CPU, there's a deadline that this one has finished running by a certain time now. 201 00:26:06.600 --> 00:26:12.060 William Cheng: So it depends on you know what kind of backing that can happen and we divide this into two, two different kinds of real science time since that 202 00:26:12.510 --> 00:26:20.970 William Cheng: One is called the heart real time system, okay for the heart, the heart rhythm system over here for the hardware. THAT IS MISSING THE DEADLINE MEANS disaster. 203 00:26:21.390 --> 00:26:25.140 William Cheng: Okay, people is going to die. We're going to lose. Because helium know billions of dollars or something like that. 204 00:26:25.530 --> 00:26:29.640 William Cheng: So the example that will give in the textbook is controlling a nuclear power plant. 205 00:26:30.060 --> 00:26:33.660 William Cheng: Okay, so, so how do you, you know, implement a controller for nuclear power plant plant right 206 00:26:33.810 --> 00:26:41.820 William Cheng: So. So typically what you have to do is that you have a controller tried to sort of make sure that things don't go bad inside a. Is that a nuclear facilities that you have to take measurement all the time. 207 00:26:42.270 --> 00:26:49.230 William Cheng: Okay. So for example, you know, so somebody come up with some equation to say that while you have to, you have to take a temperature every, every 30 seconds. 208 00:26:50.280 --> 00:26:55.380 William Cheng: Okay, so if you missed your deadline, then you know maybe something back and actually happened. But in the end, you going to end up with 209 00:26:56.220 --> 00:27:04.860 William Cheng: You, you can end up with a nuclear meltdown. So that would be really bad, right, you probably have to take a temperature every 30 seconds, you probably have to take a pressure reading 210 00:27:05.040 --> 00:27:11.430 William Cheng: You probably have to take a moisture reading all this kind of stuff. So there's a lot of monetary attached. You have to do you have to do this periodically. 211 00:27:11.850 --> 00:27:17.820 William Cheng: Okay, so this way you can make sure that you know the the nuclear reactors, as I gotta go crazy now. 212 00:27:18.240 --> 00:27:25.920 William Cheng: The second example over here given by the textbook is landing softly on Mars. Okay. I mean, landing on Mars is really easy just land on 213 00:27:26.280 --> 00:27:33.030 William Cheng: That no that'd be nice, right. So what you have to do is say, you have to actually slowly the scent on Mars, and make sure that you actually you lead perfectly on Mars. 214 00:27:33.390 --> 00:27:37.020 William Cheng: Right, so you know case you need a real time operating system, right, because you have to keep monetary 215 00:27:37.410 --> 00:27:45.120 William Cheng: The terrain. So you know that whether you're going to put your leg down at a bad place or not. So this way. Again you slowly come down a unique keep looking at the ground. 216 00:27:45.480 --> 00:27:54.000 William Cheng: To make sure that you're going to the right place. Okay, so to get all the job that you're going to run inside a CPU. They all have a deadline. If you miss a deadline, one in this case, I mean, 217 00:27:54.990 --> 00:28:08.490 William Cheng: You know if this you know if this aircraft has no people on that my neck is no people is going to die. But you know, it's a disaster for the project that is going to take you several year to send another, you know, send another spacecraft to Mars. 218 00:28:09.210 --> 00:28:18.270 William Cheng: Okay, so in that case it will be a disaster for the entire company for the entire project, the entire project. So in that case, you know, which you use in real time, it was us a heart real time operating system. 219 00:28:18.990 --> 00:28:27.990 William Cheng: That alright so these are the system what we typically require a specialized optimism. I mentioned before, we typically we talk about general purpose openings, is that 220 00:28:28.230 --> 00:28:36.420 William Cheng: Okay, so, so, so, I mean, this will be the only sort of exception. We're going to talk a little bit about what kind of scheduler, do you need to do for you know for hardware time system. 221 00:28:36.990 --> 00:28:45.270 William Cheng: Yeah. The other kind of realizes, I know it's a soft real time, Sam. So in this case, meeting a missing the deadline doesn't really mean a big deal. Nobody's gonna die. You're not going to lose. Good. 222 00:28:45.810 --> 00:28:54.630 William Cheng: Zealand dollars but happiness is going to degrade the quality of the user experience. Okay, so we all see system like that. Right. So we are watching YouTube video. 223 00:28:54.870 --> 00:28:57.120 William Cheng: Or when you're watching you know some kind of a recording 224 00:28:57.390 --> 00:29:06.810 William Cheng: All of a sudden you're especially on YouTube, you can see the things spins. Right. And then, you know, after a while, you know, they got to be able to watch the video again. So that's really not a good experience. 225 00:29:07.290 --> 00:29:15.600 William Cheng: Right. So in that case, you know, when you miss the deadline, you know, so, so the video is coming across the you know the the network. And I think 30 frames per second. 226 00:29:15.900 --> 00:29:23.850 William Cheng: Right, so every frame, sort of, you know, have a deadline of one 30th of a second. So if you so if you don't have the data at 130 have a second. So in that case, 227 00:29:24.060 --> 00:29:33.990 William Cheng: Either they will try to construct that friends going to look really weird or sometimes when you see the stuff on the screen you see the squares appear on your TV well. So in that case, again, it cannot keep up. So therefore, again, 228 00:29:34.200 --> 00:29:41.910 William Cheng: It degrades the user experience. But again, nobody died. Somebody lose a lot of money. Okay, so in that case. So these are no it's a soft real time system. 229 00:29:42.600 --> 00:29:49.950 William Cheng: So, you know, play playing streaming audio streaming video. So if you're on voice over IP right you have a phone like that when you 230 00:29:50.250 --> 00:29:56.280 William Cheng: When we use the phone like that, once in a while, you will see that the voice is getting garbled right so what do you do 231 00:29:56.580 --> 00:30:00.630 William Cheng: All you have to say, Could you say that again and you will be able to recover, you know, from the air. 232 00:30:01.020 --> 00:30:11.700 William Cheng: Okay. So in a way, we are being trained by the soft real time system to know how to behave and then in the end we won't get too upset when the, the, the quality of the user experience about degraded. 233 00:30:12.540 --> 00:30:20.400 William Cheng: Then we also show that, you know, these kind of system can be can be built for the soft real time system that can be built using a general purpose operating system. 234 00:30:21.150 --> 00:30:30.720 William Cheng: Okay, so, so, so you can so you know when you use a laptop or user desktop. There's no problems streaming audio and video Make use them to make phone calls, you know, Skype, all this kind of stuff. Yeah. 235 00:30:31.350 --> 00:30:36.930 William Cheng: Alright, so these are the different kinds of, you know, the system that we need to deal with. So, so in this case, you know, 236 00:30:37.650 --> 00:30:42.180 William Cheng: You know, which one is going to be the best scheduler well as, as it turns out, it's kind of tough to say 237 00:30:42.510 --> 00:30:49.830 William Cheng: Different operating system, you know, vendor, they have different approaches to do things. So in the end, it really depends on exactly what you're running all the systems. 238 00:30:50.190 --> 00:30:54.060 William Cheng: Okay, and also when you try to talk about what is the best scheduler to run 239 00:30:54.690 --> 00:31:03.660 William Cheng: Okay, what is the best schedule was said, Well, how do you actually measure what's best. Okay, you need some kind of performance metrics in order for you to tell that the schedule is actually better than CH scheduler be 240 00:31:04.080 --> 00:31:11.190 William Cheng: Okay so messy want to look at is what are the typical metric that you will use to sort of compare different kinds of scheduling. 241 00:31:12.120 --> 00:31:22.140 William Cheng: Now, so yeah, so, so, so, so when people look at all these kind of stuff. Different people have different kind of metrics. Unfortunately, some of these metrics, a conflict with each other. 242 00:31:22.680 --> 00:31:32.700 William Cheng: Okay, so there's therefore there's no way to actually optimize for all the metrics over here, you need to decide which one is more important to you. And then, you know, given that maybe you can actually to figure out what is the best schedule. 243 00:31:33.390 --> 00:31:38.820 William Cheng: Okay, so in reality, sort of picking the best schedule is actually very difficult a difficult job right. You need to know exactly what you're running 244 00:31:39.030 --> 00:31:49.800 William Cheng: And then, and then then you sort of need to figure out which kind of performance metrics that you want to optimize for example, you know, for the partition server, right, if you're running inside the data center. 245 00:31:50.250 --> 00:31:58.530 William Cheng: You spent a bunch of this has been a lot of money on it. You want to make sure you get one 20th of the CPU, even though you don't perform very, very well. But you want. So you want your 246 00:32:00.180 --> 00:32:05.880 William Cheng: You want your virtual machine vendor to be fair to you, right. So, in that case, fairness is more important than anything else. 247 00:32:06.960 --> 00:32:11.550 William Cheng: Alright, so again you know sometimes you need to make these kind of decisions, even though it might not make perfect sense. 248 00:32:12.030 --> 00:32:18.240 William Cheng: But you still need to make a decision to see what was more important to you. Yeah. Alright, so let's take a look at some of these performance metrics over here. 249 00:32:18.480 --> 00:32:30.150 William Cheng: Number one is to maximize the CPU utilization is what is the CPU utilization right the CPU utilization is going to be a number between zero and 100% if the CPU is 100% utilized. I mean that the CPU is busy all the time. 250 00:32:30.780 --> 00:32:37.620 William Cheng: Okay, the CPU is zero percent utilized. That means that the CPU is not is not very, very busy that so this one case is just one number 251 00:32:37.980 --> 00:32:45.360 William Cheng: Your warm up to right, you're going to see you. Actually you print out the fraction of time the server is busy. So that's also known as the utilization 252 00:32:46.260 --> 00:32:54.390 William Cheng: OK, so the utilization over here is the store the fraction of time a particular server or the CPU or the hardware that that that's busy. 253 00:32:55.080 --> 00:33:02.490 William Cheng: OK. So again, this, this number is actually not very, very good, right, because just because your CPU is actually very busy. Does it means that you have a good scheduler. 254 00:33:02.790 --> 00:33:13.800 William Cheng: I mean, what if some stress over here are doing Busy waiting. Well, in that case, even though your CPU is very, very busy. It doesn't really mean that you have the schedule. Okay. And also, this just a number between zero and 100 so it doesn't really give a lot of information. 255 00:33:14.940 --> 00:33:21.720 William Cheng: That. All right. Another metrics that we're going to use quite often. It's called the CPI is called a throughput. 256 00:33:22.170 --> 00:33:29.280 William Cheng: The throughput is measure in this weird unit over here. It's called jobs per second. Right. We talked about threats. So what our jobs over here. 257 00:33:29.520 --> 00:33:39.420 William Cheng: Okay, so the textbook defined the job. This way there. Alright, so, so you get on the wrong thing over here you know wait for the CPU to become available. And now you are brand new job at the wrong cute. 258 00:33:40.080 --> 00:33:46.920 William Cheng: Okay, so when you get on the ranking for the first time you're, you're a different job and then what you do is that you get to run inside. Inside the CPU. 259 00:33:47.220 --> 00:33:54.510 William Cheng: Now and then, at some point, you can get bumped off, but you get bumped up you're going to go back into the run queue. And then you're going to get on CPU. Again, you get bummed Bob, you can go back and forth, back and forth. 260 00:33:54.870 --> 00:34:01.830 William Cheng: At some point when you are finished with the CPU when you finish all your competition. Is that a CPU, you're going to voluntarily give up the CPU. 261 00:34:02.460 --> 00:34:10.620 William Cheng: OK. So again, why would you monitor and give up the CPU. Well, maybe you need to wait for a new tax way. Maybe you need to wait for it. Oh, you need to wait for this way for that. Well, you need to wait for something 262 00:34:11.130 --> 00:34:20.790 William Cheng: You were in the running state. And now you go into the waiting state. Okay, so when you go into the weight instead over here. That's where you leave around to you next time, will you come back into the rank you you are a new jobs. 263 00:34:22.080 --> 00:34:28.710 William Cheng: Okay. So, this way we can actually, you know, sit at the monkey over here and measure the number of jobs per second that's being served by the scheduler. 264 00:34:29.520 --> 00:34:38.760 William Cheng: Okay, so in this case we want a big number. They want a small number. So typically we want other jobs for a second to be as high as possible what that means that it seems that we're doing a lot of work. 265 00:34:40.200 --> 00:34:52.650 William Cheng: Okay, so remember over here. You know when you get on the run queue, you can run inside of CPU and then you can be put back you only consider that you left the CPU when you voluntarily give up the CPU and going to the waiting state. 266 00:34:53.370 --> 00:35:02.280 William Cheng: All right. Okay. There's a little comment over here, a threat, sometimes can be incorrectly classified as either a CPU bound or IO bound threat. 267 00:35:03.000 --> 00:35:13.590 William Cheng: Okay, so, so if you think about your thread over here. Our CPU bound, meaning that when it. You know what that means that when he ran. He said to CPU. He wants to hold on to the CPU, as long as, as long as you want. 268 00:35:14.340 --> 00:35:22.920 William Cheng: Okay, a job is the IO bound job. That means that whenever he tried to run, he's out of CPU only needs to CPU for a very short period of time and then it's going to go away for a while. 269 00:35:24.030 --> 00:35:33.240 William Cheng: Okay, so in that case, if you think about your threading warm up one by one by one. You have a threat. Now you don't have more time to it, you only have one thread is that thread CPU bound or IO bound 270 00:35:34.950 --> 00:35:44.220 William Cheng: OK, so the answer for that is that it depends on you know what it's doing. Right. So over here, what would the way I can sort of think about this is that on the horizontal axis over here is time. 271 00:35:44.580 --> 00:35:52.290 William Cheng: Okay. The vertical axis over here. So over here, I'm CPU bound right at the bottom over here I'm IO bound. Okay, so in the beginning of your warm up. What do you do 272 00:35:53.220 --> 00:35:59.220 William Cheng: While you try to, you know, read all these Ben transaction records. So therefore, you're going to the iOS device all the time. 273 00:35:59.490 --> 00:36:06.210 William Cheng: Right. So in the beginning, over here, you're actually your, your thread is about that at some point. So every time we will, you know, 274 00:36:06.810 --> 00:36:15.420 William Cheng: Read a line from the input your parcel you feel a data structure your pendant to a tutor to us right and then you go back to the IO again. 275 00:36:16.260 --> 00:36:24.360 William Cheng: Okay, so when you parse that online. And then when you have had to tell us how long does it take well it doesn't really take very long. Right. So, therefore, you're going to end up doing I O most of the time. 276 00:36:24.780 --> 00:36:33.030 William Cheng: Okay, so therefore your IBM job right when you whenever you get it, and then to run inside of CPU you only run for a small amount of time and there you go with it again right what you call reading for 277 00:36:33.300 --> 00:36:40.200 William Cheng: You with while Yeah, at some point we finished reading all your records and now you're in the link test. And the next thing you need to do that, you need to sort it 278 00:36:40.650 --> 00:36:47.940 William Cheng: Okay, well you perform the sort operation. Okay. It depends on how you implement so you know bubble sort of whatever sorted. So do you go to the iOS device. 279 00:36:48.810 --> 00:36:54.720 William Cheng: Actually, you don't at all, right. So, therefore, at that point, it will turn into a CPU bound job over here and then it will stay there for a long time. 280 00:36:54.990 --> 00:37:06.300 William Cheng: How long the link list is right in the link. This is really, really long as 1 million elements over here will take you very long time. And then in this case you don't go to IoT device it all you want to use the CPU, as long as possible. 281 00:37:07.050 --> 00:37:14.190 William Cheng: Okay. And once you finish that. What do you do you start printing them out one one, you know, one one data structure at a time. So in this case, yeah, you become IO bound job. 282 00:37:14.370 --> 00:37:24.600 William Cheng: Right, because every time when you run inside of CPU. You go to the link. Let's get the next get get get get get the next transaction you format a transaction over here and then you call right 283 00:37:25.050 --> 00:37:37.350 William Cheng: To send the data out of this way. Okay. So, in that case, again, if the display. So you're going to end up waiting for this way all the time. And then in that case you'd become IO bound album job. Yeah. So, therefore, if you look at this picture I this entire thread. 284 00:37:38.820 --> 00:37:39.990 William Cheng: Whoops. 285 00:37:45.570 --> 00:37:47.670 William Cheng: Okay, I end up getting this thing. 286 00:37:51.150 --> 00:37:58.470 William Cheng: Yeah, sorry about that. Okay. So if you look at this picture over here is this thread CPU bow, bow, bow was it's neither right because sometimes CPU bound samples. 287 00:37:59.370 --> 00:38:10.440 William Cheng: So if you look at this as a job, then it will make more sense right at the beginning over here. Do I have a lot of job right every time I leave the run over here. And if I leave the CPI pick up a different job. So at the beginning over here. I'm actually many, many jobs. 288 00:38:11.040 --> 00:38:16.680 William Cheng: Okay. When I become a CPU bound bound job to do. The story I stay as one job because I don't give up the CPU. 289 00:38:17.100 --> 00:38:21.690 William Cheng: Okay, so therefore, in this case, I'm going to run for very long time as one job and then Indiana area when I 290 00:38:22.140 --> 00:38:33.360 William Cheng: When I start printing printing data out to the display. Again, I'm gonna come to the CPU many, many times and go to the IoT devices at the time. So in this case I will be I'll become you know many, many different jobs. 291 00:38:34.470 --> 00:38:42.210 William Cheng: Okay, so you can see that all these jobs are actually different. Right. These jobs over here, they require to see people are very short period of time. This job is a really, really long job. 292 00:38:42.750 --> 00:38:47.880 William Cheng: Okay, so all these job. There are different size, guys. Some of them will use the CPU for a long time. So we use for for a 293 00:38:48.480 --> 00:38:58.830 William Cheng: Very short time. So again, it makes more sense to talk about the job in CPU bound IO bound and it doesn't make sense to talk about a threat being CPU bound CPU bound oil, oil. 294 00:38:59.580 --> 00:39:06.930 William Cheng: Okay, because, you know, because when you talk about a job, the job, get on the run queue depend. So when you get on the wrong code. Do you know how much of the CPU time you need 295 00:39:08.700 --> 00:39:16.050 William Cheng: Right. So if you think about warm up wine. Right. Well, one on one. When you get on the CPU you actually, you can actually look at your code and you see how long the the you know the the list is 296 00:39:16.290 --> 00:39:25.410 William Cheng: You can sort of get an idea of how long you're going to use the CPU. So therefore, in a way, if we can pass that information to the operating system, the organism, I should know that whether you're going to be a CPU bound or IO bound job. 297 00:39:26.340 --> 00:39:37.710 William Cheng: Okay, alright. So anyways, so. So again, it's more important to look at jobs and don't look at threats. Right. So right now, you know, when we talk about scheduling. We are scheduling jobs and we're not scheduling threads anymore. Okay. 298 00:39:38.730 --> 00:39:44.160 William Cheng: All right. The other thing is that we can actually minimize waiting time. So what is waiting time. Right, so the textbook defined waiting time is this 299 00:39:44.430 --> 00:39:56.040 William Cheng: The time when you first get on the donkey. We're going to start a clock okay at the time where you voluntarily give up the CPU. We're going to stop the will. We're going to stop the clock and the difference between these two hog value is you're waiting time 300 00:39:57.210 --> 00:40:02.670 William Cheng: Okay. So, therefore, you know. The other way is that you know you want your waiting time to be as short as possible. Right. 301 00:40:02.790 --> 00:40:10.080 William Cheng: So if the time that you use inside the CPU. This one is a fixed amount every time, will you get onto the rank you you know exactly how much time you going to spend inside of CPU. 302 00:40:10.230 --> 00:40:15.360 William Cheng: Well, in that case what you're what you're trying to minimize waiting time you're going to minimize the amount of time that you stay inside of you. 303 00:40:16.110 --> 00:40:27.090 William Cheng: Okay. So is that a good thing to to minimize right so when you're waiting. Is that a monkey. What are you waiting for, you're waiting for all the job ahead of you. That's going to get to use the CPU first before you get to use CPU. 304 00:40:27.690 --> 00:40:32.760 William Cheng: Okay. So, therefore, if you have a smart scheduler, maybe, in that case, you're waiting time can minimize 305 00:40:33.120 --> 00:40:45.030 William Cheng: Okay, so therefore, another matches over here is that you can minimize waiting time again the waiting time is defined in the we're way over here is defined that that the difference between the time that you give up the CP voluntarily and the time you got on the donkey. 306 00:40:46.260 --> 00:40:53.520 William Cheng: Okay, so we're going to sort also learn how to compute this, you know, a little later. Okay. All right, so 307 00:40:54.090 --> 00:40:58.230 William Cheng: And also there's some people have said a while. Maybe you want to minimize the response time. So what is the response time right 308 00:40:58.380 --> 00:41:07.470 William Cheng: So responsive. It's kind of hard to define. Right. But it's basically a sort of tells you whether your operating system or your scheduler is responsive or not. So how do you know when the system is responsive. 309 00:41:07.710 --> 00:41:12.210 William Cheng: But typically, you going to do something that is this animal, will you see a response. You can say, oh, this is them has responded 310 00:41:12.810 --> 00:41:16.410 William Cheng: Okay, so for example when you double click on the icon on your computer screen. 311 00:41:16.620 --> 00:41:21.990 William Cheng: And then you see something happen right when something happens is that, oh, that's the response. I mean, this isn't that isn't that very, very good response. 312 00:41:22.170 --> 00:41:28.560 William Cheng: Some people will say, Well, when I double click on something. I WANT TO SEE THE APPLICATION COMPLETED running. Then I call that to have a good good good good response. 313 00:41:29.160 --> 00:41:36.240 William Cheng: Okay, so therefore response time is actually very difficult to define. Because for different people, you know, they sort of feel the response that so so that's a different phenomena. 314 00:41:36.810 --> 00:41:44.490 William Cheng: Okay. So, therefore, you know, for interactive and real time application. So maybe we can actually talk about the response time and this can be very difficult to define. 315 00:41:45.240 --> 00:41:55.860 William Cheng: OK, so the default in this class, which is tried to stay away from a metrics such as response time. Okay. All right. Finally, fairness. Right. So does it also can be very difficult. 316 00:41:57.060 --> 00:42:08.940 William Cheng: But again, people have sort of tried to define fairness, as it turns off fairness is very difficult to define. I typically when people think about fairness. What are the thing about right. Is it fair to approximately aside equal proportion of the CPU to threats. 317 00:42:09.570 --> 00:42:18.450 William Cheng: Okay if I have 10 threads should every thread get one 10th of the CPU. Well, the answer is of course not. Because what if one user is using five threats. Well, in that case, that will be not fair. 318 00:42:19.680 --> 00:42:28.200 William Cheng: Okay, so therefore, how do you prevent the people who is running multiple multi threading to use the CPU in a fear of fashion compared to all the other users. 319 00:42:28.650 --> 00:42:43.020 William Cheng: Guys, when you guys get it fairness is really important to you. What kind of scheduler, would you run to guarantee that you had these fairness. Okay, so this way, people who run multi threaded you know processes will not have an advantage over single threaded processes. Yeah. 320 00:42:44.040 --> 00:42:49.920 William Cheng: Right scheduling is very important because its effect and how well a cheap all these goals. 321 00:42:50.160 --> 00:42:56.010 William Cheng: Can be felt by the user, right. So in the end, again, we'll talk about the user response to music and he says, Well, I'm using the system. 322 00:42:56.220 --> 00:43:06.780 William Cheng: I sort of feel that the system is a little bit slow sluggish. I don't know why, but if this one you know if this kind of feeding keep lasting longer and longer and longer. Eventually, the user is going to be coming patient and go to different audiences, so 323 00:43:07.770 --> 00:43:11.040 William Cheng: Okay. So, therefore, you know, all these before. I'm actually, you got to pay attention to it. 324 00:43:11.220 --> 00:43:20.220 William Cheng: There is no one scheduler that can optimize all the performance metrics. Right. So in the end, you know, a scheduling is actually a very complicated subject. Right. So this is why will you go on. 325 00:43:20.460 --> 00:43:29.490 William Cheng: On interview if they know that you have taken a operating system class you're going to get scheduled in questions. Okay. That's a guarantee. Okay. Because the very, very important topic. Yeah. 326 00:43:29.880 --> 00:43:37.200 William Cheng: Alright, so this is a good time to break so next lecture, we're going to continue to talk about scheduling, we're going to go through a bunch of different scheduling policies that