WEBVTT 1 00:00:02.100 --> 00:00:09.420 William Cheng: This is the third part of lecture 16 so and at the end. The second part. We talked about this very important picture. 2 00:00:10.349 --> 00:00:18.870 William Cheng: About how to perform reset on copy on right so when you a full copy HR process. You have to read. You have to reset for copy on write 3 00:00:19.410 --> 00:00:27.960 William Cheng: This means that you go to every memory segment. Find out which one of them is private, and for all the corresponding page, page table entry. You said the read only and 4 00:00:28.530 --> 00:00:33.060 William Cheng: You said the protection to read only. That's part of resetting your copy on write 5 00:00:33.540 --> 00:00:39.780 William Cheng: The second part over here is that we need to add an empty shadow object, okay, and also for these two processes, the parent and the child process. 6 00:00:40.200 --> 00:00:49.560 William Cheng: Anything below this, these two shadow consider frozen consider read only. So, from this point on, when you perform copy on write, you know, the new 7 00:00:50.010 --> 00:00:57.870 William Cheng: Paint Patreon that you get created. They will need to be referenced inside the chatter object. Okay, so, so later on when you tried to implement Colonel three 8 00:00:58.470 --> 00:01:03.600 William Cheng: You know, and, and that at some point need to implement shadow object, you have, you have to make sure that you follow all these rules right 9 00:01:04.230 --> 00:01:12.990 William Cheng: Right, so we're going to continue from here and we're going to, you know, the picture is going to get pretty clutter. So we're going to stop joining the page table and also the physical page. 10 00:01:13.290 --> 00:01:19.560 William Cheng: You know, because by looking at this, the rest of the picture we sort of see that when we reference to a page from x y AMP z. 11 00:01:19.950 --> 00:01:24.420 William Cheng: They are, you know, there's a corresponding page table entry and there's corresponding physical page. 12 00:01:24.750 --> 00:01:31.620 William Cheng: And the one that our original that are there. The one that the original page frame of the one at the bottom of this picture and all the middle one. 13 00:01:31.950 --> 00:01:41.100 William Cheng: You know there is a shadow object. They weren't originally copied on right but they have been modified. Okay, so this will will can keep track of a lot of these different version of the same page. Right. Yeah. 14 00:01:42.870 --> 00:01:52.110 William Cheng: Alright, so, so, so from the previous page to this page. We just got rid of all these things are with the page table and the physical page. So now that looks like this. We're going to continue without example. 15 00:01:52.620 --> 00:02:02.580 William Cheng: So, so, so, so we first, you know, we started out with, modify, you know, a process, a modified pay a page x and then a forks be I'm going to end up with the current state now. 16 00:02:03.180 --> 00:02:06.870 William Cheng: The next thing that we're going to do is that A is going to modify z and B's that I modify why 17 00:02:07.140 --> 00:02:14.910 William Cheng: That. So when a modified z. So, remember we just finished we said in for copy on write all the page table entry for these private memory segment. 18 00:02:15.330 --> 00:02:20.520 William Cheng: They are all they're all read only. Right. So when you try to modify a page or in this case, you're going to try and inside the 19 00:02:21.480 --> 00:02:26.640 William Cheng: trappings that operating system again for process. A, we need to walk down this list over here and we see that 20 00:02:27.060 --> 00:02:31.350 William Cheng: You know this memory segment is private, which means that we need to perform copy on write right so in this case. 21 00:02:31.560 --> 00:02:40.860 William Cheng: What we need to do that. So we need to ask the buddy system for new page. So the bus is going to give us talking about page. Oh, yeah. And then we need to perform copy over. So the question is, where do we copy from 22 00:02:41.340 --> 00:02:49.230 William Cheng: Okay, so in this example to see it seems pretty straightforward. The copy. There's only one copy of z. So, therefore, we need to copy the this one. So this one is going to be an Uzi 23 00:02:50.190 --> 00:02:54.810 William Cheng: Okay, but if the situation is a little more complicated. How do we actually find pink zebra. 24 00:02:55.230 --> 00:03:01.260 William Cheng: Okay. So on the right hand side over here, this is the algorithm that you have to implement in order for you to put one copy of like 25 00:03:01.620 --> 00:03:09.600 William Cheng: That when you try to find a patient to copy from you need to you need to follow this algorithm. Okay, so let's read this out with them, or is it to find a page to copy from 26 00:03:09.840 --> 00:03:16.950 William Cheng: You start with a process memory map and follow the chain of shadow objects. And I say, here's a memory map over here we find the memory. 27 00:03:17.220 --> 00:03:21.510 William Cheng: That we will find the memory segment because of the other page for virtual address that. 28 00:03:21.720 --> 00:03:31.770 William Cheng: And then inside this memory segment. In this example, we know we have three page. Right, right. We need to look for this one. So this one is paid z over here. So what we need to do is that we need to follow the chain of shadow objects. 29 00:03:32.490 --> 00:03:35.910 William Cheng: Okay. It's saying that the shadow object swarm a linked list. 30 00:03:36.570 --> 00:03:41.160 William Cheng: Okay. So, you look at the picture of us and why that's a tree data storage tonight. It's not a treat data structure. 31 00:03:41.370 --> 00:03:48.540 William Cheng: It's an inverted tree data shelter. If you have an inverted tree data center, you basically have a bunch of linguists, eventually they point to the same route at the bottom. 32 00:03:49.410 --> 00:03:55.770 William Cheng: Okay, so this case we're actually we're gonna have a have an Olympus. So again, if you look at this data structure over here, clearly it's a linguist right over here says 33 00:03:56.040 --> 00:04:03.000 William Cheng: Follow the linguist of you're trying to look for peace Ramsey. So what you do is that you start with his memory 17 over here, you follow this pointer. 34 00:04:03.360 --> 00:04:09.570 William Cheng: You ask the shadow. I go over here and say, Do you have paid Z. OK, so the shadow just says, I don't have it. So then you go to the next next guy. 35 00:04:09.780 --> 00:04:14.430 William Cheng: And that guy says, I don't have. So in this case, you go to the one in the India, you end up with a file object. 36 00:04:14.580 --> 00:04:19.110 William Cheng: And you say, Do you have paid z. This one says yes. Is he right. So that will be the one that you copy for him. 37 00:04:19.260 --> 00:04:26.730 William Cheng: So we're going to do is I'm going to copy this one, this one will be the new page z. And now we're going to make a reference here inside the shadow object, right, and then appointed as well. 38 00:04:27.240 --> 00:04:35.340 William Cheng: Because there's a better way. We have multiple shadow orders over here. Which one do we, you know, we were trying to we add this reference to patron z. 39 00:04:35.760 --> 00:04:48.930 William Cheng: Okay, we have to add it to the we have to add this that this reference to pay see at the top most shadow object. Why is that because as far as these two processes are concerned. Anything below this line. They are frozen. You're not allowed to modify them. 40 00:04:49.980 --> 00:04:57.720 William Cheng: Okay, so therefore over here when you try to modify something you have to modify the top one, the top one is empty. To start with, because we need to populate them with, you know, 41 00:04:58.590 --> 00:05:10.050 William Cheng: A patient that will that were originally copied all right but they have been modified. Right. So since we have reset for copyright and now this page Ramsay has been modified after we have reset for copyright. So therefore, the new reference over here. Go to the top. 42 00:05:11.880 --> 00:05:19.920 William Cheng: Left. So we do your kernel three, you have to implement this way, then what about be over here be modified. PAGE Why, over here. So again, you know, 43 00:05:20.520 --> 00:05:22.890 William Cheng: Process be we just reset for copy on right 44 00:05:23.340 --> 00:05:26.730 William Cheng: So right, it's going to be incompatible with read only. Right. So we trap. Is that a colonel. 45 00:05:26.910 --> 00:05:38.400 William Cheng: What on this list. Why identify that this is the memory segment. Now, where the page ball and then again, there's a three page frame X, Y, and Z. So what we need to do that again we need to run. We need to follow this algorithm to try to 585 PAGE Why, 46 00:05:38.790 --> 00:05:47.220 William Cheng: They would go to the shadow objects that you have page. Why the shut off this is I don't have it will go to the next shot on just that you have age wise and I don't have it. Finally, we'll find page. Why are we here at the 47 00:05:47.580 --> 00:05:57.240 William Cheng: Object at the bottom and then in this case, we asked the buddy system for four kilobytes of page frame copy this one over. So now this is the new page. Why, and then we reference this inside the shadow optic over here to point it out. 48 00:05:58.470 --> 00:06:09.180 William Cheng: Okay, so that's, I guess I'm not trying these pointers anymore. Right. So in this case, we're going to end up with this picture right so process. A over here, you know, the, the one that has one copy. All right. 49 00:06:09.600 --> 00:06:14.760 William Cheng: Page frenzy is sitting here and then this one for process be page. Why is sitting right here. 50 00:06:16.050 --> 00:06:20.730 William Cheng: So what you need to understand is that, you know, according to this picture. If you ask process. A for this memory segment. 51 00:06:20.910 --> 00:06:28.050 William Cheng: Where your page x y AMP Z. OK. So again, we need to follow exactly the same algorithm over here, right. So try to find all these objects that. So where's 52 00:06:28.350 --> 00:06:33.900 William Cheng: Your patient and so you can actually walk down this list over here, try to look for page for him and you will find out that x is actually right here. 53 00:06:34.560 --> 00:06:45.480 William Cheng: Okay. For process. A whereas a patient. Why so again you follow this algorithm over here. Is that why is over here before processing workspace Ramsey will see that you have to come over here. So process. A this is x y&z 54 00:06:46.440 --> 00:06:53.520 William Cheng: Okay, but what about the process be right. So again, for Busby you ask process be worse patron actually walked on this lady finance right here. 55 00:06:53.760 --> 00:07:03.390 William Cheng: You as process be workstation. Why you will find the right here. It has process be workspace Ramsey, you will find the right here so proper process be these three other page for Endpoints y&z 56 00:07:04.770 --> 00:07:17.730 William Cheng: OK. So again, if you go back to our on our example, you will see that these are the exactly the right three page frame for process. A for press person A and B, but now they're actually you know they that they actually use different page rapes, okay. 57 00:07:19.530 --> 00:07:30.960 William Cheng: All right, so, so, so, again, it's very important to understand. You see this picture. How do you buy all the page brain for a memory segment for one particular process. Okay. And this setup page rank can be very different from another process. 58 00:07:32.220 --> 00:07:40.590 William Cheng: All right. Let's continue our example, he's gonna afford to create process. See, right. So again, we know what to do. Well, we get it, we're going to create a process see over here. Make a copy of our 59 00:07:41.190 --> 00:07:51.090 William Cheng: address space. So that's VM at this VM area. So again, there's a segment over here to private and then this will point to the same one. Right. But again, in this case, we need to reset for copy. All right. 60 00:07:51.270 --> 00:07:57.720 William Cheng: Wonderful process, B and C. We need to go to the page table entry reset all the, you know, all spatial entry that are private 61 00:07:58.110 --> 00:08:05.370 William Cheng: To read only. Right. And we also need to insert a new shadow object. Right. So we need to add a new shiny object over here, a new shiny object over here. 62 00:08:05.610 --> 00:08:15.750 William Cheng: From this point on, process, B and C. Anything below this line. They are considered read only. And then only on the top of the call. Why don't we go can be modified. Okay, so we're done. It will look like this. 63 00:08:17.310 --> 00:08:25.800 William Cheng: Okay, so now we're going to continue our example, we get right so. So again, this picture is a little complicated, right, because, because before you know for a and b, this line below it and 64 00:08:26.550 --> 00:08:34.590 William Cheng: It's preserved for BSC it's below this line scrolls, as well as well. Any, any two pairs of any peers apparent process parent child process. 65 00:08:34.950 --> 00:08:42.120 William Cheng: There might be a different line, then you need to be john okay so that's why we need a complicated data structure because the situation over here is very complicated there. 66 00:08:42.540 --> 00:08:49.560 William Cheng: Alright, so he's going to modify page x over here, right. So he only has paid z that are rewrite all the other pages are read only. 67 00:08:49.680 --> 00:08:55.680 William Cheng: So again, I'm going to try things out of Colonel we find this memory segment over here. And then we need to look for our page XYZ Ajax. 68 00:08:55.890 --> 00:09:06.780 William Cheng: Page x is not here paychecks right here. So we asked the buddy system for new for four kilobytes over here. Copy page x over here and then make a reference inside the shadow again. So this one, it will point right here. 69 00:09:07.260 --> 00:09:12.420 William Cheng: Okay, so again, this one, this one is going to be different because this one has been modified this one, you know, 70 00:09:14.670 --> 00:09:17.460 William Cheng: We have made a read only. So, therefore, you can be modified that 71 00:09:18.090 --> 00:09:28.590 William Cheng: Process VO VO is going to modify page I'm X right be process be only patient. Why is rewrite all the other ones are read only. So again, going to try and inside the current over here, we need to look for our paychecks. 72 00:09:28.800 --> 00:09:32.220 William Cheng: Page x is not here pages is not here pages. This year we're going to ask the 73 00:09:32.460 --> 00:09:39.900 William Cheng: The buddy system for new four kilobytes over here and make a copy. So this is the new page x. And now we're going to refer to this page for a max over here inside of each other object. 74 00:09:40.350 --> 00:09:51.240 William Cheng: That processes got another page frenzy. A see just a little side I think I made a mistake over here process be we just finished doing a reset for copyright. So all the patient on Patreon. 75 00:09:51.570 --> 00:09:58.410 William Cheng: They're all we'd only right. Similarly for process. See also the same thing all the page frame over here are read only. So, therefore, you can try to write a page see 76 00:09:58.650 --> 00:10:02.610 William Cheng: You're going to try this out a kernel. And then we need to look for page z z is not here. 77 00:10:02.910 --> 00:10:11.790 William Cheng: He's not here he is not here, hazy is here. So we need to make a copy of or four kilobytes over here. So this is a new page Z. I'm going to refer that inside us to shut off it right here. 78 00:10:12.630 --> 00:10:16.500 William Cheng: Now, so when we're done. You know, it's going to look really messy. Now it's gonna look like this. 79 00:10:17.220 --> 00:10:28.260 William Cheng: Okay, so that if you ask process. A. Where's your x y AMP Z paste ran it will say my exes right here. Where's my wife right my wise right here. Am I see right here. So we're process. A. These are the XYZ 80 00:10:28.500 --> 00:10:34.200 William Cheng: For process be where the X y&z right. It says here, wise years these years of process be is right here. 81 00:10:34.680 --> 00:10:42.360 William Cheng: But process see where's X y&z right X is actually right here. Why is right here is, he's right here. So the approval process. See here x y&z 82 00:10:43.170 --> 00:10:52.320 William Cheng: OK. So again, if you don't implement this that this inverted tree data structure. There's no way for you to figure out, you know, where all these three page ramp. All of these processes. Okay. 83 00:10:52.920 --> 00:10:59.430 William Cheng: When you're working in a kernel three, one of the probing, you have to pass is called fork bomb. So basically the Robin is that it's going to 84 00:11:00.000 --> 00:11:08.910 William Cheng: You know, the parent process is going to forget Chopra says it's going to fork like crazy. I think that end up with 1000 processes over here. And then in that case, you still need to figure out how to do 85 00:11:09.210 --> 00:11:17.400 William Cheng: How to do a copy on write without this data structure, there's nowhere for you to do it correctly. Okay, so. So again, you know, you have to implement that. Yeah, that's pretty good data structure. 86 00:11:20.460 --> 00:11:21.840 William Cheng: The object at the bottom over here. 87 00:11:22.710 --> 00:11:31.140 William Cheng: We're not being very creative and call it the bottom object that so the bottom logic over here, even though, in the previous example. It's in the file object classes. Now, we now know that he renamed 88 00:11:31.410 --> 00:11:41.820 William Cheng: Inside a file object. There's a memory management object. So, so this this one over here at the bottom is the management men. Men memory management object inside the file object or it can also be anonymous object. 89 00:11:42.570 --> 00:11:51.330 William Cheng: Okay. And also remember that you know the the shuttle orders over here is also a memory management app. Yeah. So, India, we're going to end up with three different types of memory management objects. Yeah. 90 00:11:52.530 --> 00:11:59.610 William Cheng: So again, all these pointer over here appalling morphing pointer coming from the shadow objects over here. What can we point to right we can point to 91 00:12:00.180 --> 00:12:12.870 William Cheng: You know the memo BJ that's inside the the file object. If we next, we can also point to anonymous. I'll get right. And also, you know, the shadow Jeff and point to another shot object. So all these pointer over here. They're all polymorphous yeah 92 00:12:15.540 --> 00:12:23.550 William Cheng: This one, it's a slightly different example I had this one at the bottom. Over here, the object of the Bible doesn't have all three doesn't have all these three patron. Right. Why is that 93 00:12:24.750 --> 00:12:33.000 William Cheng: Well, because, you know, let's say they the bottom one over here is the one that's associated with the fall object. Right. So in this case, you only get two page spread of baseball one that pays frame x and y. 94 00:12:33.720 --> 00:12:37.050 William Cheng: Amp z. And that's why pay trim. Why has never be brought into memory. 95 00:12:37.470 --> 00:12:45.510 William Cheng: Okay, so the terminology that we're going to use in when he says that pace red X and Z. They are memory resident or page. Why are we here are not memory resident 96 00:12:45.870 --> 00:12:53.460 William Cheng: Okay, so later on we're going to get all these kind of pace falls over here, as it turns out our patients are on page x and z. So, in the end, we're gonna have all these other you know 97 00:12:53.760 --> 00:12:59.190 William Cheng: Patient will be here. There were originally copied all that. But they have been modified and there are kept track up by all the shadow objects. 98 00:12:59.730 --> 00:13:09.690 William Cheng: Okay, so, so, so in this example, your, what if you actually get a piece for on page one, right. So we have process. A, B, or C, when he tried to run their code and then it turns out that, you know, they try to access PAGE Why, 99 00:13:10.200 --> 00:13:15.960 William Cheng: So again, the entry is read only you tried means that often uses the and you come over here, you try to look for and you cannot find it. 100 00:13:16.710 --> 00:13:24.360 William Cheng: Okay. So in this case, what you have to do is that the object at the bottom, the bottom of your has the responsibility of creating a page frame that you're looking for. 101 00:13:24.930 --> 00:13:29.760 William Cheng: Okay, so, so, so again this memory, second one over here is supported by page friend x y AMP z. 102 00:13:30.720 --> 00:13:37.980 William Cheng: Okay, so, so the idea here is that the object at the bottom is responsible for creating X, Y, and Z. What about the shadow 103 00:13:38.430 --> 00:13:49.920 William Cheng: The shadow object or are used to kept track of the patient originally originally copied on right but have been modified. OK. So the one that originally copied all right. They all are managed by the bottom object. 104 00:13:51.000 --> 00:13:54.450 William Cheng: Okay so anytime. When you reach the bottom out there at the bottom, it says, I don't have it. Well, the 105 00:13:54.780 --> 00:14:03.540 William Cheng: Bottom line is that, can you create it for me and the other says, Yes, I can create it for you. Well, then, what it would do that real quick for you. And then if you need to perform copy on write at that point you make a copy and you ready 106 00:14:05.310 --> 00:14:09.930 William Cheng: Okay, so please remember the object of the bottom can create a patient that you're looking for. 107 00:14:10.260 --> 00:14:19.590 William Cheng: OK. So again, over here. This one is responsible for creating X y&z. What if you ask the bottom optical leaders they create Patreon for W for me one. In that case, they cannot do it. 108 00:14:19.860 --> 00:14:25.170 William Cheng: Right. So in this case going to end up with a segmentation fault and you kill you, that and you kill user process. Yeah. 109 00:14:26.790 --> 00:14:27.330 William Cheng: All right. 110 00:14:29.400 --> 00:14:34.110 William Cheng: Okay, so let's continue over here as a bunch of stuff with a great exit the lower left hand corner. 111 00:14:35.190 --> 00:14:39.120 William Cheng: Alright, so we're done with the shuttle debt, which is going to, sort of, you know, sort of summarize it. 112 00:14:39.690 --> 00:14:47.220 William Cheng: Why do we go through all the trouble is very, very complicated, right, because we want to implement copy. All right, together with for because we know that, you know, 113 00:14:47.550 --> 00:14:54.990 William Cheng: The 94 is terrible. The virtual for no problem also deal with that. So in the end, we have to implement copy on write together with four 114 00:14:55.230 --> 00:15:03.060 William Cheng: Okay. And we see that if we're doing this right away. It doesn't really work right there in the cases where it doesn't work. So therefore, we, in the end, we're going to end up with implemented object. 115 00:15:03.360 --> 00:15:13.320 William Cheng: That so easily shut object, you have all these pages rain. You need to understand that a variable, such as data, a few slides back can exist in many different physical page rain simultaneously. 116 00:15:13.920 --> 00:15:20.670 William Cheng: Okay. Each content, a different version of this variable, right. One of them says zero the launch of the 17th yellow says five it says one 117 00:15:20.880 --> 00:15:27.420 William Cheng: And also on that page rain. There are four. There's four kilobytes of data. So not just do that all the other variable and you must not changing already 118 00:15:28.410 --> 00:15:33.630 William Cheng: Okay, so, so to handle this big mess we have to we have to have shut off their web to implement all these complicated 119 00:15:34.170 --> 00:15:43.650 William Cheng: Algorithm that so to manage this mess when he was the idea of shadow object, what is the what is the idea, the idea is everything that I talked about shadow object you have implement all of them. 120 00:15:43.950 --> 00:15:50.040 William Cheng: Okay, we're going to organize a tree of shadow object using the inverted tree data structure where the root is at the bottom and 121 00:15:50.550 --> 00:15:54.300 William Cheng: You know, the bottom object can create all the patient that you want. 122 00:15:54.840 --> 00:16:03.570 William Cheng: That and then all the other ones are performing copy on write that we also need to implement the rule for finding peace rain or the physical pays that contain the global rambling question for you know for 123 00:16:03.930 --> 00:16:14.820 William Cheng: For for for particular process. I suggest starting with the so when you get to paste all your paper on the virtual address you walk down the list of VM area, find out which many segmented belongs to. And then in that memory segment. 124 00:16:15.210 --> 00:16:18.270 William Cheng: That's supported by multiple pages, right, you need to look for that page rain. 125 00:16:18.750 --> 00:16:28.350 William Cheng: Bye bye bye bye going down that link list of shadow objects. And do you get to the bottom. When you get to the bottom, while you live in case you get to the bottom line that case, the bottom object can create a patient for you. 126 00:16:30.780 --> 00:16:40.500 William Cheng: All right. Cheers turbocharger pointer to the inverted tree and then how to perform copied on right at the right time, how to set everything up. How do we sample copy on write you how to implement all these things exactly correct. 127 00:16:40.770 --> 00:16:47.370 William Cheng: Otherwise, you know, this is not going to work. Okay, so you have to implement what's described, you know, all these sites, you know, Carnival three. Okay. 128 00:16:49.110 --> 00:16:56.880 William Cheng: Alright, so let's talk a little bit about this memory management to read the job of the memory managed object is the is the managed piece rings. Right. So when we look at this 129 00:16:57.360 --> 00:17:04.050 William Cheng: Linguists of VM area over here. Each one of them implement a memory segment. Right. So some of the memories seven over here might be three pages law. 130 00:17:04.290 --> 00:17:15.330 William Cheng: So we're the Patreon right the pastries are managed by the memory management object. Okay, so, so now we know that because of copyright. We can actually have different copies of the patient with in different objects. Okay, so 131 00:17:15.810 --> 00:17:18.660 William Cheng: So, so this guy's got what kind of memory management update is that 132 00:17:19.080 --> 00:17:25.470 William Cheng: We have is our carnal assignment, as it turns out our kernels, I'ma has more memory management as well yet, but lots of them has been implemented for you. 133 00:17:25.890 --> 00:17:35.640 William Cheng: Okay, the one that you have to worry about are these three. Number one is that there's one that live inside the Beano so again in Colonel to you have seen this already. The end right arrow key and mo BJ. 134 00:17:35.880 --> 00:17:40.350 William Cheng: That's a memory management object that's the one that manage pace rain coming from the desk. 135 00:17:41.100 --> 00:17:48.420 William Cheng: Okay, you know. So over here, right, starting with the fallout. Yeah, the fall, I can point to a vino and he's been on those mmm will be j. So, from the vino. You can also 136 00:17:49.170 --> 00:17:54.600 William Cheng: Find a vino. You can also get back to the file object, right. So this way you know these object work together that 137 00:17:54.960 --> 00:18:05.010 William Cheng: The shuttle deck is also a memory management gag. And finally, the anonymous object over here is also a memory management object, right, the anonymous object doesn't type of the process. And so as an 138 00:18:05.700 --> 00:18:13.770 William Cheng: Object to create a suited to create a patient for you all. It has to do is to ask the buddy system for four kilobytes page rank and then what it will do is it is 139 00:18:14.340 --> 00:18:20.100 William Cheng: It was zero, the entire contents. It was 04 kilobytes, with all zeros and then in this case it will create a new patient 140 00:18:20.880 --> 00:18:31.500 William Cheng: Yeah, so, so, so, so it sort of, you know, these objects over here, they're different in the way that they created a train for the one that's instead of email he has to ask the the file object to go to the disk. And then, you know, 141 00:18:32.490 --> 00:18:40.380 William Cheng: And then be four kilobytes of data from a distant memory for the anonymous object, you can just create these objects out of thin air. Okay, because they are anonymous 142 00:18:42.030 --> 00:18:48.270 William Cheng: Alright, so we have this picture over here, I can actually see that you know we have shadow octaves everywhere. He's not because they are all privately map. 143 00:18:48.600 --> 00:18:57.810 William Cheng: You know men, we said that. What about the the the tech segment over here, right. So this one is read only. So in this case, if you stick a shadow object over here right right here. It's also work. 144 00:18:58.530 --> 00:19:00.990 William Cheng: Right, because it's read only. So you never perform copyright 145 00:19:01.950 --> 00:19:10.860 William Cheng: Guys, and this goes, we can actually also implement another shout out. Yeah. So, so some people like it this way to say now, everything looks the metric right coming out of the VM area. 146 00:19:11.070 --> 00:19:15.300 William Cheng: The first point to the shadow on deck. And then there's a link below chatter object that will lead you all the way to the bottom. 147 00:19:16.320 --> 00:19:26.070 William Cheng: Of that. So this work, you know, if this one is read only one of this one is we re share right so we always said, if the rewriting ship. Well, in that case, you are not allowed to have us out on that because in that case. Well, you try to write to it. 148 00:19:26.940 --> 00:19:31.500 William Cheng: You know, it might not work properly. Unless you there's a way for you to guarantee that I shudder object. 149 00:19:32.430 --> 00:19:40.950 William Cheng: So again, if you implement everything correctly, even if you have a shadow object, since we never reset for copying on. Right. So in that case, you know, again, the shadow should never get affected. 150 00:19:42.090 --> 00:19:48.300 William Cheng: Well as at the bottom line over here is either different ways, including your kernel. So whatever that works for you. It's a perfectly fine that 151 00:19:50.730 --> 00:19:54.480 William Cheng: Alright, so the idea is going to play a very important role. 152 00:19:54.810 --> 00:20:00.930 William Cheng: You know, because they are the one who managed peace train. Right. So one of the important thing that we talked about with us to find a patron, find a patient in front of pace. Right. 153 00:20:01.110 --> 00:20:10.560 William Cheng: So in order for you to find a patient, you have to use the memory management object in order for you to get to the memory management often you have to go through the VM area in order for you to get to the VM area, you have to go to the VM map. 154 00:20:11.610 --> 00:20:20.970 William Cheng: Okay, so that's how you supposed to think, how do you, how do you find stuff there. Alright, so, so, so, so in weenies so they actually have a sort of a complicated way to to 155 00:20:22.230 --> 00:20:26.940 William Cheng: To, to find out memory management object. I'm sorry to, to, to find the peace reign 156 00:20:27.870 --> 00:20:32.550 William Cheng: As it turns out that every patient. There are given a name, the way they need these pieces are pretty weird. 157 00:20:32.940 --> 00:20:38.700 William Cheng: Okay, so here's the notation to name a patient, right, and so, so you so you know what what they will do is it will put the page rank. 158 00:20:38.910 --> 00:20:47.160 William Cheng: We mentioned before, right, that there's a there's an active page Lizzie, Dr. Page less I made it sounds like a list, but we next they're actually implemented using a hash table. 159 00:20:48.180 --> 00:20:59.760 William Cheng: Okay, so when you start to look up stuffings at the highest level, you need a key for weeknights the way you look up a page frame object is to use a key and the key is a combination of two things. One is, which mmm will be generated this patient belong to 160 00:21:00.810 --> 00:21:08.520 William Cheng: Okay, so we saw before, right over here we have a Patreon Z were two of them, right. So, therefore, we tried to name them. We can't just say page R amp z, because in this case. 161 00:21:08.820 --> 00:21:15.810 William Cheng: Which one are we looking for. So we have to say, you know, which a memory management that belongs to. And also, what is the page number 162 00:21:16.650 --> 00:21:24.750 William Cheng: Okay, so then this page down over here. As I mentioned before, it's not the virtual patient number is not the physical page number but it's it's a very small array index. 163 00:21:25.110 --> 00:21:33.150 William Cheng: So in this example, if our bottom object over here is managed patient number 01 and two then in this case x will have the name of 164 00:21:33.690 --> 00:21:45.360 William Cheng: So, so, so, so, this guy's Yo, what will be this patient will be here right so the NLL BJ is because I've been in be so so this object. The name is going to be be comma zero, and this will refer the patient max. 165 00:21:46.110 --> 00:21:54.300 William Cheng: Yeah. What about patient. Why are we here are patient license official name is going to be be comma one. Okay, and paste Rainsy the official name over here with the comma to 166 00:21:55.170 --> 00:22:09.810 William Cheng: Okay, what about a set object over here either shut off over here and I caught up. So, therefore, this is going to be S comma 01 or two, right. So this one is coming copy from picture. Number two of us have it for the official name for this patient is gonna be so to 167 00:22:10.980 --> 00:22:11.280 William Cheng: Know, 168 00:22:12.570 --> 00:22:16.560 William Cheng: All right over here. So, to ask the question, where does the patient them actually come from. 169 00:22:17.790 --> 00:22:24.540 William Cheng: Okay. So yes, I call these ones Ilana to. Why do I call them 01 and two right guys. So one thing that you can do is that, you know, you can think about, you know, 170 00:22:24.750 --> 00:22:35.340 William Cheng: If this one is the fall object. The fall again. The purpose of the project is to serve the purpose of the purpose of the memory now people over here is to map a file into the address days. 171 00:22:36.210 --> 00:22:45.150 William Cheng: Okay, so definitely which had a map of find your addresses, we should map four kilobytes at a time. So we should lose that you just think about as far as a real pages as a here's my far right here that 172 00:22:45.330 --> 00:22:49.890 William Cheng: There are pages over here. Each one of them is four kilobytes. Right. Okay. So in this case, the 173 00:22:50.100 --> 00:23:00.330 William Cheng: You know the page number over here is the array index now. So if I met this one from the this into memory. So this one is not a page on zero. This one's going to copy paste on no matter what. And this one's called paste, I'm sure. 174 00:23:00.540 --> 00:23:06.030 William Cheng: And that's why all these pages. I'm over here. They are typical these small index because their index into 175 00:23:07.620 --> 00:23:10.020 William Cheng: Into the file that's been mapped into address space. 176 00:23:11.670 --> 00:23:23.220 William Cheng: Alright so so clearly, you know, if this object over here is associated with the file object then in this case the page number over here, what we refer to the page number inside the file that so the page is the array index into that file. 177 00:23:23.490 --> 00:23:34.110 William Cheng: Okay, but what about for anonymous object, the anonymous object doesn't really matter something for the fall into memory. So for the anonymous object over here. The beginning over here. As always equal to zero. And then the next one is one that likes to 178 00:23:34.470 --> 00:23:42.300 William Cheng: Go. So what are the 01 and two because there are contiguous, you know, in the virtual address. So that's why they are consecutive integers. 179 00:23:43.590 --> 00:23:56.400 William Cheng: Okay, so the, so, so, so, so again, when you think about what we tried to look up a page rain. You need both which M. O. B data belongs to. And also, which page number. You know what, what, what, what is the page number over here. Okay. 180 00:23:58.140 --> 00:24:08.460 William Cheng: All right, so this is my example right for the bottom of the deck over here at the bottom, much as name is be then this will be be comma zero become a become a two and then for the shout object over here, this will be asked to 181 00:24:08.970 --> 00:24:16.980 William Cheng: That alright so. So in this case, you know, you have these two keys. When you try to use the hashtag. Will you give these two keys to the hash function and the has want you will tell you what it is. 182 00:24:17.190 --> 00:24:29.910 William Cheng: And again, what you would do is that is that, you know, whenever you use, you know, use the hotspot unit, it will give you a bucket number and given the buggy number you can walk down the list of collision resolution chain and and again use the key and a value tried to look like to 183 00:24:30.990 --> 00:24:32.640 William Cheng: Try to look for an object that 184 00:24:33.810 --> 00:24:39.660 William Cheng: So again, I encourage you to have a Q. There's quite a few FAQ item, try to explain how this works. Yeah. 185 00:24:40.680 --> 00:24:52.770 William Cheng: Oh, here's a weird commerce, sometimes you know exactly the name of fish. Right, right. So over here, if I if I know I'm exactly looking for this one I can say, you know, so I can ask to close a gimme object as comma to 186 00:24:53.700 --> 00:24:57.090 William Cheng: OK, and then Robin is they use the hash function over here and you'll be able to find it. 187 00:24:57.330 --> 00:25:07.050 William Cheng: But sometimes you only know the page numbers, right. So again, when I get a paste all I tried to sort of figure out where to copy. You know what would have been copying right from. So in that case, I only have a page number 188 00:25:08.310 --> 00:25:17.010 William Cheng: OK. So again, when I try things out of current off because I'm doing copy on write up on those memories. I'm going over here. I'm going to go down this list. I'm going to ask for who has paid frame or why 189 00:25:17.730 --> 00:25:25.260 William Cheng: Okay, so, Nicholas. What should I do right, I go to the, the, the, the shiny object over here to say you have patient while Watson is this case over here, you know, the patient. 190 00:25:27.480 --> 00:25:39.330 William Cheng: The patient model we use page number one, right. So definitely this case I need to look for S comma one. So, I will send it to the Hash. Hash who said you have a common one, and the high symbols and this actually doesn't exist. 191 00:25:39.960 --> 00:25:43.110 William Cheng: Okay, so then what I will do that will follow this link list of 192 00:25:43.350 --> 00:25:50.340 William Cheng: You know, shout out live over here. Go all the way to the bottom of that will be here. So this guy's there's an object called be comma one over here. So I will ask the bottom. It has to say. 193 00:25:50.580 --> 00:25:58.350 William Cheng: Do you have pays for him. Why, and again, the way I will ask it is that is there such an object called be comma was and this guy is is they are here it is. You can actually use it right 194 00:25:58.530 --> 00:26:04.020 William Cheng: And if you want copy all right you as as somebody snip or four kilobytes. You make a copy, and you make references that child objects. 195 00:26:05.730 --> 00:26:15.810 William Cheng: Okay, so then you know there are times the only, not a peacetime. So in this case, you have to iterate through all the linguists of chatter object. And in this case, every in every step, you have to use the you know the the hash table. 196 00:26:16.140 --> 00:26:22.140 William Cheng: To look up a pretty large check to see if it exists or not right for the shadow object and they don't exist, you continue to go to the bottom. 197 00:26:22.440 --> 00:26:26.280 William Cheng: Okay. So you could either through you know through to follow the pointer over here on to go all the way to the bottom. 198 00:26:26.460 --> 00:26:33.930 William Cheng: When you get to the bottom of the bottom object doesn't you know the the object doesn't didn't exist. Well, there's no problem because the bottom. I didn't know how to create such an object. 199 00:26:34.620 --> 00:26:49.410 William Cheng: Okay. And once they are created, you'll be added to that to the table. From this point on, when you started look where you are you going to be able to that. So again, the different ways to use, you know, the you know the the are these keys to to to look up a Patreon. Okay. 200 00:26:51.450 --> 00:27:01.530 William Cheng: Oh, so we are done with copy the line work guys so, so there's one last topic will be here, the issues about backing store. And so again, you know, the pace rain. 201 00:27:01.860 --> 00:27:10.590 William Cheng: You know, if you decide need to swap out a piece grant it needs to go into the file system hierarchy or going to the soft space over here. So we're going to talk about how to implement the backing store now. 202 00:27:11.130 --> 00:27:12.540 William Cheng: So there are two kinds of backing. 203 00:27:13.440 --> 00:27:22.020 William Cheng: Into two types of memory segment. What is the share memory segment. The other one is the private memories that man. So for the shared memory segment the backing store is always going to be the file system. 204 00:27:22.470 --> 00:27:27.960 William Cheng: Now, so for example if you have a read only mapping on the file for the text admin. So in this case, we're doing sure mapping 205 00:27:28.170 --> 00:27:36.990 William Cheng: Now, since the page name is always identical to do the data on this. So in this case, when you decide to free up this patient, and you can just go ahead and free. You don't have to write the back to this. 206 00:27:37.290 --> 00:27:41.370 William Cheng: Okay, so this is super easy to do. Right. What about for sure mapping 207 00:27:41.700 --> 00:27:53.370 William Cheng: Okay, so if a if a file is doing sure mapping and this for rewrite. Well, in that case where you know what we trying to free up a PageRank. You need to write the patient out to the this into the share file. Okay. So in this case, when 208 00:27:53.970 --> 00:27:59.700 William Cheng: For another process. They're sharing the same they shouldn't be surprised that the data has changed. Okay, so definitely this case. 209 00:28:00.240 --> 00:28:06.480 William Cheng: The back in school. We, here is the buses of hierarchy, right inside of our system over here. So you study simply read the data, you know, back to the file. 210 00:28:06.930 --> 00:28:19.500 William Cheng: That. So the comment over here is as a week support this type of backing store and these that kind of back to the store are implemented by default object, right, and also the end and will be gay that's inside of vino that the the MO BJ that instead of vino and the vino is instead of 211 00:28:20.880 --> 00:28:29.880 William Cheng: Alright. So again, these guys over here. They know how to, you know how to write data to the back of the store and sometimes you don't have to write it off because the data is guaranteed to be the same. That's what sitting on the desk. 212 00:28:30.660 --> 00:28:36.870 William Cheng: But what about private mapping. Okay, so private mapping over here, then in that case we need the back end. So, okay. 213 00:28:37.230 --> 00:28:38.640 William Cheng: So as it turns out, there are two kinds of 214 00:28:38.940 --> 00:28:48.090 William Cheng: You know, a present mapping, one is the one is the one that like the data section over here. Right. Initially, the data actually come from the file. But as soon as we copy them into file. And now we need to put one copy. All right. 215 00:28:48.600 --> 00:28:57.270 William Cheng: Okay. So in this case, you know, if it turns out that once you perform copy on write and then we'll need to swap out that patient. The patient needs to go into the swatch race. 216 00:28:57.930 --> 00:29:09.000 William Cheng: Okay, so in this example over here we're going to use the anonymous object over here, right. So, so once you put one copy all right over here. Some of the patient will be will be managed by the anonymous object because it anonymous object knows how to manage the swap space. 217 00:29:09.660 --> 00:29:18.330 William Cheng: Okay, so this. So, this guy's got a pastry and we'll go into the saucer. So what are the spa space look black rice white space is a desk over here on the one side over here. We're gonna have to swap 218 00:29:20.040 --> 00:29:24.930 William Cheng: swap over here. Okay. The swamp space is simply that a real four kilobytes pages. 219 00:29:25.590 --> 00:29:30.900 William Cheng: Okay. So, therefore, if you decide to roll roll one piece right into the swap. All you have to remember is the re index. 220 00:29:31.290 --> 00:29:41.520 William Cheng: Okay. So this guy is going inside the anonymous. I think I said this particular face to face right now. They went into the spa space. And it's, you know, number one to seven or something like that. So in that case, you remember what it is. 221 00:29:41.820 --> 00:29:54.480 William Cheng: Okay, late, all you need to bring it back. All you need to do is to go to the spa space use this as a re index and then retrieve the four kilobytes block over here and they and they and they, in that case, you can fix up your space when 222 00:29:55.830 --> 00:30:03.330 William Cheng: I asked the other kind of our apartment is for anonymous mapping rise for the tech for for the heap segment and for the 223 00:30:03.900 --> 00:30:08.130 William Cheng: For the second segment. They don't come from the bosses them. So in this case, they're just created, you know, 224 00:30:08.610 --> 00:30:16.050 William Cheng: out of thin air. So in this case, in case you need to swap out the entire memory segment all those pages needs to go into the spa space, right. So again, 225 00:30:16.230 --> 00:30:22.410 William Cheng: The algorithm is exactly the same as the data segment over here using anonymous object to remember where they are, you can swap Mike and 226 00:30:23.460 --> 00:30:29.430 William Cheng: Then we as is a cloud operating system. It does not support this type of backing store. Okay, so 227 00:30:30.540 --> 00:30:34.500 William Cheng: So, so, so, so what what's, what's going to happen if the page. I'd even be satisfied with a job. 228 00:30:35.340 --> 00:30:38.310 William Cheng: Okay, so you got to make sure that doesn't happen. So you want to make sure that the page it 229 00:30:38.700 --> 00:30:56.700 William Cheng: Will only swap out, you know, the first two kinds of backing store, right, the one that has the facts that back things up inside of our system, we need does not implement a swap say so, therefore, there's no way for you to to to to to swap out the pace rain that privately, Matt. Okay, so good. 230 00:30:57.870 --> 00:30:59.370 William Cheng: So, so how does, how does winning I should 231 00:30:59.670 --> 00:31:08.310 William Cheng: Do so that I can guarantee that the page ADINA will never solve all those exact that so the solution turned out to be very simple. What you would do is that you will play hide and seek with the page demon 232 00:31:08.610 --> 00:31:15.960 William Cheng: Okay, we know what the patient even do it goes to the active patient list and look at all those patient and decide which one is recently used and which was not recently used 233 00:31:16.140 --> 00:31:22.650 William Cheng: So what we can do is that for all these pace rain that are used for private not be we just hide it away from the page list. 234 00:31:23.070 --> 00:31:29.670 William Cheng: Okay, what to put it all into a different list. So this way, the page. I've even can never find that the page. I didn't can apply to the data center will not be able to swap them out. 235 00:31:30.900 --> 00:31:42.390 William Cheng: Okay, so, so your current or three. The first part of what are you going to implement three function P friend get I talked about that already. And there's people in pen and paper and pen so paper and pen is to take the paper and paste. Right. 236 00:31:42.720 --> 00:31:46.590 William Cheng: Out of the occupation us and then put it inside a list of the p page document cannot find 237 00:31:47.280 --> 00:31:53.070 William Cheng: Okay, so this is called pitting a page, I take a page rank remove her from the list that the page I view men are will scan. 238 00:31:53.340 --> 00:31:59.940 William Cheng: And then moving to a different list by a pending or two different lists and now the page, it will not be able to find it. So, therefore, now this patient is say 239 00:32:00.660 --> 00:32:06.540 William Cheng: Okay. So whenever you create a page rain by the anonymous object, you have to pin it right so this way, the page, you know what, I'd be fine. 240 00:32:07.020 --> 00:32:16.530 William Cheng: There's another function up front on pen. Right. And it's the opposite operation at some point, you need to free up a centerpiece rent you need to take it from the hit list and then put it back to the regular patient list. 241 00:32:17.310 --> 00:32:24.540 William Cheng: Guys, okay, these two functions are pretty easy to implement it consists of one on link and then what a pen and then you're done. Right. Okay. 242 00:32:26.070 --> 00:32:37.800 William Cheng: Alright, so I was one more question over here is the how to not as a source page where I draw the disk over here. There's a swap says over here. I said it's fascinating to be divided into different pages. So when do you actually allocate a page. 243 00:32:39.090 --> 00:32:47.820 William Cheng: Look at a page inside of swap those again sometimes will say that I look at the page spring is that a swap right in this case the physical page again patient has go page, though, I mean the same thing that 244 00:32:48.360 --> 00:32:58.110 William Cheng: There are two different approaches. One is called. It was a radical and conservative approach based on ego evaluation. The other one is a radical liberal approach based on lazy evaluation. 245 00:32:58.860 --> 00:33:03.900 William Cheng: So eager evaluation is that every time you create a PageRank. You need to worry about what is this page, man. 246 00:33:04.800 --> 00:33:14.370 William Cheng: What if this patient needs to be swapped out. So therefore, I need to allocate, you know, a page inside of slack face. OK. So again, these are they also. So, so, so what does this happen. 247 00:33:15.270 --> 00:33:20.250 William Cheng: Okay, so this happen every time you create a Patreon, even for user space program where you call Malik. 248 00:33:20.460 --> 00:33:28.590 William Cheng: It is possible you create a page rain. So in this case, what I would do is I will allocate space inside the PageRank, just in case, just in case the patient needs to be swapped out so up that 249 00:33:29.160 --> 00:33:33.510 William Cheng: Okay, so the question over here. Is that what if, at this time, the swamp is out of space. 250 00:33:34.350 --> 00:33:41.160 William Cheng: Okay, I tried to allocate one four kilobytes patients at a swap and swapping out of space over here. So in this case, Malik will fail. 251 00:33:41.460 --> 00:33:50.310 William Cheng: Right. Because, because I'm doing either evaluation. I tried to be very conservative. So I'm required to allocate a page inside the swap and the beauty, if I can. I'll do that. That Malik will fail. 252 00:33:51.210 --> 00:33:59.310 William Cheng: Okay, so this is one reason Malika not your feel for no good reason. So some people write a small program that is sort of the cell running and they go, how can how can Malik return know 253 00:33:59.640 --> 00:34:07.800 William Cheng: You know, because you know I have plenty of memory. So, so one possibility that you have memory corruption, but the other possibility is that your, your entire system run out of swap 254 00:34:08.460 --> 00:34:21.090 William Cheng: Okay, so if you have processes inside you is our systems are very aggressive they use up a lot of pastry and they started using up the swap it is possible, where you even read a tiny program we call Malik Malik and actually fail because you run out of swap 255 00:34:22.080 --> 00:34:33.930 William Cheng: That. So in this case, is this okay okay some people that wanted that's not okay but but what you're supposed to do that when you call Malik, you have to check the return call it the return code is no need to tell the user to say, hey, I can I 256 00:34:34.590 --> 00:34:38.220 William Cheng: can allocate memory. So therefore, I need to self terminate that 257 00:34:39.000 --> 00:34:48.840 William Cheng: I need because if we run out of memory, what else can you do as a self terminate right now. The second approach over here. It's called it is based on lazy evaluation. So some people call this up to your audience. So sort of an 258 00:34:50.070 --> 00:35:01.530 William Cheng: Optimistic and management of the swaps days. So whatever we do is that whenever I create a new patient. I'm going to say that I'm gonna, you know, I'm going to hold that I'm going to be lucky that this patient will never get swap out to the desk. 259 00:35:02.640 --> 00:35:10.020 William Cheng: Okay, so what I would do. So when I create a patient. I don't need to allocate space inside a swap. So when do I have to allocate space in the space inside as well. 260 00:35:10.260 --> 00:35:18.330 William Cheng: Well, this is based on lazy evaluation, you gotta, you gotta wait until the last possible moment and then I'll have to go to the alligator. So what is the last possible woman. 261 00:35:18.690 --> 00:35:29.040 William Cheng: Is that what you're paying for. And what we're going to get swapped out to the desk, because at that time, I'm going to ask the, you know, as the swap today. Do you have four kilobytes. For me, if the spa spa space that's know what should I do 262 00:35:30.330 --> 00:35:39.750 William Cheng: Okay. So, at this time, I, I have to swap on this page ran onto into the South Bay and not a spa space. In this case, what, what should the colonel do the cardinal have to kill the program. 263 00:35:41.070 --> 00:35:44.340 William Cheng: Okay, so you know what this is a really bad idea, right, because in this case, you know, 264 00:35:44.670 --> 00:35:56.460 William Cheng: You know what I talk to swap out a pastry. If there's no space inside the swap. I don't have to kill the process. So now, a process can actually die for no other reason right you're running a perfectly good program for three or four days, all of a sudden your process dice. 265 00:35:57.420 --> 00:36:02.940 William Cheng: Okay, so we take the second approach over here. Again, it can be bad. Okay. But in this case, when something goes bad is going to be really bad. 266 00:36:03.420 --> 00:36:06.630 William Cheng: Okay, so why would people actually use this approach, right, because you know the 267 00:36:07.500 --> 00:36:17.970 William Cheng: Project has a good idea because I don't really want to allocate patients that have swapped because that will take time. So this way. I will run, you know, successfully most likely my process will finish doing whatever it's doing before I 268 00:36:18.300 --> 00:36:25.140 William Cheng: Before I process swapped out. So in this case, I can actually be very optimistic. Okay. But if you're unlucky, then something really, really bad can happen. 269 00:36:26.070 --> 00:36:35.430 William Cheng: Now, so there's system actually out there that will take the middle of the road approach. So I think window that she does that. So Robin is that, you know, when you call back you 270 00:36:36.570 --> 00:36:45.330 William Cheng: You, you, you, you end up creating a new page, right. So in this case, what we're gonna do is we're going to go to the swapped it we're going to reserve four kilobytes a PageRank inside as well. 271 00:36:45.810 --> 00:36:53.820 William Cheng: Okay, so we don't really allocate four kilobytes a Patreon will be a we're actually we're going to make. We're going to reserve for killed by a patient. And so what's the difference between making reservation. 272 00:36:54.090 --> 00:37:01.230 William Cheng: And then actually sort of, you know, sort of a competitor further coming to a particular page. Okay. It's almost like when you started rent a car. 273 00:37:01.650 --> 00:37:07.320 William Cheng: Okay, when you try to rent a car. What you would do is that you will reserve a car, but you don't really know what are you going to get when you get to 274 00:37:07.590 --> 00:37:11.880 William Cheng: The car rental place they will actually find out what cars there. And then what it will do is it will give you a car. 275 00:37:12.870 --> 00:37:24.000 William Cheng: Okay, so, so, so when we receive a call we only count the number of, you know, pages over here inside as well as long as we don't use up a limit. It doesn't really matter which patients are you going to get, because in the end all people are equal. 276 00:37:24.540 --> 00:37:27.090 William Cheng: Okay. So, therefore, you know, at the end when you actually try to 277 00:37:27.900 --> 00:37:30.150 William Cheng: Win. Well, will you will 278 00:37:30.420 --> 00:37:40.890 William Cheng: Your patient actually needs to be swapped out at that time. We're going to allocate a random page for having to give it to you right and that's what we know that that part. There's going to be space inside the swap because all the patient over there are 279 00:37:41.400 --> 00:37:42.990 William Cheng: Because you have already reserved a patient 280 00:37:44.040 --> 00:37:51.420 William Cheng: Okay. So guys, this is the middle of the road over here. So, so usually you know something actually worked best would be to make a compromise. Okay. 281 00:37:53.640 --> 00:38:02.250 William Cheng: All right, so I think we're done over here for chapter seven. So now we actually want to go back to chapter six, Chapter six we finished the 282 00:38:02.640 --> 00:38:10.440 William Cheng: First part and we're going to go to the second part over here to look at performance enhancement, we mentioned before, the, you know, 283 00:38:10.980 --> 00:38:20.700 William Cheng: The, you know, the business really, really slow. Right. We talked about this one I mentioned about the smallest addressable unit on the disk. It's a sector and the way you name a sector is by specifying 284 00:38:21.120 --> 00:38:26.850 William Cheng: The head or the surface number followed by the cylinder or the track number and then followed by the sector number within this 285 00:38:27.960 --> 00:38:36.390 William Cheng: Within that within that particular track that. And also, you know, since you know the address address is that this way when you try to access the desk over here. 286 00:38:36.810 --> 00:38:44.430 William Cheng: You need to wait for with with the sea, time to move to this head to the right track. And then we need to wait for rotational agency, you know, which is 287 00:38:45.660 --> 00:38:54.060 William Cheng: You know, we're just waiting for this to spin until the separate you're looking for, you know, come under this head. Right. And the last part over here is called the data transfer time 288 00:38:54.300 --> 00:38:59.130 William Cheng: That the data transfer time is the amount of time for that data to go from go from the desk. 289 00:38:59.610 --> 00:39:09.930 William Cheng: You know, so, so, so once you're once it is head is right on top of the sector, we had the first bit and then a data transfer times the amount of time that it takes for the for the entire sector to get transferred inside of this buffer. 290 00:39:10.470 --> 00:39:24.900 William Cheng: That so your total access times and these are the these three things are in there are two separate. So you just add them all up. That will be your entire access that. So what's important to understand is that the seat time of the rotational latency over here they are. They 291 00:39:26.340 --> 00:39:31.470 William Cheng: They are unpredictable that Dana transit time over here is pretty typical typically a fixed number 292 00:39:32.370 --> 00:39:38.370 William Cheng: Okay, so when you buy a new hard drive. I typically what the harddrive will also tell you what is the maximum transfer capacity. 293 00:39:38.730 --> 00:39:42.090 William Cheng: So forth. So the purpose for the rest of the topics that we are 294 00:39:42.450 --> 00:39:49.800 William Cheng: When I talk about transfer POTUS capacity. I'm not talking about the storage capacity of the day as the storage capacity. How many gigabytes that he can actually store. 295 00:39:50.040 --> 00:39:54.750 William Cheng: The transfer capacity is how many bytes per second that he can actually transfer for the disk into memory. 296 00:39:55.740 --> 00:40:02.400 William Cheng: That. So when you buy it. This if you if you flip the discover there's always tell you tell you what is the maximum transfer capacity for that this 297 00:40:02.940 --> 00:40:12.180 William Cheng: So that number you get is by assuming that C calm is equal to zero and rotational latency over here, equal to zero. So, the maximum transfer capacity is basically one over the data transfer. 298 00:40:12.900 --> 00:40:18.450 William Cheng: OK, so the foster dinner starts with times faster than that other than the maximum transfer capacity. Right. 299 00:40:19.560 --> 00:40:24.750 William Cheng: So last time, you know, I guess that will be working in chapter six. We also show you this table up on textbook. 300 00:40:25.140 --> 00:40:30.420 William Cheng: The show you that there are different kinds of seat time because they're different motors that on the disk arm and 301 00:40:30.840 --> 00:40:43.290 William Cheng: Etc. As it turns out, one of them is actually a key to improve the performance of getting data on the desk. Okay, so, so, so I get. Today we're going to give you some background material in the next lecture, we're going to see how how that information can be used. 302 00:40:45.030 --> 00:40:47.910 William Cheng: Alright, so the rhino appeals maximum transfer capacity. So again, 303 00:40:48.570 --> 00:40:56.370 William Cheng: The transport speed on terms of capacity is one over the data transfer. Time for a sector that. So, so far, no. Do I know the hard drive is 64 304 00:40:56.580 --> 00:41:02.970 William Cheng: Megabytes well maybe megabytes per second. But as it turns out, if you put a system five losses. I'm on the rhino be a hard drive. 305 00:41:03.180 --> 00:41:17.040 William Cheng: And you measure the performance of system for versus them on the average, you're going to see that the, the, the, the effective transfer speed of this is going to be 124 121 or 2.4 kilobytes per second. Not megabytes per second. 306 00:41:17.850 --> 00:41:24.150 William Cheng: Okay, so this is zero, this is 0.16% of the maximum and transfer capacity. 307 00:41:24.510 --> 00:41:38.010 William Cheng: Okay, now 16% 0.16% or the transfer capacity. Right. So what it means is that you just you just paid gazillion dollars for this right. Nope, your hard drive and the end the overall throughput, they can get out of this is only 0.16% 308 00:41:38.670 --> 00:41:49.770 William Cheng: Okay, so definitely gonna be very upset because you know the write up your hard drive. They're very reliable very high speeds very expensive. But in the end, the most you can get out of the transfer capacity, it's less than 1% okay 309 00:41:51.300 --> 00:41:56.700 William Cheng: All right, so we're going to talk about is the how to actually improve the performance on a disk drive like that night. 310 00:41:57.090 --> 00:42:03.090 William Cheng: So, so, so, so we're going to sort of take a look at different approaches. One thing that you can do is I can use hallway. 311 00:42:03.450 --> 00:42:14.820 William Cheng: So on the disk controller with he is a pre fetch buffer. So again on this control. This is this control over here, I will put a precise buffer. So before we only have a buffer that can actually a copy one sector of data from a distant memory. 312 00:42:15.060 --> 00:42:22.830 William Cheng: What if we use a large buffer over here. So when you know so we try to copy data from the desk over here instead of only copying. One second. We're going to copy multiple sectors. 313 00:42:23.700 --> 00:42:27.150 William Cheng: That someone was like this over here is going to come inside a prefix buffer over here. 314 00:42:27.480 --> 00:42:34.140 William Cheng: Okay. As it turns out, when we do something like this will speed things up by a little bit, but it's not it's not very, very much. Right. So, so 315 00:42:34.440 --> 00:42:45.060 William Cheng: And the reason for that is that, you know, when we transfer data will the data are organized into sectors upon one sector to another sector, you know, they, you know, they might be a completely different place on the desk. 316 00:42:45.990 --> 00:42:53.580 William Cheng: Okay, we saw before. And this isn't PA system inside the I know there's at this map that this man appointed to the this blog that this block because of 317 00:42:54.090 --> 00:42:57.330 William Cheng: The way we allocate this block this ball can be scattered all over the desk. 318 00:42:57.480 --> 00:43:06.660 William Cheng: So, therefore, you know, you can actually speed things up a little bit and then pretty soon. You got it. Again, we tend to get the next block of data you need to pay for a seat time you need to pay for a little additional latency. 319 00:43:06.840 --> 00:43:09.750 William Cheng: And the your performance is going to get killed by by by seeking 320 00:43:11.550 --> 00:43:21.360 William Cheng: Waiting for the desk that says, as it turns out you know the the way to actually improve performance is to come up with a better operating system. Right, so he's got the opportunity to send the file system will make a big difference. 321 00:43:21.870 --> 00:43:28.200 William Cheng: So in the end, we're going to end up with a better own this data structure, right, because the file system mentioned that autism is two things. 322 00:43:28.380 --> 00:43:33.630 William Cheng: One is how you may all data on the desk. So as it turns out that the way you did it on the, this may make a big difference. 323 00:43:34.020 --> 00:43:41.910 William Cheng: And also the other part over here is that you know you need to write code as as a bit on this guy's a better file system over here is going to improve the performance overnight. Right. 324 00:43:42.840 --> 00:43:46.830 William Cheng: Now, so here are some of the tricks that we're going to see you can increase the block size. 325 00:43:47.250 --> 00:43:54.630 William Cheng: Okay, so, so again we increase the block size when you try to access the file instead of, you know, so let's have the block size over here is going to be A times the previous block size. 326 00:43:54.930 --> 00:43:59.820 William Cheng: So in this case, instead of going to a different random places on the desk. Now they're going to be continuous. 327 00:44:00.270 --> 00:44:07.980 William Cheng: Continuous on the physical here. So in this case, you can actually use the power prefect buffer to improve one. Okay. So that would be one trick. 328 00:44:08.670 --> 00:44:14.040 William Cheng: We also going to see technique will minimize them to see time and minimizing and to rotate to we just an occasional latency. 329 00:44:14.670 --> 00:44:24.840 William Cheng: That so that we want to see. Time to go to zero, we have to we wanted rotational energy to go to zero. So, this way we can achieve near 100% of the disk transport capacity as the question is how we're going to do that. 330 00:44:26.520 --> 00:44:35.160 William Cheng: Alright, so the next improvement over the system. Our system is known as the fastball system for obvious reason they call the fastest isn't because it's much faster than this is the process then 331 00:44:36.060 --> 00:44:44.310 William Cheng: You know, so, so, so, so, so one, one thing that they do is that you know what we just talked about. They're going to sort of organize the data differently on to the desk to improve the performance 332 00:44:44.760 --> 00:44:49.080 William Cheng: They also add other functionality. For example, you know, this is above us then. 333 00:44:49.950 --> 00:44:56.940 William Cheng: You know, this is my bosses, then it's kind of like the ramp also sent. Okay, so you you actually you have seen the code already in Colonel to net 334 00:44:57.420 --> 00:45:00.540 William Cheng: So, so in that case you see that every directory entries over here. 335 00:45:01.020 --> 00:45:10.770 William Cheng: How big is it directly or indirectly or directly. I just 32 bites law that four bytes of them is I know number and the other third the other 28 bytes over here. It's going to be a see string that has the component name. 336 00:45:11.250 --> 00:45:18.510 William Cheng: Okay. So in the end, need to terminate with back to zero. So, therefore, the longest component name instead of directory can only be 27 characters. 337 00:45:18.930 --> 00:45:23.460 William Cheng: Okay, so that's a limitation, because some people want to name their, their component as long as they want. 338 00:45:23.910 --> 00:45:28.650 William Cheng: Okay, so the question is, can you implement a file system where the component and can be anything that you want. 339 00:45:29.460 --> 00:45:35.520 William Cheng: Okay, so in the past. So then they tried to do that. So that's one of the thing they do, they have lost their supporting local component and the directory that 340 00:45:36.090 --> 00:45:43.500 William Cheng: In the first assist them as it turns out, they also contain the same data structure for the I notes, you know, in the system officer would use this map. 341 00:45:44.070 --> 00:45:52.770 William Cheng: Okay, so remember that this map. The first 10 point or direct this pointer and the next one is indirect and then followed by a web platform. He pointed direct. So as it turns out that, you know, 342 00:45:53.400 --> 00:46:02.730 William Cheng: You know, whenever you you need to perform random access you know the the operations, the number of disco that this blog, you can we change is going to be a one to one and otherwise, pretty good. 343 00:46:03.240 --> 00:46:10.800 William Cheng: Okay, so definitely at the time when it is not as fast. I'll system. This order was pretty good. So therefore, they're going to keep this map of this is the system now. 344 00:46:12.000 --> 00:46:22.770 William Cheng: So now I'm synchronized with the again the summer 2019 lectures. So, so I'm going to stop right here. So next time I'll let you 17 we're going to continue to talk about chapter six. Okay.