WEBVTT 1 00:00:02.520 --> 00:00:14.070 William Cheng: Okay, so this is the second part of lecture 23 in the first part, we talked about a copy on write and fork and one of the last thing that we talked about is the reset for copy on right 2 00:00:14.849 --> 00:00:25.830 William Cheng: So when you fork. You need to go to all the memory segment that are private and then go to all the corresponding paste headway and tree reset, you know, everything from rewrite to read only. 3 00:00:26.340 --> 00:00:36.990 William Cheng: So this way you know fork can work work well of the copy on write. Then the last problem that we mentioned over here is that there are too many of the same page, you know, a good example. I have 4 00:00:37.410 --> 00:00:41.640 William Cheng: There are two up there for page Z's over here, this picture only show too. 5 00:00:42.150 --> 00:00:49.980 William Cheng: Blessed to do you know a copy on write you going to end up with a lot of hazy and we can really trust the entries that page table because the page table entry can be on that. 6 00:00:50.310 --> 00:00:56.820 William Cheng: They can be set to zero you know the the VM is that the zero for all kinds of reason. So, therefore, you know, we sort of need to 7 00:00:57.540 --> 00:01:08.400 William Cheng: Be able to figure out where to copy from using the colonel data structure. So again, I'll go with us memory map in order for you to figure out where to copy the data from even though the page, though, even though the page. 8 00:01:09.030 --> 00:01:18.720 William Cheng: Even though the pace a book can be completely invalid guy was still know where to copy from yeah alright so this required to work require us to introduce new kind of object is that a colonel. 9 00:01:19.290 --> 00:01:23.190 William Cheng: So this is called a shadow object, the shadow object is one level indirection. 10 00:01:23.670 --> 00:01:32.400 William Cheng: So the picture over here sort of tried to sort of show you what's going on. So again, inside one process. There's your address space representation which is a linear list of VM area. 11 00:01:32.730 --> 00:01:37.890 William Cheng: The VM area before we have a point to the file object we have a point to the anonymous object. 12 00:01:38.610 --> 00:01:47.940 William Cheng: That. So now what we're gonna do is we're gonna we're going to introduce one level indirection. We're going to add a shadow object beef between the VM area and the file object and the anonymous object. 13 00:01:48.660 --> 00:01:54.810 William Cheng: OK. So again, this is one level interaction. So again, again, we see this many, many times was one leveling direction they give us a lot of flexibility. 14 00:01:54.990 --> 00:02:00.840 William Cheng: So in this case, we need to we can use that to sort of sort of figure out where to copy from in case you have to perform copy. All right. 15 00:02:01.140 --> 00:02:09.360 William Cheng: Okay, so let's read through some of the others. Very, very important slide sort of tell you what you know what shadow objects. Yeah. So, so this new object over here that's empty. 16 00:02:09.810 --> 00:02:18.330 William Cheng: It's shut off. So why is it empty. Right, because this is the one that's going to keep track of the copy of z, whereas over here, we saw before, you know, at the the file object. 17 00:02:18.780 --> 00:02:26.640 William Cheng: I guess the example that keep using right you have a memory Segway that's that's 10 kilobytes law we need three different pace RAM and these are the two provisions called x y AMP z. 18 00:02:27.150 --> 00:02:32.940 William Cheng: Okay. So in this case, you know, when we need to perform copy or I have z, you know, we make a copy. And where do we 19 00:02:33.420 --> 00:02:38.850 William Cheng: Keep track of the copy, while the answer. Over here is that we keep track of the copy of Z inside a shadow object. 20 00:02:39.450 --> 00:02:42.750 William Cheng: Okay, alright. So, again, we'll talk about a lot of details over here. 21 00:02:43.140 --> 00:02:46.980 William Cheng: So it's just shut object is introduced one level in direction we're going to keep track of pages. 22 00:02:47.220 --> 00:03:01.470 William Cheng: That were originally copy on write but have been modified right so so I started out with a z over here page z is inside of object over here. So, so the data instead of file object will be the exactly the same but you know it will be exactly the same as what's on the 23 00:03:02.820 --> 00:03:03.570 William Cheng: What's on desk. 24 00:03:03.900 --> 00:03:09.000 William Cheng: Okay, but when you perform copy on write for the first time we're going to make a copy. Right. Once we make a copy 25 00:03:09.150 --> 00:03:17.190 William Cheng: We need to have some object to keep track with this copy, while the shadow object over here will keep track of the copy of z. So, again, what's going to be the difference between the Z and the other see 26 00:03:17.430 --> 00:03:21.600 William Cheng: What the z at the bottom over here is going to be clean the z will be exactly the same. 27 00:03:23.310 --> 00:03:30.300 William Cheng: As what's in the desk and the, the one that's that's over here. There are there are managed by the better shut object. This one will be modified. 28 00:03:31.140 --> 00:03:39.900 William Cheng: Okay, so therefore this page. This page D initially will be the initial they're exactly the same but we put where we perform copy. All right, you end up modifying 29 00:03:40.140 --> 00:03:47.610 William Cheng: This page. So there's going to be one memory location, there'll be different, but also from this point on all the new modifications, they will all go to the Go, go to this page is he 30 00:03:48.420 --> 00:03:55.200 William Cheng: Okay, so they have a pretty soon. This page. The and this page, it will it will be completely different. Okay. So initially, they're the same. But once you you know 31 00:03:55.800 --> 00:04:05.790 William Cheng: Proven copy on write there'll be different and depth on this point on it would become more and more different. Yeah, so, so, so any of the modified page here I'm over here. We're going to keep track of, you know, any, any of the patient that has been modified 32 00:04:06.090 --> 00:04:10.770 William Cheng: Do to copy on write. We're going to keep track of them inside the shadow object, okay. 33 00:04:11.490 --> 00:04:22.410 William Cheng: Alright, so a page and a memory map, you know, into which an object was my private. Right. So again, this one has to be my private otherwise we're not doing any other object, okay. Only when it's private. And it was only when it's rewrite, then we're doing 34 00:04:22.920 --> 00:04:29.610 William Cheng: With each other object. Okay, so, so a page and memory map into which and if it was my private has an associated shout object. 35 00:04:29.820 --> 00:04:36.870 William Cheng: Okay, so the first point here that points out of here is no longer anonymous object is no longer the fall object. But instead, it has to be a shadow object. 36 00:04:37.080 --> 00:04:49.050 William Cheng: Okay, so if a page is managed by the shadow object that means that this page has been modified right otherwise the page is managed by the original object which is, you know, the Fall object or anonymous object. So in that case that page has not been modified 37 00:04:49.800 --> 00:04:59.400 William Cheng: Now alright so XYZ on the right. Right hand side over here. Again, they are page for him. And there's a one to one correspondence between patient my physical pages. So again, you know, sometimes we use x, y AMP z. 38 00:04:59.760 --> 00:05:09.930 William Cheng: To refer the patient. We also can do XYZ to refer to do to to refer to a physical pages. We can also use x, y, and z to refer to those page table entry that there are mapped 39 00:05:10.500 --> 00:05:15.960 William Cheng: The virtual address the physical address. Okay, so we're going to use XYZ. You know that different places. So again, it depends on the context. 40 00:05:16.440 --> 00:05:21.000 William Cheng: You need to sort of figure out exactly what x, y, z as but again they they all were referred to the same thing. 41 00:05:21.810 --> 00:05:34.890 William Cheng: Right, so, so, so the, the important thing about a shout out things that the shutter object tells you where to copy from well you need to perform copy on. Right, right. So, so when I when I ended up on copyright. I have one z over here, another one at the bottom over here. Where do I copy from 42 00:05:36.390 --> 00:05:45.570 William Cheng: Okay, so, so, so, so, so again, right. So, so if you look at this picture over here. Now, if I have a PC over here inside the shadow object. This one will be the newer page z. 43 00:05:46.200 --> 00:05:50.700 William Cheng: Right, because we started out with this page, do we perform copy on write we've made a copy will kitties that a shot object. 44 00:05:50.820 --> 00:05:59.520 William Cheng: So, so this one is NEWER COMPUTER, the one at the bottom right, so they will next time, next time you know whenever we need to publish out object. Maybe we need to fork. Another time will reset for copyright 45 00:05:59.730 --> 00:06:05.340 William Cheng: And then we need to copy again. Well, this will be the newer version of z. So, therefore, we need a copy from this and not from this 46 00:06:06.270 --> 00:06:16.260 William Cheng: Okay, so what I'm going to talk about an algorithm. What do you have to do in case you get a page fall you to perform copyright. Where do you copy from guys, we're going to see a bunch of examples how to use the shutter object. Yeah. 47 00:06:17.940 --> 00:06:30.450 William Cheng: Alright, so now you know so. So the pitch as a chain right originally web. Web the I'll get this is a linear listed as region or BM area here. Again, this one is what text. This one is for you know data plus BSS this one. So he 48 00:06:30.930 --> 00:06:36.870 William Cheng: This is what and memory map file. And this one is for the stack, right, we say that you know these things point to the file object. 49 00:06:37.230 --> 00:06:41.550 William Cheng: The memory map off upon a file object and then you know this one point anonymous. This one upon to anonymous 50 00:06:41.760 --> 00:06:50.280 William Cheng: Now we need to be careful, right, because you know if anything that's my private. Now we have to use shadow object. So this one is private, so therefore we have to insert a shout object right here. 51 00:06:50.490 --> 00:06:57.630 William Cheng: This one is primarily to insert a shout out to go here. This one is probably the answer shut off, take out here and this one is private, we need to insert a shout out here. 52 00:06:58.590 --> 00:07:10.320 William Cheng: Okay, so look at the rule is that if you have you have a privately map memory segment. The first object and it points to has to be a shadow object. Yeah, there's want to share. So therefore, the component directly to the body. Yeah. 53 00:07:11.340 --> 00:07:21.450 William Cheng: Alright, so now we have, you know, and then now you know what we have to start with the following right so they're all the shadow objects over here and also 54 00:07:21.930 --> 00:07:30.450 William Cheng: You know, since we are doing, you know, we next I want to send emissions and, you know, something like that, you know, I mean, if you look at this picture, all these pointers over here. 55 00:07:30.810 --> 00:07:43.050 William Cheng: They all point to different kinds of objects, right. So, you know, so. So again, this is the polymorphous pointer, it can point to shadow a component anonymous object. So the, the pointer over here doesn't really point to a file object. 56 00:07:44.250 --> 00:07:49.020 William Cheng: OK, so I guess in, you know, previously was sort of saying it pointed a file object and conceptually, they're the same. 57 00:07:49.500 --> 00:07:56.910 William Cheng: But now you know if you have been, you know, working Colonel to right you see that inside the vino there's an object called the M AMP LBJ object. 58 00:07:57.600 --> 00:08:10.410 William Cheng: Okay, the emoji OBG object, they are the one that performed memory management operations. What does memory management or memory management operation, you know, in winnings means that they managed page frames. 59 00:08:11.760 --> 00:08:19.080 William Cheng: Or so, so, so now you know exactly who's managing the page rank anything that's a demo BJ a memory management object, they are the one that managed space rain. 60 00:08:19.290 --> 00:08:27.750 William Cheng: And inside the file object either the vino inside the vino there's the LBJ so so over here instead of pointing to the file object I should pointed to a memory management object. 61 00:08:28.440 --> 00:08:32.610 William Cheng: Okay, so there are three types of memory management, I'll get right one is the one that live inside to be know 62 00:08:32.730 --> 00:08:43.590 William Cheng: And also a shadow objects and memory management object and also anonymous object is also a memory management object, right. So that's why this point, Joe, can point to all these three kinds of object because they're all the same kind of object. 63 00:08:44.220 --> 00:08:54.300 William Cheng: Whereas, again, if you think about C plus plus the mmm LBJ will be a base class and then you know you know all these three other kinds of movies. Yeah, they're all self classes of the base class. But again, since we're doing, you know, 64 00:08:54.780 --> 00:09:01.020 William Cheng: We're doing these things and see we have an array of function pointers or this way you can actually implement this polymorphous yeah 65 00:09:01.770 --> 00:09:10.740 William Cheng: All right. Alright, so, so again, you're starting from the Texas area over here. We're going to point to the movie, Jeremy. Again, this picture show you that it's inside of fall object. But remember, instead of fall off. Jane, there's a vino 66 00:09:11.040 --> 00:09:14.250 William Cheng: vino there's mm LBJ, right. So again, there's many level of indirection. 67 00:09:14.700 --> 00:09:20.400 William Cheng: Hopefully the weeknights Colonel did it for good reason. Right. Again, they wrote the code. I don't know why they do that. But, you know, hopefully they have a good reason. 68 00:09:21.090 --> 00:09:28.680 William Cheng: This point I'll be appointed shadow jag and a shout out data over here has to point to another mmm LBJ so this case they will pointed mmm LBJ inside to be known. 69 00:09:29.310 --> 00:09:35.280 William Cheng: For the hip area, they are privately map so they point to a shadow object and a shout out to go be here will point to anonymous object. 70 00:09:35.460 --> 00:09:39.630 William Cheng: Again, this one is anonymous because there's no file system path. Similarly, for the stack. 71 00:09:39.840 --> 00:09:47.670 William Cheng: You know, coming out of the VM area over here, they will point to the shadow get going to shut off to a point on on this object. And if you use a memory map file, man. Again, the different way to map memory. 72 00:09:48.390 --> 00:09:55.320 William Cheng: Map things into into your memory into memory segment our example is to map a file into our memory segments. So therefore, in this case. 73 00:09:55.680 --> 00:10:05.400 William Cheng: The shadow article pointed the mo mo BJ that's live inside of vino which live inside of our guys, again, you know, so, so, so this is so, so for your kernel of programming assignments things is going to look like this. 74 00:10:06.570 --> 00:10:09.870 William Cheng: Okay, so, so again, when users are worried about mm LBJ a little later. So again, 75 00:10:10.110 --> 00:10:20.040 William Cheng: There are three kinds of me. What we do you have to worry about. I mean inside of Windows kernel. They're actually other kind of internal BJ. Some of them. You don't have to worry about that okay Bobby Colonel three got to worry about these three types of projects. Yeah. 76 00:10:21.570 --> 00:10:30.360 William Cheng: All right, so, so again we're going to put all this picture I again whenever you see the thing about pasta is the address space implementations that there's a linear list of VM area. 77 00:10:30.900 --> 00:10:37.170 William Cheng: And the if the VM area is sure then you don't point to shut off jack if it turns out that it was private any points or shout object. 78 00:10:37.560 --> 00:10:45.120 William Cheng: That alright so let's take a look at, you know, how do you actually implement, you know, a fork. When you have a memory segment that's shared 79 00:10:45.660 --> 00:10:52.110 William Cheng: Well guys will get every memories document can be different. Right, we're only going to look at one that's shared the only one that we saw before, the one that's shared 80 00:10:52.560 --> 00:10:57.480 William Cheng: I guess which one is shared over here. Okay, so it's the shared one over here is the tech segment. So in this case, 81 00:10:58.050 --> 00:11:06.030 William Cheng: You know, why was that we perform a fork operation. Okay, so when you perform for cooperation over here, what you do is that you're going to, and we saw before I you know 82 00:11:06.660 --> 00:11:08.700 William Cheng: The copy on write and for works perfectly. 83 00:11:09.090 --> 00:11:17.070 William Cheng: Perfectly fine with the share memory segment. So we're going to start with a simple case where everything works just fine. Right. So you see where it goes. And then we're going to look at the more difficult case. Yeah. 84 00:11:17.250 --> 00:11:22.710 William Cheng: All right, so if we have a share mapping right so this one directly point to the file objects. Okay, we know that there's not object. 85 00:11:22.920 --> 00:11:32.010 William Cheng: This is the MO BJ that live inside the vino that seems out of object, but I'm going to keep saying the file object, right, because in the end, there's a one to one correspondence. So again, that doesn't really matter. 86 00:11:32.400 --> 00:11:40.380 William Cheng: Yeah, alright. So, this one will be appointed a file object, right. He's got a file object over here, this is the 10 kilobytes, you know, memory segment we implement using three paste rain. 87 00:11:40.650 --> 00:11:49.320 William Cheng: X y AMP z. And now when we have full coverage how process you will be process be when you perform the fork operation. We don't copy any patient. We're going to share all the PageRank. 88 00:11:49.680 --> 00:11:53.220 William Cheng: Then, but we're going to copy the address base. So therefore, we're going to take this 89 00:11:53.460 --> 00:12:00.450 William Cheng: You know, leaving your list of VM area we're going to make a copy of it, right. So one of them over here will be correspond with this one. So now this one since they are sharing 90 00:12:00.840 --> 00:12:07.650 William Cheng: This one can just point to this fall object. Okay. So, therefore, when I perform for operation. When I finished it will look like this. 91 00:12:08.340 --> 00:12:17.010 William Cheng: Okay, so again, a process, a over here, a modified the data is that page crazy over here process be will see the changes and that's perfectly okay because that's what sharing means 92 00:12:18.150 --> 00:12:26.880 William Cheng: Alright, so again, I mean, that would be fantastic, man. But if this one is a memory map file and then they using the share memory segment one does. In this case, this has to happen. Yeah. Alright. So again, this, this. 93 00:12:27.180 --> 00:12:36.990 William Cheng: Case worth. We also saw before that, if you, you know, if you fork first and then perform copyright that also work. So now we're going to jump directly into the case that's most that was giving us trouble. 94 00:12:37.410 --> 00:12:44.250 William Cheng: Okay, so, so, so what you would do is that you were to copyright first and then you do for it. And then in that case we know that we need to perform 95 00:12:44.670 --> 00:12:51.330 William Cheng: We need to reset for copy. All right. Okay, so now we need to do that with shadow objects, right. So let's see what what that's gonna look like. 96 00:12:52.230 --> 00:13:03.570 William Cheng: Okay, so this is the case, that was the most trouble over here. So now again this memory segment of your again there are many, many Members. I'm only focusing on one and this one is a privately memory. Memory segment could be he could be, you know, 97 00:13:04.530 --> 00:13:09.300 William Cheng: Could be staggered, whatever. So in this case, this point or the first object data points will be shut off yet. 98 00:13:09.630 --> 00:13:19.740 William Cheng: Okay, so in the beginning. So shall object is empty, right, because we haven't performing copy on write yet. Yeah. And then this 1.2 again I'm going to call it the fall object instead of object over here. There are three page from x y AMP z. 99 00:13:20.160 --> 00:13:21.180 William Cheng: The picture look like this. 100 00:13:21.780 --> 00:13:28.650 William Cheng: Okay. And again, the way we're going to sort of connect this with our page table over here is that we're going to have a page table over here are three entries over your call x, y, and z. 101 00:13:28.830 --> 00:13:34.770 William Cheng: And then each one of them in the beginning, you know they're they're going to be read only and stuff like that. So they will look like this. 102 00:13:35.340 --> 00:13:45.780 William Cheng: Okay, so this x y&z over here are references to these paste rain or you can also think about the reference the physical page. So these are the physical page over here, x, y, and z. Again, they're young. These were referred to the pace rain. 103 00:13:46.080 --> 00:13:54.540 William Cheng: And then for process is page table over here we have X, Y, and Z. These are the three page table entry. They're all read only. And then the physical page over here. The whole point of these three pages. 104 00:13:55.350 --> 00:14:04.290 William Cheng: That. So again, the case where trouble with us is that we're going to perform copyright first and then we're going to form. Okay, so there's no child process yet. Right. Right now we're gonna move on copy on write 105 00:14:04.830 --> 00:14:11.310 William Cheng: So let's do it right. So again, we saw this you know operation, many, many times. Right. He is going to modify a page next 106 00:14:11.520 --> 00:14:17.370 William Cheng: Page x is this one. It's incompatible with read only is what we're gonna do. We're trapped inside the operating system. The 107 00:14:17.580 --> 00:14:23.640 William Cheng: System is going to ask the buddy system for new page. We're going to copy this one over here, you know, copy this one. So this one is a new page x 108 00:14:23.850 --> 00:14:32.130 William Cheng: We're going to change this point of the point there change this one to rewrite and I'm going to go back into the user space program to say try again. And now you will modify this page x 109 00:14:32.490 --> 00:14:42.690 William Cheng: Okay, so when we finish doing this it will look like this. Yes. Okay. This is, you know, a finished modified Ajax. OK. And now we're going to perform the fork operation. Yeah. 110 00:14:43.170 --> 00:14:53.370 William Cheng: Alright, so the next thing I will do what we have, also, by the way, the one, one thing you have to do over here is that now we have two x right this x over here who's keeping track of what's kept talking about inside the file object. 111 00:14:54.240 --> 00:14:59.790 William Cheng: Okay, or inside the you know the demo widget inside of you know is a file object, right. So this one is skeptical right here. 112 00:14:59.970 --> 00:15:08.160 William Cheng: This page x over here. Somebody needs to manage it, because otherwise it's gonna disappear. I mean, again, we said, Oh, there's a point of pointing to it. But this this pointer is a temporary pointer. 113 00:15:08.610 --> 00:15:11.460 William Cheng: Because page table can be wiped out anytime. So therefore, it doesn't really count. 114 00:15:11.760 --> 00:15:14.280 William Cheng: Okay, so therefore we need to keep track of this page right 115 00:15:14.460 --> 00:15:25.230 William Cheng: And this one was originally copied all right but it has been modified so therefore we're going to make a reference to it inside a shot object. So the way we're going to draw this is I'm going to point to this one like this. So when this one is done, it will look like this. 116 00:15:26.280 --> 00:15:38.280 William Cheng: Yeah. So now again, if you look at this data structure there to Patreon X one is at the bottom and the other one is managed by the chatter object right one, the one, the one at the bottom. Over here is the original shadow object so 117 00:15:38.670 --> 00:15:43.440 William Cheng: The one at the bottom of yours original page for IMAX the one inside the shadow object is the one that has been modified 118 00:15:44.790 --> 00:15:45.090 William Cheng: Okay. 119 00:15:46.140 --> 00:15:51.900 William Cheng: Alright, so now the next thing that we do is that AI is going to form to create be right. So, therefore, we're going to create a trial process be over here. 120 00:15:52.110 --> 00:16:00.810 William Cheng: We're going to make a copy of the address space, right. So they're going to copy the linear list of VM area when a copy all these data structure over here. And then one of them corresponding with this one. 121 00:16:01.050 --> 00:16:06.780 William Cheng: This one is private, right. So, therefore, this one, we need to point to the shadow object. Right. So when you make a copy. They point to the same thing. 122 00:16:07.170 --> 00:16:14.220 William Cheng: Okay. And then we also have our page table. Don't take our pace table. We're going to copy it and then we have to do resettle copy on write 123 00:16:14.850 --> 00:16:23.100 William Cheng: Okay, so therefore we're going to copy all this kind of solve XY and Z right here and we have to reset to change them all to read only. And this one, we have also changed to read all 124 00:16:24.210 --> 00:16:27.870 William Cheng: Okay, so when we're done, he will look like this over here. Okay, so, yeah. 125 00:16:28.920 --> 00:16:36.510 William Cheng: We create process be over here. We're going to copy this link bliss over here, they will point to the same thing. We copy and paste a ball and now we have to read 126 00:16:36.750 --> 00:16:46.560 William Cheng: Reset for copyright rights over here. This one change the read only over here. This one change to read only. Right. So again, they all need to point to the new one over here. So, so this is not difficult to do. 127 00:16:47.910 --> 00:16:55.140 William Cheng: Okay, so, so therefore you know there's no right when you receive a copy on right so when you change this one to like this. There's also one more thing that we have to do. 128 00:16:56.190 --> 00:17:05.250 William Cheng: That. So since we are resetting for copy on right so now all the patients that we have what we hear, they will initially copy on write and they haven't been modified 129 00:17:05.610 --> 00:17:12.300 William Cheng: That's what it means to be reset for copyright right it's as if all those PageRank. They are the latest page rank and we haven't performed copy on write on them. 130 00:17:12.750 --> 00:17:24.060 William Cheng: Okay, so therefore this patient over here page from x over here as should be consider as unmodified because how do you do that. Well, the way you do this is that you add another shadow object right here. 131 00:17:25.170 --> 00:17:34.980 William Cheng: Okay, if you add a shuttle object right here. Then, then you know the shadow object will be the ones actually storing our Patreon, that was originally copied on right and now it has been modified so therefore they need to go there and 132 00:17:35.250 --> 00:17:47.190 William Cheng: Same thing with the process me. So whenever you perform for you need to reset for copy on write both for the parent for the child. And also you need to add a brand new shot object which is empty for these two processes. Okay. So, therefore, when you're done, it will look like this. 133 00:17:51.900 --> 00:18:03.750 William Cheng: Okay, so when you're done, it will look like this. Right. So over here, you know, this one is empty over here. Right. So. So in this case, again, what we're saying over here is that now, or we reset will copy on write, have you make your. Have you done copywriting any other page rank. 134 00:18:04.380 --> 00:18:17.340 William Cheng: Well, the answer is no, right, because we forgot. No, we're done at all before right process. A before we do this right before we do this process. So yeah, I think you're right. This is the object that has the the patient that originally you know that 135 00:18:17.730 --> 00:18:26.850 William Cheng: That there were originally copied on right but hasn't been modified and now this one, the one that keep track get captured companies had a shot object that's the, that's why. That'd be my mother has been modified 136 00:18:27.540 --> 00:18:41.400 William Cheng: Okay. So, initially the parent process know about this, but now once we reset copy on write, then everything below this line right once when we sell will copyright everything below this, this line as far as process. A and B are concerned, they are read only. 137 00:18:43.110 --> 00:18:44.220 William Cheng: Okay, so that's what it means. 138 00:18:45.000 --> 00:18:55.860 William Cheng: To receive a copy on write anything below that, you know, these brand new shadow object. They are all considered read only. Right. So in this case, when you try to perform copy. All right. What do you copy them to do you copy them into the shadow object now. 139 00:18:56.550 --> 00:19:02.670 William Cheng: Okay, because everything below over here, as far as these two positive because they're completely frozen. You can only read from there you can never write to them. 140 00:19:03.510 --> 00:19:08.730 William Cheng: Okay. And why don't we need to write to that you make a copy and you right into the copy. So therefore, they will go into the shadow object. 141 00:19:10.980 --> 00:19:15.150 William Cheng: Alright, so again, reasonable copy. All right. Right. We need to change the page table entry for privately. 142 00:19:15.630 --> 00:19:25.260 William Cheng: Memory segment to read only. So for every one of this memory segment over here as long as they're private. We need to find all these pastry and find the corresponding page table entry over here, reset them all to 143 00:19:25.500 --> 00:19:37.080 William Cheng: You know, we send them all to read only and also for the parent and child processes that we here, we need to add another note is that a limitless. Okay, the first know has to be empty shadow object. Okay. And then they will point to the to the other side. 144 00:19:39.090 --> 00:19:45.690 William Cheng: Alright, so this is how we perform copy on write, you know, I'm sorry. How we reset for copyright. There are two things that needs to be done. Yeah. 145 00:19:47.910 --> 00:19:51.660 William Cheng: There's a little comment over here. So we need to actually doesn't do that do that. Exactly. 146 00:19:52.080 --> 00:20:01.560 William Cheng: We need again. It's a toy ordinances. And so what they do is that they do these the same to stir in two steps. Okay, so it doesn't change the page table entry over here to really 147 00:20:02.010 --> 00:20:11.400 William Cheng: Read Only instead. What it does is that they are maps the entire user space page table I he said the equal to zero for all the user page table entries over here. 148 00:20:12.690 --> 00:20:22.470 William Cheng: Okay, so. So again, you can see that if there are many, many memories, like, man, for every segment. There are many, many page rank for every patient and we need to go to one place at one entry and change it to read only. That's a lot of work. 149 00:20:22.890 --> 00:20:24.420 William Cheng: Okay, that's also very, very tedious work. 150 00:20:24.660 --> 00:20:29.160 William Cheng: If you do that, maybe going to end up with errors over here. So we need does a very simple approach over here. 151 00:20:29.280 --> 00:20:39.060 William Cheng: What they will do is that they were a map the entire page tables. A B equals to zero over here. So again, the equal to zero, only for the first three quarters of the page as well because the bottom. Hope you went to the Colonel. 152 00:20:39.390 --> 00:20:47.340 William Cheng: Okay, so therefore the first record over here. They are the entry for user for for for the user space program, we're going to set equal to zero, all that 153 00:20:48.900 --> 00:20:58.110 William Cheng: Okay, so now when you try to use these entries over your wife, and while again equal to zero, you're going to live inside of Colonel so when you finish trappings that account over here at the colonel will actually fix all these pages table entries over here. 154 00:20:59.490 --> 00:21:07.890 William Cheng: Okay, so instead of fixing them only one shot. And when you make the for system Hall right when you made the first season call all they do is to zero out the 155 00:21:08.160 --> 00:21:15.810 William Cheng: Both of these both of these page table. And that's how when you go into the user space program what happens. Are you going to start getting paid file and we're going to use the on demand page and again 156 00:21:16.020 --> 00:21:24.510 William Cheng: But this time, all the patient on inside a colonel already right so therefore we each have things that are currently. You don't have to go to the disc anymore. You need to find those pages for him and then change the pace table entries over here. 157 00:21:24.690 --> 00:21:37.920 William Cheng: And then if you are performed the read operation you change the read on it. Okay. If you're on the right operation at this point by looking at the the VM area, you should be able to tell whether you doing copy on write or not. If it's copy on write, then you can perform the copyright operation. 158 00:21:39.330 --> 00:21:51.480 William Cheng: Right, so it's okay if it turns out that it's a it's a private member segment and you're right right where you make a copy of the patient over here and then you store the copy inside the shadow object. 159 00:21:53.070 --> 00:21:59.520 William Cheng: Or. So in this case, you know, when you perform the forces that are you going to come into the kernel. As soon as you go back into your space, you know, Ii Ii 160 00:22:00.060 --> 00:22:03.840 William Cheng: II, you're gonna start getting page files and in the pace for you fixed up all these page table entry. 161 00:22:04.560 --> 00:22:09.630 William Cheng: Okay, so therefore, when you perform the for cooperation, when will you come into the kernel. You got to create the new 162 00:22:09.840 --> 00:22:20.190 William Cheng: Shadow object that Paul, you have to do well you perform the fork operation, but the patient branches over here instead of changing every entry. What you do is I use a map the entire year user space page table entries 163 00:22:21.360 --> 00:22:21.660 William Cheng: Right. 164 00:22:23.550 --> 00:22:29.070 William Cheng: All right. So, by the way, you know, I'm going to run out of space. Pretty soon. So, so I'm going to stop drawing, drawing you know the 165 00:22:29.370 --> 00:22:35.340 William Cheng: This page, these, these tables and also the physical pages over here. We only got to pay attention to the shadow object data structure. 166 00:22:35.730 --> 00:22:42.570 William Cheng: Yeah, so, so. Yeah, we know. We know what the other thing is, look. Right, right. So, therefore, we don't have to keep pointing at the arrows going to become really, really confusing. 167 00:22:43.230 --> 00:22:52.620 William Cheng: So we're gonna we're gonna sort of simple and pictures look like this. Right. So, so now you perform a fork operation we reset for copy on write. Okay, so now we're going to continue 168 00:22:53.130 --> 00:23:04.440 William Cheng: With our example. OK, so now to get as far as process amb is concerned, below this line. Everything is read only. And now they haven't done any copy or right. Yes. So that's why bush other options over here I'm completely empty. 169 00:23:05.850 --> 00:23:10.740 William Cheng: Okay, so let's continue to our example over here. So, be able to modify page z. 170 00:23:11.340 --> 00:23:17.280 William Cheng: When a mother of a pain. See what's gonna happen, right. So, a mother pages over here, since we have reset for copy on write every entry or 171 00:23:17.640 --> 00:23:20.880 William Cheng: It's going to be read only. Right, whether you do the weaning supposed to in two steps. 172 00:23:21.090 --> 00:23:30.960 William Cheng: Or you do it in the the Linux approach student one shot. Again, it's more complicated. I should I, should I don't know exactly how they doing the Linux. Maybe they do it exactly the same as Phoenix seems to be pretty straightforward, right. 173 00:23:31.260 --> 00:23:39.330 William Cheng: Okay. So anyways, either way is going to modify page Z paid Zoom is going to be read only. You're trapped inside the Colonel. So in this case, where do I copy paste it from 174 00:23:40.380 --> 00:23:46.980 William Cheng: Okay, if you look at this picture, there's only one page Z right so they have a clearly this is why the copy for him. So therefore, you're going to ask the buddy system for new page. 175 00:23:47.160 --> 00:24:00.570 William Cheng: You copy this Pacey over here. So this one was, it will be the new page D and now you change your page table entry to point it this way. You also need to keep track of the new page Z inside the chatter object. So over here in Chicago. Here I'm going to make reference to this PhD. 176 00:24:02.040 --> 00:24:07.110 William Cheng: Okay, so this is how I keep track of them right so so as going about her page. See, I'm going to end up with this situation and you go back 177 00:24:07.800 --> 00:24:13.680 William Cheng: To the process. A will continue, please go to modify PAGE Why, again, why is read only. You're trapped inside the Colonel. 178 00:24:14.100 --> 00:24:18.450 William Cheng: There's only one page. Why, and it's right here. It's very, very simple. You ask the buddy system for new page for and 179 00:24:18.870 --> 00:24:33.540 William Cheng: You copy this why into it. Now this one become PAGE Why, and then you keep track of this one inside the shadow object. Okay, so. So again, this one will refer to this page. Why so when you're done, it will look like this. Yeah. So. So over here, it says, you know, to find a place to copy 180 00:24:37.260 --> 00:24:48.090 William Cheng: And paste a copy to you must manage by the first shot on the web form. Copy that. So, so anytime you want to copy something into another page rain, they go into the shot object, right, because everything below the slides. Consider read only. 181 00:24:48.750 --> 00:24:55.830 William Cheng: Okay. Alright, so let's continue with the example over here. He's going to fork to create a see rather than what do you have to do. 182 00:24:56.280 --> 00:25:01.920 William Cheng: You're gonna, you know, creative process see over here. Make a copy of this linear Lissa. You know, a 183 00:25:02.250 --> 00:25:08.970 William Cheng: VM area over here and this one corresponding to this one right and this needs to be pointed this one. But wait a second, we need to reset for copy on right 184 00:25:09.120 --> 00:25:20.370 William Cheng: So therefore, we need to allocate a new shiny object over here, allocate a new shadow object go over here and also from this point on, as far as process, B and C is concerned, below this line everything over here is read only. 185 00:25:21.600 --> 00:25:34.920 William Cheng: Okay, but what about for between process and be present and be below this line over here is read only. So for process be below this line is read only for process. A below the slides is read only for process. See below this line over here is going to be read only. 186 00:25:35.550 --> 00:25:43.650 William Cheng: But as you can see that this feature is going to get very, very complicated. Pretty soon. Okay, so without these data structure is very difficult to actually keep track of what we don't know what's really not read only. 187 00:25:44.070 --> 00:25:47.250 William Cheng: Yeah. Alright. So when you finish working process. See what look like this. 188 00:25:47.910 --> 00:25:57.480 William Cheng: Guy. So again, this is the same memory segment over here. They point to an OSHA empty shout object again below this line, you know everything, you know, for us as B and C. They read only. Yeah. 189 00:25:58.290 --> 00:26:03.840 William Cheng: OK. Let's continue our example over here is going to modify page x, guys. So in this case, there are two page x 190 00:26:04.140 --> 00:26:18.750 William Cheng: Which one should a modifier. So again, you know, we saw that he already modified page z as a page. These rewrite the page. Excellent. Why they are read only. Right. So, therefore, if you try to modify page. So you try be inside the Colonel. Now it comes out a kernel, which acts, do you copy for 191 00:26:19.770 --> 00:26:24.540 William Cheng: Okay, so there's this one which is older. This one is newer over here. So what you have to do over here is that you don't 192 00:26:25.740 --> 00:26:30.420 William Cheng: If you take a look at the data structures over here for process. A over here. There's actually a link 193 00:26:30.960 --> 00:26:36.060 William Cheng: That will take you all the way to the original though we're taking all the way to the original page right 194 00:26:36.960 --> 00:26:44.490 William Cheng: Okay. So, therefore, if you follow this link lists over here, you can actually 555 pages and that will be the one that's newest for process a 195 00:26:45.210 --> 00:26:54.870 William Cheng: Okay, so therefore that's the one that was an Asia copy for I'm and also it kind of makes sense. Over here, right, because remember, you know, paychecks over here, we perform copy on what already. So this one is the modified version of the original right here. 196 00:26:55.170 --> 00:26:59.040 William Cheng: So therefore, from this point on, if you want to perform copy. All right, you should copy from this one. 197 00:27:00.660 --> 00:27:00.990 William Cheng: Yeah. 198 00:27:02.160 --> 00:27:03.750 William Cheng: Let me see, where is my 199 00:27:04.920 --> 00:27:11.670 William Cheng: Did I forget to read something. Okay. All right. I think I saw you know skip this slide over here that's to find a page to copy from 200 00:27:11.940 --> 00:27:21.270 William Cheng: This is the algorithm, you have to use right so so whenever you you know what what do you try these out a colonel. He said, Oh, I need a full copy of all right. Where do I need to copy from, you have to run this algorithm. 201 00:27:21.660 --> 00:27:29.940 William Cheng: OK, so the awkwardness. So, so first of all, where you get a page, all you need to find them every segment right. Why did you find a memory segment this guys will be a VM area. If you follow this linguists over here. 202 00:27:30.360 --> 00:27:36.510 William Cheng: You know, you will need to all the way to the object at the bottom over here. So what you need to do is that as you traverse wingless 203 00:27:36.810 --> 00:27:47.100 William Cheng: For every shadow object, you have to ask whether that that a patient that patient that you're looking for is in there or not. Okay. Because as soon as you find one that's the one that you need that you need to copy from 204 00:27:47.880 --> 00:27:53.850 William Cheng: Okay, so in the end if if you cannot find it anywhere inside the, you know, this object over here, what the object must be at the bottom. 205 00:27:54.030 --> 00:28:03.990 William Cheng: Because the bottom object over here is the one that manage all the patrons. Okay. All the original pitch rain so therefore we should have a formal linear search here, you should always be able to find that particular topic for 206 00:28:04.800 --> 00:28:06.120 William Cheng: Us to be able to find the PageRank. 207 00:28:06.510 --> 00:28:08.550 William Cheng: Mess over here. Again, I'm going to read this algorithm over here. 208 00:28:08.760 --> 00:28:20.370 William Cheng: Start with the process memory map. Alright, so again the memory Bob over here, follow the chain of shadow object you find a BM area you follow the link list of shadow object. So even though this picture this, picture look like a tree right 209 00:28:20.610 --> 00:28:32.220 William Cheng: Does it look like a tree over here. It looks at the tree, but this is an inverted tree. There's wasn't inverted tree right same virtual expect basically a bunch of English at the end they point to the same root note at the bottom of the tree. 210 00:28:33.480 --> 00:28:41.070 William Cheng: Okay, so therefore it's really the Upside Down tree right you know. So you saw with the leave you then then then then and then India they all point to the same route now. 211 00:28:41.490 --> 00:28:48.030 William Cheng: Okay. So, therefore, if you start with any kind of leave all you have is the link less well guys, this is actually not a true data structure. It's an inverted tree data structure. 212 00:28:48.330 --> 00:28:56.820 William Cheng: There. Alright. So you start with the process memory map follow the channel shout objects. And then if it's not in such an object, you know, you can follow the link will be here. 213 00:28:57.180 --> 00:29:03.660 William Cheng: Eventually it will end up with the the object about it. Alright, so the object about and we mentioned before, it's the fall off jack. It's also the anonymous object. 214 00:29:04.050 --> 00:29:11.700 William Cheng: They also called the anonymous object zero object, right, because these are the you know the these are the one I guess for for Linux operating system also for when he 215 00:29:12.180 --> 00:29:18.120 William Cheng: When the when an anonymous object, create a patient. It was zero, the pace ram alter the value of zero. 216 00:29:18.900 --> 00:29:24.450 William Cheng: Okay, there are some criticism doesn't do that again. This particular behavior is operating system dependent that 217 00:29:25.230 --> 00:29:27.990 William Cheng: All right, sorry I skipped this this the yellow box over here. 218 00:29:28.530 --> 00:29:34.410 William Cheng: So, so right now we're going to implement this algorithm here. So I've been is that you know you modify paychecks. I'll be here. We're gonna follow the algorithm you 219 00:29:34.980 --> 00:29:42.780 William Cheng: Know, so. So this one again x y AMP Z belong to this memory segment. So now you need to find x. So, you follow this link list. I'll be here. 220 00:29:43.020 --> 00:29:51.990 William Cheng: For process, eight, nine. So, President Obama. He said his patient X in here, the answer is no. So you follow the links over here and then you find this one you find x now. 221 00:29:52.440 --> 00:29:56.460 William Cheng: Okay, so that's where you have to copy from right the first one that you find will be able to record one 222 00:29:56.580 --> 00:30:07.350 William Cheng: So this one. What you would do is that you ask the buddy system for new page rank right and then you copy from this wine. Now, this will be the new page fan and now you keep track of this one. This one over here is called X over here, this one to point it out one 223 00:30:08.880 --> 00:30:16.080 William Cheng: Okay, so therefore it's gonna be like this. You're gonna make a copy and the references in page x over here. Okay. Similarly, P is going to modify also paychecks. 224 00:30:16.500 --> 00:30:23.310 William Cheng: guys again for be we just reset for copy on write the shadow object is empty. All the page table entries over here, they're 225 00:30:23.760 --> 00:30:29.640 William Cheng: If they're private, they're all read only. So they're going to try things out of the Colonel. And now, again, we need to follow that that algorithm. 226 00:30:29.790 --> 00:30:40.440 William Cheng: So this is process v over here, we find that the pace for address inside this memory segment. So again, this case, we need to find page x want to go to this one said, You are page X know we go to the next one of your 227 00:30:40.650 --> 00:30:46.050 William Cheng: Page acts as a yes. As I know over here we go to the next one over here. And that's what actually has paychecks. Right, so therefore 228 00:30:46.410 --> 00:30:57.000 William Cheng: We're going to ask the buddy system for a new page. We're going to copy this one this will be new page x. And now he's our process be over here, we're gonna we're gonna remember this page. Page x because this one is gonna be managed by here. 229 00:30:58.200 --> 00:31:07.980 William Cheng: Okay, so see over here is going to modify page z for processing, we just received a copy long run. So sees going to be read only your tribe inside the operating system. And then again, we're going to find this memory segment. 230 00:31:08.550 --> 00:31:18.690 William Cheng: There's three page, right, I'm gonna start looking at page Z. It's not here. It's not here. It's not here at the bottom over here. So, therefore I'm going to ask the buddy system to allocate a new page. Make a copy right here. So, this will be a new page z. 231 00:31:18.870 --> 00:31:25.830 William Cheng: And now we're going to make a reference inside a shadow object to this, this option over here. Okay, so when we finished all these three operation, it will look like this. 232 00:31:27.600 --> 00:31:32.790 William Cheng: OK. So again, the ad copy of X is right here. Please copy extra here and sees copy of these right here. 233 00:31:33.750 --> 00:31:39.720 William Cheng: Okay, so now if you ask process. A Where are your page rank X, Y, and Z. For this particular memory segment. 234 00:31:40.320 --> 00:31:46.470 William Cheng: What it's going to be the answer for process, a process SS, you know, so you need to follow the you know the algorithm. I'm trying to look up the pace red 235 00:31:46.770 --> 00:31:57.540 William Cheng: x's here whereas why why is not here. Why is not here. Why is it right here. Why is right here. And these right here okay so process. A x y AMP z are right here. So this is process as x y&z 236 00:31:58.110 --> 00:32:09.060 William Cheng: Yeah. What about if you ask process, the A B. Where's your x y AMP Z right X is actually right here. Right. Whereas, why, why is right here, whereas these these right here. So we'll process be x y AMP Z or right here. 237 00:32:10.500 --> 00:32:26.100 William Cheng: There for process see where's X y&z right. So x is actually right here. Right. So again you you follow this link this over here, x is not here. Not here x right here, whereas why why is actually right here. And these right here. So for process C x, y, and z are actually right here. 238 00:32:28.350 --> 00:32:34.920 William Cheng: Okay, so you can actually see that you know this data sources, very, very tricky. Okay. For every process X, Y, and Z. They're all scattered all over the place. 239 00:32:35.160 --> 00:32:41.640 William Cheng: But if you use this data structure, you can find all the right pages and then you know where to copy from well you have to perform copy. All right. 240 00:32:42.240 --> 00:32:52.770 William Cheng: Guys. So again, this case we don't rely on anything inside of a stable because inside the page table can a map. So therefore, equal to zero, that means that the patient when she is not valid. So therefore, we're not allowed to use the pointer there. 241 00:32:53.250 --> 00:32:59.490 William Cheng: Okay, so therefore we're going to rely on the colonel data structure over here to tell us for every memory, Simon. Where are all your patrons. 242 00:33:00.750 --> 00:33:09.330 William Cheng: Okay, so when you're doing your assignment. This is very, very important. And for every process of every, every segment. You have to know what your patients are rather this way, your program will execute correctly. 243 00:33:10.380 --> 00:33:10.680 William Cheng: Okay. 244 00:33:12.540 --> 00:33:20.550 William Cheng: All right. Um, I can actually go on, you know, you know, she's gonna, you know, a full cup of tea process. I'm going to do a lot example. So again, you sort of know how to work. So I'm going to stop right here. Okay. 245 00:33:21.060 --> 00:33:30.960 William Cheng: Yo, Colonel three, there is a there's there's a program called forth bomb. I think inside. For now, you can afford 1000 times and I think they're doing copy. All right. 246 00:33:31.470 --> 00:33:36.810 William Cheng: Okay, so therefore, you're gonna have 1000 processes this data structure is gigantic. It's a big mess. 247 00:33:37.020 --> 00:33:43.140 William Cheng: You're going to make sure that when you perform copy all right you copy from the right place. Okay, so they have. I always get a question. Does it do we have to implement the 248 00:33:43.710 --> 00:33:51.300 William Cheng: Copy. All right. Well, I mean, you know, look at this complexity over here. Do you have to implement copy. All right. I mean, yeah, if you don't want things to work. You don't have to worry. You don't have to be printed out object. 249 00:33:51.510 --> 00:33:59.310 William Cheng: But if you want things to work perfectly. Which is why we're taking this class will learn how to do things perfectly. We have to implement that object. Okay. 250 00:34:05.310 --> 00:34:13.830 William Cheng: So just a little note over here in Phoenix, the object at the bottom over here. So again, it's upside down tree. Yes, there's a route that's got a bottom object over here. 251 00:34:14.550 --> 00:34:17.640 William Cheng: So again weaning sometimes they're not very creative. Right. So the object of the bottom is called 252 00:34:17.940 --> 00:34:30.750 William Cheng: Object. And again, this doesn't really have to be associated with a file or it could be associated also with the anonymous object, right, and also the bottom logic over here is going to be the one that's that's in the Ma ma LBJ that's inside of vino that the instead of object. 253 00:34:32.070 --> 00:34:37.110 William Cheng: OK. So again, the object at the bottom over here. That's the one that has all the original piece rains. 254 00:34:37.620 --> 00:34:44.940 William Cheng: Okay, all the other one on top of it. Again, this is belong to the private memory segment. So, therefore, a picture will look like this. If you're doing copy. All right. 255 00:34:45.390 --> 00:34:49.950 William Cheng: Okay, so all the copies I maintained by the, you know, bye, bye, bye, bye, bye, bye, the shadow objects. 256 00:34:50.820 --> 00:35:02.280 William Cheng: Or it and I'm this object and the one that's inside the Beano the enemy LBJ, those are the one that managed the original, original piece right so then what is the original page right that's the one that's identical to what's on the desk. 257 00:35:03.600 --> 00:35:06.210 William Cheng: Okay. So again, it's very important to understand this picture. Yeah. 258 00:35:06.960 --> 00:35:17.580 William Cheng: Alright, so again we're using polymorphous them at this point over here clearly as a poly movie pointer, you can point to a shadow object can point directly to anonymous up a gun pointed anonymous object and also pointed the admin will be J. 259 00:35:18.210 --> 00:35:23.370 William Cheng: You know, inside the the Beano. Is that a file object and also all these pointers over here. Again, they're all polymorphous pointer. Right. 260 00:35:23.550 --> 00:35:33.300 William Cheng: The last pointer over here coming out of the shower object. What is the point to it right you can point to a shadow object. You can also point to the memo BJ instead of, you know, you can also point to anonymous object. 261 00:35:34.230 --> 00:35:44.460 William Cheng: Okay, so in Colonel three. I think the last discussion section I mentioned, you know, one thing is that in Colonel three, you know, the polymorphous them you know he's gonna go crazy. So now you can actually see what's going on. Yeah. 262 00:35:46.950 --> 00:35:52.650 William Cheng: All right, let's take a look at a slightly different example the object at the bottom over here. They don't really have to have all the PageRank. 263 00:35:53.490 --> 00:35:58.860 William Cheng: Okay, it is possible that the object at the bottom over here. He only has page frame X and Z. It doesn't have patient and why 264 00:35:59.100 --> 00:36:09.060 William Cheng: OK, so the terminology that you use in the Venus current over here is that page rank X and Z. They are memory resident or pastry. And while we're here is not memory resident 265 00:36:10.350 --> 00:36:15.630 William Cheng: OK. So the reason I sort of want to use the terminology is that is that when you start your kernel three. The first 266 00:36:16.200 --> 00:36:23.220 William Cheng: Function, you have to implement is P for and get okay so he's happy for him get if you read a comment that will say, you know, you need to see if this is this 267 00:36:23.670 --> 00:36:29.280 William Cheng: Page room is resident or not. If this is written resident you do this if it's not resonating do that. Alright, so this is what it means. 268 00:36:29.730 --> 00:36:34.380 William Cheng: You know the object over here, when they are now resident. That means I'm sitting on the desk. Okay, how do you get it. 269 00:36:34.980 --> 00:36:42.330 William Cheng: What if you know if the object over here is the LBJ that's inside of vino those things. How to Follow object while you tell the file object to go ahead and get it. 270 00:36:43.020 --> 00:36:52.860 William Cheng: Right, because the file object knows you know how to how to get it on the desk that if the bottom object over here is an anonymous object, the anonymous object over here when you try to you know what 271 00:36:53.310 --> 00:37:00.630 William Cheng: We try to realize his face right the anonymous object and create this patient out of thin air by allocating four kilobytes. And they're filled with zero 272 00:37:02.070 --> 00:37:11.580 William Cheng: Whereas it again, you know, these to do these these different memory management objects they sort of, you know, do things a little differently, but we use probably more for them to sort of make them look like look very, very similar, but 273 00:37:12.930 --> 00:37:21.450 William Cheng: Alright. So in this case, you know, get ex Soviet can be copied all over the place to be. It can be copy or place but nobody ever access. Why so therefore, why can still sitting on the desk. 274 00:37:21.690 --> 00:37:28.980 William Cheng: Okay, so next time, will you will we reference. You know why over here, you, you know, again, you try to write to why you need to put on copyright you coming out of Colonel 275 00:37:29.160 --> 00:37:36.390 William Cheng: And then you find out that this wide patient patient doesn't exist. So, so what do you have to do. Right. So again, you need to create a page frame, right, the patient is sitting on the desk. 276 00:37:36.810 --> 00:37:41.880 William Cheng: Sitting on the desk, you're currently has to go to sleep. And eventually, you know, the data has been transferred on a distant memory. 277 00:37:42.030 --> 00:37:51.060 William Cheng: You're going to get woken up and then you're going to fix up all your data structure, right. So at that point, you also need to make a note that this particular page right now is memory resident and in there. You have to copy. All right. 278 00:37:51.450 --> 00:37:59.610 William Cheng: So let's say if you're processing over your new football copy. All right. Now you can ask the buddy system for new page copy why into this and then make a reference over here. Is that a shot object. 279 00:38:00.510 --> 00:38:04.620 William Cheng: We have to remember, every time we need to write a page frame, you always right into the shadow object. 280 00:38:04.800 --> 00:38:14.640 William Cheng: That we usually performer read, you need to put on that you know that operation to linear search, you know, to, to buy something, it is possible that you find something that's not memory resident while they in that case you need to ask the 281 00:38:15.150 --> 00:38:23.010 William Cheng: The, the LBJ inside of vino or the anonymous object to to to to to to basically realize that patient. Okay. 282 00:38:25.140 --> 00:38:25.620 William Cheng: All right. 283 00:38:27.240 --> 00:38:33.900 William Cheng: Okay, so what else I'm skipping this virtual. What is it called virtual copy assembling it doesn't matter. 284 00:38:37.290 --> 00:38:44.010 William Cheng: Okay. All right. So why don't we go through all these trouble, right, you know, because we need to implement copy on it together with for 285 00:38:44.310 --> 00:38:52.380 William Cheng: Why do we have to implement copyright with fork, right, because the original way. I mean, with the not you were implementing forget to him inefficient. And then we also don't like the fork. 286 00:38:52.890 --> 00:39:03.480 William Cheng: Okay, so therefore the right way to implement, you know, forget to do it together with copy own right and we see that some cases it doesn't really work out. So therefore, we need to, you know, create all these complications. Yeah. 287 00:39:04.170 --> 00:39:14.280 William Cheng: So we also need to understand that, you know, because we're doing copy all right with fork a variable, such as the data, a few slides back can exist in many, many different physical pages simultaneously. 288 00:39:14.940 --> 00:39:20.340 William Cheng: Every one of these, you know, one of these physical pages they contain a different version of the variable. 289 00:39:21.090 --> 00:39:28.290 William Cheng: Okay, so there was a big mess. We need to perform copyright. Again, you need to copy from the right page ranks. Okay, so that's why I need to go to a big mess. 290 00:39:28.770 --> 00:39:32.370 William Cheng: To manage this big mess. We need to use the idea of shadow objects. 291 00:39:32.640 --> 00:39:37.560 William Cheng: I think Linda tell you something very similar. What is the ideal shadow objects. Everything that we talked about. Right. 292 00:39:37.740 --> 00:39:43.620 William Cheng: It's going to organize this tree of shadow object using the inverted tree data structure right it's upside down tree. 293 00:39:43.710 --> 00:39:51.540 William Cheng: So starting from every VM area. It's like a linguist right but if you look at it, you know, if you step back and look at the entire data structure. You say, Oh, it's an inverted tree data structure right 294 00:39:51.930 --> 00:39:59.700 William Cheng: The root of this inverted tree is called the bottom object. It could be associated with anonymous object or the memo BJ that's inside of you know now. 295 00:40:00.120 --> 00:40:07.170 William Cheng: We also need to implement a rule for finding PageRank. I started on the VM area you follow the pointer over here. And then, you know, eventually, you go to the 296 00:40:09.780 --> 00:40:13.500 William Cheng: Eventually, you go to the bottom object and the bottom object, you know, 297 00:40:14.520 --> 00:40:16.380 William Cheng: I guess I forgot to mention one more thing over here. 298 00:40:17.310 --> 00:40:25.830 William Cheng: Yeah, that's actually important part over here. I forgot to mention novia when you try to look for a patient over here. If you've got to the bottom object. If it's not memory resident, you need to go get it. 299 00:40:26.130 --> 00:40:34.170 William Cheng: But what about in all the other object over here, right, you need to go. Look what Patreon, why are we here. Why is not inside a shadow object. What do you do, you don't do anything. 300 00:40:34.800 --> 00:40:42.450 William Cheng: Right, because what you're trying to figure out where to copy from you don't copy, you know. So in this case, if it's not inside the shadow of yet we don't need to do anything. 301 00:40:43.650 --> 00:40:50.700 William Cheng: Okay, so, so, so, so in this case is going to be a pass through right we try to find while we're it's not here. It's not here. We will eventually fight fight fight fight. 302 00:40:51.600 --> 00:41:00.090 William Cheng: Fight, fight in the bottom over here is the patient and they're looking for here is page x. So let's say that we're processing over here we're looking at our pace rain and we try to figure out what a copy for all 303 00:41:00.720 --> 00:41:08.790 William Cheng: X is not here right so so some people say, oh, x is that memory resident, we need to as the shutter object to create this patient, the shadow object doesn't know how to do that. 304 00:41:09.960 --> 00:41:13.440 William Cheng: Then the shadow object only knows how to do copy on write 305 00:41:14.550 --> 00:41:17.460 William Cheng: Okay. So in this case, if a patient X is missing over here, you know, 306 00:41:18.420 --> 00:41:25.680 William Cheng: The sharia didn't do anything. So you follow the pointer over here you go to the next one is that you have paychecks. It doesn't have please read this shiny object also doesn't know how to create Ajax. 307 00:41:26.130 --> 00:41:30.870 William Cheng: And then you go to the next one over here, say, oh, x is right here. So, therefore, I need to copy from here and make a new Patreon over here. 308 00:41:33.060 --> 00:41:46.140 William Cheng: Okay, so, so, so again the the shadow object, the anonymous object and the one inside the inside the vino they perform a different kind of function. The one inside the inside the bottom object over here. They always know how to create a PageRank. 309 00:41:46.860 --> 00:41:56.040 William Cheng: Okay, the wines I shut off doing over here. They only know how to perform copy on write. Okay, so, so these object, the shadow object over here, they cannot create a patron out of thin air. 310 00:41:56.640 --> 00:42:08.340 William Cheng: Okay, they have to copy from the bottom object or one of the earlier shiny object over here. There are read only. OK. And then they make a copy and then they represent me to the show. OK. So again, these are very important concept to understand 311 00:42:10.530 --> 00:42:19.620 William Cheng: All right. So again, we use our implemented these rules the roof of finding a page rain the physical pays the content, the global grab one question for particular process. But, you know, bye bye bye bye all the readmission 312 00:42:19.890 --> 00:42:25.680 William Cheng: A traverse the shadow object pointer, all you know all the way down the inverted tree and eventually you will reach the 313 00:42:26.370 --> 00:42:33.270 William Cheng: You know, reached the bottom of yet. And again, the operation that you performance that the shadow effect and the operational performance at about an object, they are different. 314 00:42:33.660 --> 00:42:43.740 William Cheng: Okay, so be aware of that. You also need to know when and how to perform copy. All right, right by setting the pace table entries over here to read only at the right time. And also you need to map the entire page table. 315 00:42:44.070 --> 00:42:52.740 William Cheng: You know, by, by setting equal to zero, you know, at the right time. So all these things you have to do everything perfectly, then you'll copy and I will work with for now. 316 00:42:54.180 --> 00:42:59.040 William Cheng: Alright, so you have to implement what's describe over here you know Ii Ii Ii 317 00:42:59.430 --> 00:43:08.670 William Cheng: II, you know, Colonel three. So, you know, Carol. Are you going to spend quite a bit of time to to to to make sure that you know I guess there's a poem called for can wait for can ways. The first time you implement 318 00:43:09.060 --> 00:43:14.910 William Cheng: You know afford, together with the copy on write. So at that time only at that time you have to start implementing the shadow object. 319 00:43:15.390 --> 00:43:19.350 William Cheng: Okay, so before that we're running hello and stuff like that. You haven't implemented yet. 320 00:43:20.310 --> 00:43:27.570 William Cheng: Well, you don't. You don't have to. So, so get what happened is that some Colonel team decided that we're going to everything at the beginning of your learning implement all the all the object. 321 00:43:28.260 --> 00:43:32.910 William Cheng: That that's fine if you if your team decided decided that that's what you want to go. 322 00:43:33.540 --> 00:43:38.790 William Cheng: Okay. You can also make the decision to say, well, we don't really have to worry about, you know, the shadow the shadow object. 323 00:43:38.970 --> 00:43:46.770 William Cheng: Until we get to fork away. So therefore, we're going to sort of try to implement a version of the colonel that handles everything before copy of people work away. 324 00:43:47.010 --> 00:43:53.310 William Cheng: Just in case we run out of time in Colonel three. So this way we can actually turn into your kernel three assignment and try to get enough partial credit 325 00:43:54.840 --> 00:44:05.820 William Cheng: Okay, so that might be a good way to go. So again, your team needs to sort of decide which way to go. Do we want to implement that object at the beginning, or we're going to sort of do this incremental approach get as many things to work, just in case we can't finish Colonel three 326 00:44:07.230 --> 00:44:16.470 William Cheng: Okay. And also, you know, if you follow my recommendation of the colonel three schedule and they, as long as you're not too far off, you can actually email NDA should be able to implement everything 327 00:44:17.310 --> 00:44:23.970 William Cheng: Alright, so again, you know, a your team gets to decide whether you want to implement shadow object at the beginning or in the middle. When you get to forget. Wait. 328 00:44:24.390 --> 00:44:32.250 William Cheng: Okay, so once you get to forget way beyond that everything needs to have copyright working with for that, so. So again, that's when you have to have shadow objects. 329 00:44:34.260 --> 00:44:44.040 William Cheng: Alright, so you mean it's an enema LBJ is used to manage have a Patreon rise of memory mmm LBJ is the memory management object. What kind of memory, do they manage the Manage page frames. 330 00:44:44.640 --> 00:44:47.850 William Cheng: Okay, so therefore again. Well, you'll never see me. What we did the other one I managed pace. Right. 331 00:44:48.330 --> 00:44:53.790 William Cheng: There are three types of them. We are we here at the colonel three assignment. Right. One of the then that's live inside of vino 332 00:44:53.970 --> 00:45:03.390 William Cheng: You saw this expression already in Colonel to write VN right arrow BMI underscore animal BJ so that you know i think the code there isn't written for you. So that's why you don't have to do anything in kernel to 333 00:45:03.930 --> 00:45:17.580 William Cheng: That so so so in Colonel three, you have to write additional function. You know, I think you have to write a function for this demo VJ or maybe most of the most of this function has written for you already. So, so you should look at the code over here to see see what it does. 334 00:45:18.720 --> 00:45:23.310 William Cheng: Okay, so this way when you try to implement other mm LBJ, you have to do similar things right again. 335 00:45:23.640 --> 00:45:30.450 William Cheng: Again, the, the one is that the Beano is a little different from shadow object so can read the comment blog, I figured out a way to do. Yeah. 336 00:45:30.840 --> 00:45:42.870 William Cheng: All right, I shudder objects that M. O. B day anonymous object is also mm will be j. So, he is that Colonel three, there are three different men. Men memory management objects. The code for the shuttle opposite for the anonymous object. None of them are written for you. 337 00:45:43.950 --> 00:45:52.080 William Cheng: Guys. Okay, I strongly encourage you to read the code for the vino and mo BJ and try to understand what it's doing over a year and all the other mm LBJ 338 00:45:52.320 --> 00:46:03.000 William Cheng: The ideas are kind of the same. Again, not exactly the same thing you have to do guys okay shut off James The one I need to perform copyrights and the more complicated. Okay, but do not have this object over here that are much more simple. 339 00:46:03.600 --> 00:46:08.820 William Cheng: Okay, so, so again, at the beginning, when you try to get a hello hello program to run all you need to do is the implant shut off. 340 00:46:09.570 --> 00:46:15.030 William Cheng: All you have to do is implement the anonymous object which is much more simpler and you don't have to worry about shout object because there's no fork. 341 00:46:15.960 --> 00:46:22.980 William Cheng: Yeah, so can you read the code for the, you know, for, for, you know, for, for the demo BJ that's inside to be no yeah 342 00:46:23.580 --> 00:46:35.760 William Cheng: Alright so VM area is supported by one of these three and it will be generous okay up, go back this picture over here, you know, for the tech segment over here, it points to the mmm over here that's inside of you know for the data segment of 343 00:46:36.960 --> 00:46:46.710 William Cheng: The BSS segment over here at the beginning they point to the demo widget that these that'd be no no but since this one is private, pretty soon you have to make a copy and writing for the copy 344 00:46:46.890 --> 00:46:50.670 William Cheng: And then what you have to do that, you have to switch this pointer and they have the point to anonymous object. 345 00:46:51.840 --> 00:46:58.290 William Cheng: Okay, so, so in the beginning when you try to read them the data you're going to use the file object over here to read the data into it. Right. And then as soon as you make a 346 00:46:58.710 --> 00:47:10.470 William Cheng: Make a copy right into the copy you want then in this case you have to switch to a different object. So, I'm sorry. So I yeah so, so I think inside the winnings cut over here. I think at some point they actually they switched it to anonymous object. 347 00:47:12.060 --> 00:47:23.280 William Cheng: OK. So again, you made a copy of this data over here and they have a managed by the anonymous object over here for the data and the BSS admin over here. So they actually take some of these object of your split into one managed by the, you know, by, by 348 00:47:23.790 --> 00:47:33.750 William Cheng: By the by the Beano and the other one managed by the anonymous object. Okay, so one this one. Oh, you're doing copy. Alright, so therefore once you do copyright, they all get get referenced inside the shadow 349 00:47:34.560 --> 00:47:46.800 William Cheng: That all right for the hip segment over here. So at the beginning of your kernel three. The hello world program. I mean, if you've proven doesn't call Malik and free. They don't have a heap segment. Okay, so therefore they hit Submit a lot from 350 00:47:47.910 --> 00:47:52.890 William Cheng: The beginning, they don't even exist. Once you start doing Malik and free day you're gonna end up the heat segment. 351 00:47:53.610 --> 00:48:00.810 William Cheng: Okay, the stack segment over here is private. So again, the point to a shadow object to shut off their point to anonymous object, right, because it's not appealing to the buses, the path. 352 00:48:01.230 --> 00:48:13.890 William Cheng: In the beginning, you're not doing memory map so therefore you don't have this object. Well, so therefore, at the beginning of weenies you actually you have only three different memory segment the tech segment the data plus BSS and also the stack segment that 353 00:48:16.920 --> 00:48:26.820 William Cheng: All right. So, by the way you look at this picture over here at the previous video view, it's kind of asymmetric right all these options over here. They have shadow. Yeah. What about this object over here. I mean, you could actually add a shadow object. 354 00:48:27.420 --> 00:48:29.700 William Cheng: Shut off to go here will look like this, is that okay 355 00:48:31.140 --> 00:48:40.740 William Cheng: Well, I mean, this one is a sheer memory segment right so therefore he is. It doesn't really supposed to have a shadow object, but this one is read only. So, therefore, even if you add a shout object over here. It also work. 356 00:48:41.190 --> 00:48:54.900 William Cheng: Okay, so therefore it's not wrong. If you also want to make things look symmetrical. Okay. But again, be very careful. It was a memory map file, then in that case you need to, you know, if the shirt. If it's a shared file. Why, in that case, you are not allowed to have a 357 00:48:56.280 --> 00:49:00.810 William Cheng: Child object, but in this example, this one is private, and that's why you end up the shadow. Yeah. 358 00:49:03.750 --> 00:49:11.970 William Cheng: All right, I mentioned before, we next the LBJ, you know, given me Jim Mannion space rain and every page rain has a unique name. 359 00:49:12.870 --> 00:49:19.020 William Cheng: Okay, so what should be the name of a train. Right. So here, this patient will be here, what should be the name of this patient, right, this is 360 00:49:19.200 --> 00:49:30.060 William Cheng: Page Z that's managed by the shadow object. So, therefore, you know the name of this patient is going to be which memory management object that it's managing this one followed by this other thing called a page now. 361 00:49:30.540 --> 00:49:40.200 William Cheng: Okay, so what does the patient I'm over here, right. So again, if we have a tank kilobytes of memory segment over here it's covered by three page rain. Right. The first one over here is four kilobyte. The second one obvious four kilobyte 362 00:49:40.380 --> 00:49:49.590 William Cheng: And the third one over here is also four kilobyte we're going to call this one page number zero page number one piece number two. So they're just re index these array or four kilobytes long 363 00:49:50.130 --> 00:49:54.300 William Cheng: Okay, so every array elements forking over as long over here. So the array index is called page now. 364 00:49:55.200 --> 00:49:59.580 William Cheng: Okay, so therefore, in this, in this case, this memory segment three page rain, so x over here will be zero, y is 365 00:49:59.760 --> 00:50:10.170 William Cheng: Equal to one and CEO of equal to two. So therefore, the real name for this page red X over here is going to be so the bottom logic of yours, no as be this object is going to be known as be comma zero. 366 00:50:11.190 --> 00:50:14.340 William Cheng: Get the next object over here is no as be comma one, and the next 367 00:50:14.760 --> 00:50:27.060 William Cheng: Year is going to be no has become a to what about this one. This one is owned by the shadow object. So this one is page z over here. So this one is x comma to write because to over here, meaning is the last four kilobytes. You have this memory segment. 368 00:50:28.740 --> 00:50:36.720 William Cheng: Okay, so therefore, again, you know, you know, so every page rain is uniquely identify by an N mo BJ that reference that page friend. 369 00:50:36.900 --> 00:50:44.490 William Cheng: Is also has followed by a patient patient number over here because every mm LBJ potentially can have all these three patient in their, in their 370 00:50:44.940 --> 00:50:48.450 William Cheng: Mind. So that's why you have to distinguish all them up by by each one of them using the page now. 371 00:50:48.750 --> 00:51:00.210 William Cheng: They're sort of notation is going to be LBJ follow page now. Right, so I'll be here this one is be comma zero. This one's become a ones who has become a two and then this one is going to be as comma to right over the years look like this. 372 00:51:02.190 --> 00:51:05.580 William Cheng: Okay, so when you try to perform a PageRank sometime you know 373 00:51:05.850 --> 00:51:11.880 William Cheng: You know, which patient that you're looking for. So if you have an object that says, so if you're trying to look for a patient 374 00:51:12.090 --> 00:51:20.610 William Cheng: If you know which object belongs to which. Mmm. Okay, but also, and you also know the page. Page damn well in that case we perform a function, you gotta, you gotta provide two keys. 375 00:51:21.300 --> 00:51:25.980 William Cheng: Okay. So in this case, what happened is that, you know, if you need to look for this object. You say, Where is S comma two. 376 00:51:26.520 --> 00:51:31.200 William Cheng: Guys, what do we do is that they will go down this list and look where it says, Oh, sorry. It won't go down this list. 377 00:51:31.680 --> 00:51:40.200 William Cheng: So as it turns out that you know the weaning status or a little complicated. The patient are stored inside of hash table. The key for the hash table is the memo BJ followed by the patient. 378 00:51:40.680 --> 00:51:45.870 William Cheng: Okay, so if you give it the entire key will actually be able to find this patient and really quickly. You can actually find out the space, right. 379 00:51:46.020 --> 00:51:53.370 William Cheng: you'll return to your page for Mr. Jerry can look at a patient and say, Are you busy, you know, are you clean or dirty me and all that kind of information about patient 380 00:51:53.550 --> 00:52:03.870 William Cheng: So once you have a patient object, you can actually say, What's your virtual address that the colonel can use. What is the physical page number that that that that this one refers to. So you can ask, all that kind of questions. 381 00:52:05.010 --> 00:52:09.630 William Cheng: Okay, so, so if you have both pieces of information you can easily use the hash table view, to find that 382 00:52:10.200 --> 00:52:21.660 William Cheng: There are other occasion over here. You don't know the name of this particular object. So for example, when you try to look for Peasy coming down from this linear list over here you get to page 12 years as words page to see what do I copied from 383 00:52:22.260 --> 00:52:27.570 William Cheng: Okay, so I got pages actually right here. So in this case, it's been modified so therefore you cannot get a pay 384 00:52:27.960 --> 00:52:36.540 William Cheng: Cut and paste on peasy. So let's say that you've got a patient and page zero here, right. So in this case you will come down this link to so I'll be here. How do you look for this page rank. 385 00:52:37.380 --> 00:52:42.000 William Cheng: That. So what you will do is it will go through the shadow RJ you say, does the shadow object has a patient zero 386 00:52:42.270 --> 00:52:51.390 William Cheng: Okay, so what you would do is that you will you will pass the name of this you know you'll pass the name of this object called S comma zero over here. You said, Does this page frame exists. 387 00:52:52.200 --> 00:53:00.060 William Cheng: Okay. If the answer is yes. That means that your patient zero is actually sitting on the same as the shadow object. In this example, the shadow object only has patient to 388 00:53:00.360 --> 00:53:05.670 William Cheng: Patient Zero. So, in this case, when you try to perform the look up operations and say, Is there such object, the answer will be no 389 00:53:06.630 --> 00:53:09.960 William Cheng: Okay. So, therefore, what you do is that you follow this the this point over here. 390 00:53:10.290 --> 00:53:17.160 William Cheng: Go to the next object over here. The next octave of yours bottom optic over here. So therefore, the patient might need to look for SP comma zero. 391 00:53:17.250 --> 00:53:24.330 William Cheng: So what I would do is, again, I will ask the hash table to say, is there a page rain be comma zero, and the answer will be here. Yes. Yes, right here. 392 00:53:24.840 --> 00:53:34.800 William Cheng: Okay. So, therefore, what it what does their return a pastry and now you have found it. Okay, so then you can ask whether the patient is busy or not busy at the way for the patient is not busy. You can actually use it right away. 393 00:53:36.210 --> 00:53:41.070 William Cheng: Okay, so again, depends on you know whether you know the name of the object over here, something you need to perform a search 394 00:53:41.280 --> 00:53:51.000 William Cheng: We want to search everything and every, every object that you that you visit your game, you have to ask a hash table, whether this object is this. OK. So again, these are the the functionality, implement, yeah. 395 00:53:53.070 --> 00:54:02.460 William Cheng: All right, so I'm done with shadow object. So Chapter seven over years. There's one more thing I will need to talk about. That's the backing store issue. So after that, then 396 00:54:02.730 --> 00:54:10.110 William Cheng: The then then then we're going to end this lecture. And then you have everything I guess at this point you have everything that you need to know to implement Colonel three 397 00:54:10.560 --> 00:54:15.060 William Cheng: Because in Colonel three. We actually don't have a backend store. Okay. Why don't we have a package store. 398 00:54:15.420 --> 00:54:21.840 William Cheng: Because we need is a toy operating system. Right. What happened is, is that we don't want to have the spa space that will be too complicated. Yeah. 399 00:54:22.710 --> 00:54:29.820 William Cheng: Alright, so I'll get back into over here at the basic idea of yours that any page rain. They can go you know if we need to swap out the entire process. 400 00:54:30.060 --> 00:54:34.470 William Cheng: Every page frame need to have a place to go inside the storage is that they can go into the file system. 401 00:54:34.740 --> 00:54:46.410 William Cheng: Hierarchy, or they can go into the software, right. So on the desk over here. What do I do different part one of them is a SWAP partition. Right. And then the other one is the, the, the, the actual file system, the actual file system has 402 00:54:47.490 --> 00:54:53.400 William Cheng: You know, has the file system hierarchy and also has free a free blocks right so that's what the actual file system, keep track. Oh, okay. 403 00:54:54.120 --> 00:54:58.980 William Cheng: All right, so. So anyway, so the so the sort of the, the data on the desk over here is going to be the back in the store. 404 00:54:59.790 --> 00:55:08.400 William Cheng: So what kind of back in store that we do actually have. So there are two kinds of backing store. One of them is the read only mapping of the file right like the tech segment. Why so in this case. 405 00:55:08.940 --> 00:55:16.260 William Cheng: The tech segment is read only the patient has never modify. So therefore, the backing store is the file itself. Right. So this is the executable file, they would 406 00:55:16.410 --> 00:55:26.100 William Cheng: Copy the data from. So in this case you need to swap out the tech stack men, while the tech savvy and is read only. So, therefore, the patient is always clean. So therefore, we don't have to send it to the soft space. 407 00:55:26.490 --> 00:55:36.900 William Cheng: Okay, so in this case the backing store is the file system hierarchy. Okay, the second case over here is the rewrite map and the rewrites share mapping of a file. Okay. So since we opened up off with 408 00:55:37.440 --> 00:55:47.910 William Cheng: The full, full, full, full force for share mapping and also this father's rewrite whenever we need to swap out this this page rain we simply can write it to the fastest as 409 00:55:48.660 --> 00:55:53.910 William Cheng: Well, so again, you know, this particular file we mapping into address space. So I will start with the data on the desk over here. 410 00:55:54.060 --> 00:56:06.930 William Cheng: We mapping to address space so that everything we champions that address space is the same as changing the file. So, therefore, if we need to swap out this particular patient to this, we simply can write a data back to this. And now, you know, we don't have to use this process. 411 00:56:08.100 --> 00:56:13.800 William Cheng: Okay, so therefore, for this kind of backing store as it's pretty straightforward. You just write it back to the file system hierarchy now. 412 00:56:14.490 --> 00:56:26.070 William Cheng: Then, as it turns out, we need support this type of backing store. OK. So the reason, read the read only mapping of our and also the rewrite share mapping the file because the back end store is the file system hierarchy. Yeah. 413 00:56:27.900 --> 00:56:36.450 William Cheng: What about the rewrite private mapping of a file. Okay. So in this case, these patients are coming from this file. Once you modify them. They are managed by the shadow object. 414 00:56:37.050 --> 00:56:42.930 William Cheng: Okay, so if the patient has to be modified right now, once they are modified. Can you write it back to the file system hierarchy. 415 00:56:43.140 --> 00:56:51.360 William Cheng: While you're not allowed to do that. Right. So in this case, they need to go to go to the spa space. Yeah. So in this case, we need to allocate spa space. Again, we're going to use an anonymous object, the 416 00:56:51.750 --> 00:56:59.010 William Cheng: Object is the one that know where this data will go into the swap space. And later on, you know, if you decide to bring this process back from, you know, from the desk. 417 00:56:59.250 --> 00:57:03.570 William Cheng: Or the anonymous object with us to get the data from this and then copied into memory. Yeah. 418 00:57:04.080 --> 00:57:16.770 William Cheng: Similarly, you know the the other memory segment. I'll be here like the BSS segment and the segment on the show and maybe some of the ship me, second one over here out of my private. Right. So in this case, again, you know, what will 419 00:57:19.140 --> 00:57:26.340 William Cheng: The one that's inside BSS and once it's out of stock. They didn't come from the file system, so therefore we should have swap them out. You can't have a go to the bosses that 420 00:57:26.550 --> 00:57:31.920 William Cheng: They have to go into the spa space. So this is, again, this will be another backing store that needs to go into the small space. 421 00:57:32.130 --> 00:57:45.060 William Cheng: They need to be managed by the anonymous object. So the shadow object over here and manage your memory that needs to go into the sauces. Similarly, the anonymous objects over here also need to you know need. They need to be able to swap them out into space. 422 00:57:46.440 --> 00:57:52.980 William Cheng: Alright, so, so, again, the things that are associated with a file object. Those are the first kind that they can write it into the file system hierarchy. 423 00:57:53.490 --> 00:58:01.590 William Cheng: For all the other kind of backing store either coming from the shadow object or coming from the anonymous object, the backing store will be inside this office yet. 424 00:58:02.790 --> 00:58:09.600 William Cheng: Alright, so we need doesn't support this type of backing store because the toy operating system. Right, so, so, so in this case, how do you prevent the page or demon 425 00:58:09.930 --> 00:58:19.980 William Cheng: For freeing up this page rank accidentally right because remember the page document what they will do is that it will go through the list of pastry. I'm over here, pick out which one is not recently used and try to free them up. 426 00:58:20.790 --> 00:58:27.720 William Cheng: Okay, so in this case before they free them up. They need to copy them back onto the desk. What if it's one of these patients over here. Where do you ride them under the desk. 427 00:58:28.380 --> 00:58:37.260 William Cheng: Okay. So, therefore, what you have to do. So you have to play hide and seek with the page ADINA the paste render describe over here, they should never be found by the page or demon 428 00:58:38.280 --> 00:58:50.250 William Cheng: Okay, so therefore in Phoenix, what they do over here is that they will pin this page frame where you pick the space, right, you're going to remove this page rank from the beta structure that can be found by the by the page on demand, and then you hide it in 429 00:58:50.820 --> 00:58:53.430 William Cheng: In you hire them into another link list. 430 00:58:53.970 --> 00:58:59.370 William Cheng: Okay, so therefore, when the page. I didn't try to scan for patient, it will not be able to find out. Do you not be able to find this page rank. 431 00:58:59.580 --> 00:59:04.680 William Cheng: The page or demon will only be able to find out the first kind of Patreon and in this case it will know how to write it into the back end store. 432 00:59:05.340 --> 00:59:10.920 William Cheng: Okay. All the other ones over here, there are hidden from the page on demand. So this is what you have to implement paper and pen. 433 00:59:11.400 --> 00:59:21.150 William Cheng: Right paper and pen is to take a pastry remove it from the data structure that can be found by the page it man. And then, you know, append them to a different list. 434 00:59:21.570 --> 00:59:28.380 William Cheng: Another one you over here. Copy friend on pin you take that patient from the hidden list and you return back into the data structure and now the piece. 435 00:59:28.890 --> 00:59:31.020 William Cheng: The piece on demand. I can find these patients. 436 00:59:31.710 --> 00:59:39.180 William Cheng: OK. So again, these functions are pretty, pretty simple to implement or the difficult. One is the p for and get by the people don't get is that you are given a 437 00:59:39.510 --> 00:59:47.610 William Cheng: You're given an emo BJ you're getting a page number, you need to find this particular patient gas. Oh yeah, the P for and get the similar to be get 438 00:59:47.970 --> 00:59:56.730 William Cheng: That so India. India would you need to do is I need to find it. If you cannot find it. You need to create a new page rank. Okay, so keep that in mind when you try to implement people and get them. 439 00:59:58.320 --> 01:00:09.000 William Cheng: All right, so, so to implement spa space, you know. So again, this is you know again on the desk over here. There's one space over here called the spa space. Okay, so how do you actually manage this loft space. 440 01:00:09.300 --> 01:00:15.270 William Cheng: Okay, there are two different approach of doing that. One is a radical and conservative approach that's based on ego evaluation. 441 01:00:15.690 --> 01:00:25.200 William Cheng: The other one is the radical the liberal approach called lazy evaluation. So some people also call them the first approach over here going to be a pessimistic approach and the second approach over here is going to 442 01:00:28.080 --> 01:00:39.450 William Cheng: The second approach over here is going to be the optimistic approach there. Alright, so let's talk about the first approach over here, this is based on ego evaluation. So often is that every time, will you allocate a new page right 443 01:00:40.050 --> 01:00:51.030 William Cheng: When we allocate a new page for him and this patient needs to go out into the spa space. So what we need to do is that we need to determine where this patient needs to go instead of swap face. Alright so today we have anonymous object over here. We also an 444 01:00:51.420 --> 01:00:59.910 William Cheng: Object. We also have the shadow object whenever they create a new page rank, right, whenever you get a copy on a call we perform copy on write you make a copy of that patient. 445 01:01:00.150 --> 01:01:04.410 William Cheng: That patient in case, our process needs to be swapped out needs to go into this office. 446 01:01:05.100 --> 01:01:11.070 William Cheng: Okay, so at the time when this patient is creator, we need to find out where it goes. And then we need to remember them inside a shot object. 447 01:01:11.370 --> 01:01:20.280 William Cheng: Then similarly we should create a new patient, you do not have this object over here, we need to figure out where it goes. Is that a soft face and inside anonymous object. We need to have a pointer pointed his office. 448 01:01:20.880 --> 01:01:33.060 William Cheng: Okay, so this is known as eager evaluation as soon as you create this patient. I'm over here, then you need to allocate space. And then, you know, you know, figure out your data structure. So this way you're patient and always have a place to go. Just in case your processes swapped out 449 01:01:34.080 --> 01:01:41.400 William Cheng: Okay, so. So in this case, what, what can actually happen right it is possible. You know, you can actually run out of space. 450 01:01:42.120 --> 01:01:43.470 William Cheng: Okay, so, you know, some of you know 451 01:01:43.770 --> 01:01:54.420 William Cheng: On your laptop you're running like 50 different processes. Some of them are very aggressive they allocate memory over here. So every time we call Malik. It is possibly going to end up with a new page frame we end up with a new page rain. 452 01:01:54.930 --> 01:02:08.070 William Cheng: In this case you will allocate a soft face. Okay, so if you're running simulation, you know, like BLS I simulation or something like that. You have a merry heart, pretty soon you're gonna run out of space. So in that case, where you're running your user program Malik can actually fail. 453 01:02:09.600 --> 01:02:20.520 William Cheng: Okay, so, so again, in this case, why would matter, right. So typically when you think about Malik fail is because I've memory corruption bug. It is also possible we call Malik Malik will fail because you run out of sua space. 454 01:02:21.030 --> 01:02:30.630 William Cheng: Right, so why would you run out well so well. So in that case, why would Malik fail is because we are doing eager evaluation. Right. So as soon as we allocate a new page where we need to find a place to swap to 455 01:02:30.840 --> 01:02:34.920 William Cheng: Whatever. There's no sauce as well, in that case, Malik will fail. Okay. Is that good. 456 01:02:35.910 --> 01:02:42.300 William Cheng: I mean, if your application programmer, you're going to be pretty upset right you said my program is perfect. Why would Malik fail because I run a small space. 457 01:02:42.870 --> 01:02:51.180 William Cheng: Okay, so that's really not good to get that there's another approach over here called lazy evaluation. So when you do evaluation we call Malik we generate a new page rate. 458 01:02:51.360 --> 01:02:59.400 William Cheng: You're going to be optimistic are you say that you know by the time I'm going to swap out to the swap says my program will be done. I will quit my program. I will 459 01:02:59.670 --> 01:03:03.780 William Cheng: Actually free up our page for him. So therefore I will never required to use this last race. 460 01:03:04.530 --> 01:03:14.430 William Cheng: Okay, so, so there was this case, I'm going to do the space of lazy evaluation. I'm going to delay the allocation of the spa space over here to be the last possible moment right what is going to be the last possible moment. 461 01:03:15.000 --> 01:03:21.810 William Cheng: Or the last possible moment is when your process getting swapped out so we process getting softer over here, then you look to see where you need to swap out onto the desk. 462 01:03:22.740 --> 01:03:35.700 William Cheng: Okay, so again this is, you know, it's a very radical the liberal approach it based on, you know, lazy evaluation and then you're trying to be optimistic because most likely my process will never get swapped out to this. So, therefore, I don't have to waste time allocating soft as 463 01:03:36.720 --> 01:03:40.230 William Cheng: Their as it turns out, what if you're unlucky right you'll be optimistic. What if you're actually 464 01:03:40.380 --> 01:03:48.420 William Cheng: Unlucky. You know when your, your process eventually is going to get swapped out where you're getting swapped out turns out that there's no swaps at this one phase actually used up by the memory hog. 465 01:03:49.710 --> 01:03:51.750 William Cheng: Okay, so you're not going as well. What can you do 466 01:03:52.200 --> 01:04:02.310 William Cheng: Well, so in that case, you know, if I want to swap your process out because you know you haven't been running for a while. I need to swap you out and now there's no slots as the operating system has no choice but to kill your program. 467 01:04:03.300 --> 01:04:03.990 William Cheng: There is that good. 468 01:04:04.440 --> 01:04:06.120 William Cheng: I mean, you are the owner of this process. 469 01:04:06.330 --> 01:04:11.280 William Cheng: Now this is even worse than, you know, Malik will return now, right, because now, Richard know you can actually check it will return now. 470 01:04:11.430 --> 01:04:19.050 William Cheng: They've been returned. Now you can actually say, well, your work and and do all that kind of stuff. But now, well you perform the swap operation. Your promos, not even running and all of a sudden your programs dead. 471 01:04:20.070 --> 01:04:27.510 William Cheng: Okay, so the the the radical liberal approaches actually is very, very, very, very aggressive. Okay. So in the end, you know you your problem will just die for no reason. 472 01:04:28.050 --> 01:04:30.930 William Cheng: Because again, both approaches over here plus and minuses. 473 01:04:31.620 --> 01:04:38.910 William Cheng: Some people actually, you know, sort of implement something in between. So why because that way you create a new page read what he will do is that they want to reserve a paste rain. 474 01:04:39.450 --> 01:04:47.010 William Cheng: They will reserve patient instead of spa space, even though they don't know which page rank it says, Okay, you have sua says over here inside your is our discovery or swap 475 01:04:47.280 --> 01:04:56.520 William Cheng: When you make a reservation. You just need to make sure that their space inside your space, you don't actually go, go to the sources and sort of service or to figure out which one is going to be assigned to you. 476 01:04:57.270 --> 01:05:00.960 William Cheng: Okay, so that's like reserving a car right we reserve a car. Do you know which are you going to get 477 01:05:01.470 --> 01:05:10.680 William Cheng: WELL, YOU DON'T KNOW RIGHT, ALL YOU DO IS reserve a car when you go to the airport. You mentioned, we tend to pick up a car only at that time, you, you, you, you actually you're going to know exactly what will 478 01:05:11.340 --> 01:05:12.810 William Cheng: Which which are you going to get 479 01:05:13.230 --> 01:05:19.200 William Cheng: Bigger so we can do the same thing when you try to come, Allah you create a page and all you do is to keep track of how big is the soft size. 480 01:05:19.380 --> 01:05:31.290 William Cheng: How many, how you know how in this book are left. So in this case I will make a reservation. I don't know which one it is. Eventually what you know when it when it's time I guess what, though, at that time, I know there's going to be enough spa space. So therefore I the 481 01:05:31.800 --> 01:05:39.390 William Cheng: Therefore, I will be up to be able to allocate will allocate one for kindle I page and then I did, I can actually go into the spa space. 482 01:05:40.110 --> 01:05:46.470 William Cheng: Okay, but it's still possible that that when I call Mela going to want to call Malik. I tried to reserve us, you know, 483 01:05:47.280 --> 01:05:48.840 William Cheng: We serve patients that I saw space. 484 01:05:49.050 --> 01:05:58.410 William Cheng: The swastika will be out. So therefore, in this case, Malik was still in return. No, but again, I'm reasonably happy over here because I know that around. I saw space. So, therefore, you know, whenever you call Malik. 485 01:05:58.590 --> 01:06:04.710 William Cheng: You have to check the return address. Don't assume that you know because they're programmed to use too much memory you don't have to check the return address. 486 01:06:05.760 --> 01:06:15.810 William Cheng: Alright, so again I think windows actually implement this particular approach you know so. So again, the windows that they will try to accommodate all kinds of systems out there. 487 01:06:18.150 --> 01:06:21.510 William Cheng: All right, Linux memory allocation. Oh, Peter. I'm going to skip that. 488 01:06:22.710 --> 01:06:27.090 William Cheng: Alright so I'm dealt with chapter seven. So now you have everything you need to know enough to to the employment. 489 01:06:27.690 --> 01:06:32.220 William Cheng: episode that you also know that you that you we need. We don't have a spa space. 490 01:06:32.760 --> 01:06:44.340 William Cheng: So next time I'm gonna, you know, so it's not we finished chapter seven, right, we're not going to go back to our lectures web page look at the first we're going to look at the after chapter seven and then look at all the other parts. Okay. All right.