WEBVTT 1 00:01:27.600 --> 00:01:28.860 William Cheng: Welcome to lecture. 2 00:01:41.880 --> 00:01:44.190 Lalit Gupta: Yeah. So hello professor. So I have a question in 3 00:01:45.600 --> 00:01:48.540 Lalit Gupta: The ancient in the VM map artsy 4 00:01:49.440 --> 00:01:51.720 William Cheng: Okay, let me switch screens to it. 5 00:02:02.520 --> 00:02:02.850 OK. 6 00:02:04.470 --> 00:02:08.400 Lalit Gupta: So the function of the math, science range. 7 00:02:09.270 --> 00:02:12.570 William Cheng: Okay, right. So that's the first fit algorithm. Yeah. 8 00:02:13.440 --> 00:02:14.100 Lalit Gupta: Yeah, so 9 00:02:15.780 --> 00:02:17.130 Lalit Gupta: So i don't i 10 00:02:18.150 --> 00:02:29.190 Lalit Gupta: Like, from what I understand is, we have a p. So we have a VM media and via media has a memory object and the memory of people, a lot of famous and that has pages inside it. 11 00:02:30.780 --> 00:02:39.990 Lalit Gupta: And so I thought, I thought, is when when the all the speakers are actually not free. If they are actually on this memory object. Right. 12 00:02:40.500 --> 00:02:44.430 William Cheng: Right, so the free the free spaces between the the memory segments. 13 00:02:47.340 --> 00:02:47.520 Lalit Gupta: Which 14 00:02:47.730 --> 00:02:48.420 William Cheng: Is kind of like the 15 00:02:48.630 --> 00:02:57.600 William Cheng: The sort of the opposite of the first fit algorithm that we talked about in chapter three. So, in chapter three. We keep track of the free blocks. 16 00:02:58.830 --> 00:03:03.150 William Cheng: So, so this first trade was that we would keep track of the allocated blocks. 17 00:03:07.710 --> 00:03:16.590 Lalit Gupta: Okay, so. Okay, so yes. Okay. So, so you're saying we have to be the know that whatever the whatever the whatever the region that is allocated. 18 00:03:17.070 --> 00:03:17.670 Lalit Gupta: And from 19 00:03:17.820 --> 00:03:21.810 Lalit Gupta: That we can somehow subtract out and find out what digits are free. 20 00:03:22.470 --> 00:03:24.930 William Cheng: Yeah, so anything between them. They're all free. Right. 21 00:03:27.270 --> 00:03:32.580 Lalit Gupta: Okay and. Okay, so those are not. Those are not those area do not have any 22 00:03:34.890 --> 00:03:37.560 Lalit Gupta: Pages allocated to it. So, so 23 00:03:38.670 --> 00:03:40.950 William Cheng: What is their allocate and then there's a VM area. 24 00:03:45.480 --> 00:03:48.660 Lalit Gupta: Wait. Now if I, if you 25 00:03:50.190 --> 00:04:06.480 Lalit Gupta: If you have a VMware. Yeah. And then we have the media gives us a range of range of address right and does the all that's all the range in the address has to have some patience associated with it. 26 00:04:06.750 --> 00:04:16.770 William Cheng: Was a memory segment. It's continuous, you know, virtual addresses. Right. So is that a VM area. There's no holes inside of that, but between the areas where the holes. 27 00:04:21.750 --> 00:04:27.150 Lalit Gupta: Oh, okay. So, seems like we we have to find a place the 28 00:04:29.010 --> 00:04:31.920 Lalit Gupta: Address started from the lake. 29 00:04:34.170 --> 00:04:39.030 Lalit Gupta: Yeah, we have to find a address which has no via media associated with it. 30 00:04:39.660 --> 00:04:39.900 William Cheng: Right. 31 00:04:39.930 --> 00:04:41.670 William Cheng: Right, so find find the, you know, 32 00:04:43.380 --> 00:04:44.820 William Cheng: You know, find the space in the gap. 33 00:05:01.800 --> 00:05:03.030 Lalit Gupta: I'm sorry, but 34 00:05:03.240 --> 00:05:08.220 Lalit Gupta: Yeah, yeah, what you're saying is making sense. But I just want to read it one more time so that 35 00:05:09.090 --> 00:05:17.490 William Cheng: For example, I over here. I'm going to sort of type example. Right. So, for example, one of the VMware is go from 10 1112 right so that's, you know, 36 00:05:18.000 --> 00:05:33.810 William Cheng: You know, a three at length of three pages, right, and then the next one is 15 1617 1819 so that's another one, five right and then followed by 500 by 100 and 102, you know, etc. So in this case, 37 00:05:34.200 --> 00:05:45.630 William Cheng: You know there are 10 pages at the beginning between zero and and and and before 10 right and then there's 13 and 14 so there's another empty space that's two pages long. I'm sorry. 38 00:05:46.440 --> 00:06:07.680 William Cheng: 1342 pages long. Right. And then, between these two. There's another gap that's, you know, you know, 500 minus 20 that's 480 pages long. And then at the end, compile three all the way to the end, the memory. There's another you know a free free 39 00:06:08.970 --> 00:06:09.570 William Cheng: free range. 40 00:06:10.710 --> 00:06:22.200 Lalit Gupta: Yes. Okay, so free range makes sense because the free version is next lesson, because these are the other places where it's a we do not have any virtual because pages means like 41 00:06:23.550 --> 00:06:30.120 William Cheng: Was born into this picture right. The, the, you know, the virtual page number zero to nine nobody's using it right 42 00:06:31.890 --> 00:06:40.860 William Cheng: And then from reversal page 13 and 14 there's no you know nobody using. So again, we can think about them as individual pages or it's easier to think about as 43 00:06:41.250 --> 00:06:51.720 William Cheng: As a range rather you have a beginning number and a link right and then over here, there's another range. You can also say that all these individual pages. They're all available if on 2021 all the way to 499 44 00:06:52.920 --> 00:06:53.760 William Cheng: It's the same thing. 45 00:06:54.750 --> 00:06:55.980 Lalit Gupta: Okay, yeah. 46 00:06:56.460 --> 00:07:00.690 Lalit Gupta: Even though I understand the structure to represent them right so 47 00:07:02.580 --> 00:07:13.080 Lalit Gupta: Okay, even though I understand. I feel like because pages slightly confusing because I always think that pages associated with the page frame and that is actually managed by a memory object. 48 00:07:13.950 --> 00:07:26.700 William Cheng: Well, it's because every patient can have many, many versions of it right so that's why things get complicated, right, because of copy on write all that kind of stuff. So, you know, so, so things are more complicated inside the operating system. 49 00:07:28.500 --> 00:07:32.490 Lalit Gupta: Okay, so I think there's no further than 50 00:07:35.610 --> 00:07:36.330 Lalit Gupta: And my next 51 00:07:37.560 --> 00:07:40.380 Lalit Gupta: Yeah, so they don't function in a VM map, map. 52 00:07:42.930 --> 00:07:49.050 William Cheng: Right, so that one is the one that I just answer some question in class move this morning. Yeah. 53 00:07:49.740 --> 00:07:51.900 William Cheng: So many, many arguments. 54 00:07:52.440 --> 00:07:55.350 Lalit Gupta: Yeah, can you go, can you can you start at the beginning of the moment. 55 00:07:57.600 --> 00:08:02.070 William Cheng: So, so again, this is the function that used to map a file into address space. 56 00:08:03.270 --> 00:08:05.460 William Cheng: So therefore you build a memory segments from a file. 57 00:08:07.380 --> 00:08:10.590 Lalit Gupta: Yeah. So it seems like it is. It will give us some 58 00:08:11.880 --> 00:08:23.940 Lalit Gupta: Location number and from that low page. And it also gave us pages to from that we can find a range that is not located that that is that that do that has no associated VM area with it. 59 00:08:24.480 --> 00:08:37.710 William Cheng: Wasn't like the example that I gave right 1011 right. So, so, you know, so you might end up with a so so when this one is done. So let's say that when this function is returning, you're going to have, you know, 10 1111 and 12 60 00:08:39.510 --> 00:08:44.550 William Cheng: Okay, so you'll build a memory map that's three pages long. Right now, that will be the result of this 61 00:08:46.410 --> 00:08:48.150 William Cheng: So in this case, I think, low page. 62 00:08:48.510 --> 00:08:53.130 Lalit Gupta: I cannot have 10 1112 because you already. We already have a VM media for 1011 63 00:08:53.490 --> 00:08:58.740 William Cheng: We'll start with the empty wine. So, you know, maybe this is the function, you are used to build the first 110 1112 64 00:08:59.430 --> 00:08:59.730 Okay. 65 00:09:03.180 --> 00:09:08.010 William Cheng: I think know page is a virtual page number so it will be 10 right and pages will be able to three right 66 00:09:11.070 --> 00:09:16.800 Lalit Gupta: Yes. So let's say we have a non do page. And it's, I think there's a comment in the same paragraph. 67 00:09:18.120 --> 00:09:18.930 William Cheng: Zero page. 68 00:09:19.140 --> 00:09:27.300 Lalit Gupta: If the low pages non do and specified region countries and other mapping, then that mapping should be unmapped 69 00:09:27.720 --> 00:09:27.990 William Cheng: Right. 70 00:09:28.020 --> 00:09:31.980 William Cheng: Yeah, so does the because so. So again, what's important to understand is that in the end. 71 00:09:32.850 --> 00:09:38.610 William Cheng: You know, the memory segments can overlap. Right. So if you try to map something in the memory and there's something already there. You have a map. The first 72 00:09:40.020 --> 00:09:42.300 Lalit Gupta: Basically, we have to remove that the media and 73 00:09:44.760 --> 00:09:46.890 William Cheng: You have to. You don't have to remove it, you need to 74 00:09:47.220 --> 00:09:49.950 William Cheng: You need to shrink it so that they don't overlap anymore. 75 00:09:53.640 --> 00:09:57.540 William Cheng: You don't necessarily have to remove it. Right, there's an overlap, you get rid of the overlap. 76 00:09:57.660 --> 00:10:07.470 Lalit Gupta: Yeah, if there's overlap, which we shrink shrink it or remove that part that is the overlapping part or shrinking you're removing that part which is overlapping 77 00:10:07.860 --> 00:10:17.520 Lalit Gupta: Right. And then, that part is now not being used by any memory. After we do that process and then we can create a 78 00:10:19.290 --> 00:10:20.160 Lalit Gupta: VM area. 79 00:10:21.300 --> 00:10:23.760 Lalit Gupta: For that for that range of actress. 80 00:10:23.850 --> 00:10:24.270 Correct. 81 00:10:27.180 --> 00:10:29.700 Lalit Gupta: Oh me know 82 00:10:31.980 --> 00:10:48.990 William Cheng: Right. So in this example. So let's uh, let's say that I already have a have a VM area that go from 10 1112 right okay so if I called VM M AP and low page equal to 10 and then n pages equal to three. I need to wipe out this entire area before and then build a new one. 83 00:10:49.980 --> 00:10:50.820 Lalit Gupta: Yes, yes. 84 00:11:00.660 --> 00:11:04.380 Lalit Gupta: And there's a comment. I think in this second paragraph, use the 85 00:11:05.640 --> 00:11:06.270 Lalit Gupta: vino 86 00:11:07.470 --> 00:11:18.210 Lalit Gupta: vino vineyard and map operation to get the MO, which are for the file it say now. Do not assume that it is file underscore VR ops. Why, why, why would it not be the case. 87 00:11:21.660 --> 00:11:35.970 William Cheng: Over here, this was this file is no the file is no and I'm not sure views in file is not know that Venus file will be mapped from the given range. Use the Venus. So let's take a look at that function. Where is that 88 00:11:37.050 --> 00:11:41.790 William Cheng: FS VN this one right. Is there a map function. 89 00:11:52.560 --> 00:11:53.400 William Cheng: Operation. 90 00:11:56.580 --> 00:11:57.060 Lalit Gupta: Operation. 91 00:12:03.240 --> 00:12:15.240 William Cheng: Okay, so over here. Yeah. So there's the one of the function over here is is a map right so i think it's asking you to use that for you. So let's take a look at the SV is this called does see 92 00:12:22.290 --> 00:12:26.730 William Cheng: So it's all in Vino de see Colonel FS vino see 93 00:12:30.990 --> 00:12:33.660 William Cheng: Okay, so there's read, and then there's right 94 00:12:43.380 --> 00:12:43.860 William Cheng: Special 95 00:12:55.980 --> 00:13:03.240 William Cheng: Okay. So inside the know there's a ray of function point or you're supposed to use the map function there to to do the operation now. 96 00:13:04.860 --> 00:13:06.120 William Cheng: Because others. 97 00:13:06.750 --> 00:13:13.740 Lalit Gupta: Yeah, so that I understand that you have to use this operation to get the memory object using that function. 98 00:13:13.950 --> 00:13:16.290 William Cheng: Yeah, we just got to trust that it works. And we just call it. Yeah. 99 00:13:18.120 --> 00:13:27.210 Lalit Gupta: Yeah, yeah. So this apart. I understand. But why I was just trying to just see why why they are, why they're stressing that do not assume that it is 100 00:13:27.750 --> 00:13:41.460 Lalit Gupta: File under arrow we have that memory of. Okay, so there will be an empty object that will be determined by this function and and there is also a member of that that is file. We are both our memory object. 101 00:13:42.690 --> 00:13:44.700 Lalit Gupta: What is the difference between too distant memory. 102 00:13:44.940 --> 00:13:51.090 William Cheng: Well, I think in the wind is kind of there's some other you know mmm LBJ code that's written for you that you don't know what they are. 103 00:13:51.540 --> 00:13:58.380 William Cheng: I think in the device driver. There's some other mm will be J. And sometimes those are the one that you have to use, right, for example, you don't want the map. 104 00:13:59.220 --> 00:14:09.270 William Cheng: Map of file into address space, you know, there's, I think there's the block device. And then there's a character device. So I think when you try to transfer data from the file into 105 00:14:09.750 --> 00:14:18.600 William Cheng: Memory, you have to use a block device, but we you know we didn't write the code there. So, so, you know, we should just, you know, sort of follow using the polymorphous in principle, just follow the pointer there. 106 00:14:21.090 --> 00:14:26.640 William Cheng: Cool. So, so there are other mo BJ that we don't that we don't write whether we can ride. 107 00:14:29.790 --> 00:14:35.550 Lalit Gupta: On I think I had related note, can you also go to this P frame dot c data essential function. 108 00:14:37.320 --> 00:14:40.470 William Cheng: Or no mmm keyframe that see 109 00:14:44.490 --> 00:14:45.090 William Cheng: Yes. 110 00:14:46.290 --> 00:14:47.580 Lalit Gupta: So here 111 00:14:48.690 --> 00:14:53.340 Lalit Gupta: We have SPP and MSP frame of jack, we get this memory of 112 00:14:54.390 --> 00:14:56.820 Lalit Gupta: From the speaking, we get a memory object. 113 00:14:57.150 --> 00:15:00.690 Lalit Gupta: Right and and memory and 114 00:15:03.330 --> 00:15:08.430 Lalit Gupta: Yes. And that has some operations available and we are calling Phil page. 115 00:15:09.840 --> 00:15:18.120 Lalit Gupta: And then we are giving the map, the Philippines X amount of the object. And I think that pitch him probably 116 00:15:20.040 --> 00:15:21.180 Lalit Gupta: I'm trying to understand 117 00:15:23.850 --> 00:15:37.140 Lalit Gupta: Is it, is it possible that this the argument that this object in the argument filthy document beef zero PM underscore opt and the the the 118 00:15:38.940 --> 00:15:43.950 Lalit Gupta: The function pointed out is that we are using PF underscore piece of data can be different. 119 00:15:45.390 --> 00:15:47.070 William Cheng: Yeah of course it's polymorphous than yeah 120 00:15:48.660 --> 00:15:57.150 William Cheng: So, so remember every page rank is identified by two things, right, the MO BJ that owns it, and also a page now. Right. Remember that 121 00:15:57.780 --> 00:16:15.210 William Cheng: Yes. Okay, so, so if you look at a PDF right over here. PM, right arrow PF LBJ right and then PDF of a PDF page now. Right. So if you use these to as the key, you will find the object. Right, so, so, so every page, page frame has a self identifying information that's stored inside of data structure. 122 00:16:16.470 --> 00:16:21.600 William Cheng: Okay, so therefore you can always just go to the object over here to find out you know which object actually own this page rank. 123 00:16:22.410 --> 00:16:32.670 William Cheng: Okay, and then you will. So in Colonel three, the kind of obviously you have to deal with is the one that's inside the vino and also there is the one that is the anonymous object. This is shut off yet. 124 00:16:33.540 --> 00:16:37.050 William Cheng: So if you want to fill the page with data, all you need to do is to call the Philippines function. 125 00:16:40.380 --> 00:16:45.420 William Cheng: Right over here, this function is called fill a page frame right okay we tried to fill a page frame. 126 00:16:45.990 --> 00:16:53.130 William Cheng: But depends on what kind of object it is there's a different function. They used to call. So therefore, we call the polymorphous to paste function. 127 00:16:53.700 --> 00:17:04.920 William Cheng: And then if it turns out that this is anonymous object then anonymous Phil page will get called if this one is the shadow object and shadow Phil page with your colleagues, but this one is the one the vino then the V read page will get called 128 00:17:19.290 --> 00:17:24.030 William Cheng: Does that make sense. Did you want to fill the page different ways, right, because, I mean, clearly, if you want to fill the page on the desk. 129 00:17:24.420 --> 00:17:32.100 William Cheng: You have to use a different operation. If you want to fill the data from anonymous, then you just create a page Twitter page, fill it with zeros. 130 00:17:32.610 --> 00:17:40.710 William Cheng: If you want to fill the page with a foreshadow object, you have to do the, you know, copyright, you have to find it. And you have to copy it. So they're all they're completely different. 131 00:17:43.980 --> 00:17:47.730 Lalit Gupta: Yes. So say we have a mess. Stevie because 132 00:17:48.840 --> 00:18:00.270 Lalit Gupta: I think, I think you are asking in relation to this, there is a function and an object. So sometimes we are already given a memory object and we have to we have to fill the page. 133 00:18:02.610 --> 00:18:11.010 Lalit Gupta: So do we have to call that filthy, filthy operation of that object that is given to us. 134 00:18:11.700 --> 00:18:20.160 William Cheng: Well, it depends on you know who's code that you're writing right if he already had an anonymous function that you know the object is anonymous function. Right. So in that case, you can just directly 135 00:18:20.460 --> 00:18:28.950 William Cheng: You know, you can call whatever function that's inside of web, but at this level where you know when somebody has a page rain is it filled with data, but they don't even know what kind of page frame it is right. 136 00:18:29.580 --> 00:18:37.320 William Cheng: Yes. Well, in that case you need to call a higher level function because high low function will use appalling morphic pointer to to to to to to sort of deal with how to 137 00:18:37.710 --> 00:18:46.410 William Cheng: How to fill a page right because filling a page we needs to be, you know, sort of a memory object mmm object independent way to Philip, Philip pace. Right. 138 00:18:47.490 --> 00:18:51.900 William Cheng: Right. So if you're doing something that's independent of the mm object. Well, then in that case you will call this function. 139 00:18:56.610 --> 00:18:58.050 Lalit Gupta: Starting this multi objective. 140 00:19:00.090 --> 00:19:06.450 William Cheng: Is that are really means is that if you have a page frame, you don't really know what kind of what it is because the polymer prism right 141 00:19:07.560 --> 00:19:17.940 William Cheng: So they will all you have to do is to call the function right over here says why this is how you call the function and then you trust that you know if everything is set up correctly, while then the in this case the right, the right function will be called 142 00:19:48.000 --> 00:19:54.930 William Cheng: You know, like the example that I gave in class. Right. That's a you have a disk up Jaguar you tell this object to say read data from the data into memory. 143 00:19:55.350 --> 00:20:02.850 William Cheng: He said, well, but I don't know what kind of disk it so it doesn't really matter. You just, you just use that this point or call a function and then you know polymorphous and we'll take care of it. 144 00:20:06.060 --> 00:20:18.030 William Cheng: So this is the same situation. I have a page frame, I need to fill it. I don't know what kind of pays for him. It is. It's okay, just call the palm of a function and then the right, the right kind of stuff will happen. I mean, assuming that all the pointers are set up correctly. 145 00:20:27.660 --> 00:20:34.140 William Cheng: Okay. So, by the way, you know, for this code. If you set a breakpoint. A P frame fill or set a breakpoint right on this line. Okay. 146 00:20:34.920 --> 00:20:47.970 William Cheng: Will you get there you can actually print use a print PM, right arrow pa pa or BJ. And then, and then you know. Mm, oh underscore OBS it will actually tell you what functional will call 147 00:20:49.440 --> 00:21:01.980 William Cheng: It will say anonymous filters over here. It's a real function pointer. Right, so it will actually show you that this one is this one Billington anonymous object is one bill to the shadow object. This one belongs to the by device to help us even show that 148 00:21:03.090 --> 00:21:08.460 William Cheng: You know, so, so, so, so set a breakpoint here and that you can actually see what kind of, you know, a real function point you get 149 00:21:10.080 --> 00:21:10.350 Lalit Gupta: Oh, 150 00:21:13.770 --> 00:21:24.540 William Cheng: Russia remember all these functions. They all these functions are in the data structure. So when you print PLP LBJ mmm LPS they are you going to get that the name of that a real function pointer. 151 00:21:32.310 --> 00:21:38.880 Lalit Gupta: Sometimes what happens is if you if you were to this this which which fine. 152 00:21:40.800 --> 00:21:46.680 Lalit Gupta: I think it's VM memorable ops are underscore upstart see we are we have to pee French 153 00:21:50.160 --> 00:21:51.060 William Cheng: Colonel 154 00:21:52.590 --> 00:21:53.490 Lalit Gupta: Colonel Fs. 155 00:21:54.390 --> 00:21:55.050 William Cheng: SF s 156 00:21:56.070 --> 00:21:56.730 Lalit Gupta: in Malmo 157 00:21:57.060 --> 00:21:59.310 Lalit Gupta: One. Yes. Okay. 158 00:22:00.360 --> 00:22:01.110 Lalit Gupta: If you look at this 159 00:22:01.290 --> 00:22:04.080 Lalit Gupta: Maybe we dirty page something in this 160 00:22:04.620 --> 00:22:05.160 William Cheng: Dirty page. 161 00:22:06.000 --> 00:22:15.930 Lalit Gupta: Yes. In this case, we have this because of that the frame itself has a memory object. And now we are also having another memory object so 162 00:22:18.090 --> 00:22:25.800 William Cheng: Yeah, so, so I think P frame PF underscore LBJ, I think it's equal to em, they're the same thing. 163 00:22:27.090 --> 00:22:27.870 Lalit Gupta: Oh dear. Same thing. 164 00:22:28.320 --> 00:22:37.170 William Cheng: I think so. Okay, remember every page frame inside of a store self identifying information which M. O. B data belongs to. And also, what is the page now. 165 00:22:38.340 --> 00:22:41.160 William Cheng: Okay, so, so, so this is I, you know, 166 00:22:41.520 --> 00:22:45.240 William Cheng: It will kind of make sense that you will use the same object is what is IP for it. 167 00:22:46.320 --> 00:22:48.090 Lalit Gupta: Yeah, that makes makes sense so 168 00:22:48.180 --> 00:22:58.200 William Cheng: If you want to make sure you can add another you can add another line over here i k assert obsesses a kisser PDF. PDF LBJ 169 00:23:00.060 --> 00:23:01.410 William Cheng: Equal. Oh. 170 00:23:02.970 --> 00:23:04.050 Lalit Gupta: Yes. 171 00:23:04.140 --> 00:23:13.860 William Cheng: Again, you know, you want to make sure that they're the same. You can just add a concert. So this way if it turns out that's not true. You're going to crash and then then they, you know, OK. 172 00:23:16.020 --> 00:23:20.640 Lalit Gupta: OK, I think. So this to me. Try to look this way. Okay. 173 00:23:21.660 --> 00:23:33.750 William Cheng: Yeah, so, so for your for the vino I'm pretty sure that the Wii and ops over here. So again, if you set a breakpoint right here. I could print be an ops. I think that will be the the by device array of function pointers. 174 00:23:35.220 --> 00:23:43.350 William Cheng: OK. OK. So I think, whereas the colonel drivers right device to see 175 00:23:48.210 --> 00:23:51.120 William Cheng: Her know maybe it's in Vino de see 176 00:23:52.620 --> 00:24:08.400 William Cheng: Yeah, here's the by device right array of function pointer is you know so. So what we do is that, the better you will. I think you will see the name of this real function pointer is by dev spec VR Ops or something like it is a device. 177 00:24:14.100 --> 00:24:16.410 William Cheng: Yeah, I think a vino can be represented a, you know, 178 00:24:18.750 --> 00:24:19.980 William Cheng: Sort of a keyboard device. 179 00:24:22.350 --> 00:24:27.180 William Cheng: That this device, you know, but at the higher level. It's either character device or a block device. 180 00:24:28.800 --> 00:24:29.310 Lalit Gupta: Okay. 181 00:24:30.600 --> 00:24:34.110 Lalit Gupta: But we didn't write all those code because those codes are in, you know, 182 00:24:34.140 --> 00:24:35.760 William Cheng: I guess the in the drivers. 183 00:24:36.780 --> 00:24:38.040 William Cheng: Assignment that we didn't do 184 00:24:39.060 --> 00:24:51.270 Lalit Gupta: Yeah, actually. Sometimes, if you like, if we actually had those like this as five and tribal court, I would like, we could probably like trace back to the actual thing. What is actually happening. But that's fine. 185 00:24:51.690 --> 00:24:53.970 William Cheng: Yeah, but then everybody in this class will be dead. Yeah. 186 00:24:56.820 --> 00:24:57.540 Lalit Gupta: Yes. 187 00:25:00.690 --> 00:25:03.390 Lalit Gupta: Okay, so another thing is 188 00:25:05.040 --> 00:25:05.850 Lalit Gupta: The in the 189 00:25:07.830 --> 00:25:12.060 Lalit Gupta: In the VM area of data structure, we have this 190 00:25:14.580 --> 00:25:21.240 Lalit Gupta: member variable which has which takes which which which takes here of the, what is the protection at has the VM area. 191 00:25:23.100 --> 00:25:25.560 William Cheng: Which function that is which was filed, Colonel. 192 00:25:27.750 --> 00:25:29.400 Lalit Gupta: colonel colonel. 193 00:25:30.810 --> 00:25:31.770 Lalit Gupta: Include VM. 194 00:25:33.390 --> 00:25:36.690 Lalit Gupta: And I think we met dot html thought it's probably 195 00:25:37.440 --> 00:25:39.480 William Cheng: Okay, which feel so 196 00:25:39.900 --> 00:25:40.980 William Cheng: Yeah, Mary, I guess. 197 00:25:41.160 --> 00:25:41.880 Lalit Gupta: Yeah, yeah. The 198 00:25:41.970 --> 00:25:44.490 Lalit Gupta: DMA plot the provision of mapping 199 00:25:46.440 --> 00:25:56.010 Lalit Gupta: And we have this permission and the page table also so he will also have a permission. That is it is it has a bit. I think it's a sec. 200 00:25:57.900 --> 00:25:58.890 Lalit Gupta: I think the second was 201 00:25:59.970 --> 00:26:00.270 William Cheng: Okay, the 202 00:26:00.300 --> 00:26:00.750 Lalit Gupta: Page has 203 00:26:01.260 --> 00:26:03.930 William Cheng: Got to be very careful, right, because they need to match the hardware. 204 00:26:05.010 --> 00:26:16.380 William Cheng: Okay, the VM area that's just a data structure inside the current. All right, so remember the the the VMware production can be what you know execute read and write and things like that. 205 00:26:17.040 --> 00:26:24.630 Lalit Gupta: Yeah, it has full kind of protection. Whereas, whereas the x86 only has one bit for protection, either it is a reader. Right. 206 00:26:26.070 --> 00:26:31.710 William Cheng: Right so so inside the VM area right that you know that information is not hardware specific 207 00:26:32.160 --> 00:26:37.920 William Cheng: Okay, so typically can be more general. But when you try to put things inside of page table, whether in that case you have to look up the 208 00:26:38.460 --> 00:26:47.250 William Cheng: You know, the hardware manual to see exactly which bill that you're allowed to set right so i think for Intel. There's no execute bit you know inside the page table entry. Yeah. 209 00:26:47.280 --> 00:26:49.200 Lalit Gupta: There is no. You're the only one. 210 00:26:49.770 --> 00:26:53.580 William Cheng: Right, so, so, so in that case, when you look at the VMware where you need to ignore the execute it. 211 00:26:56.460 --> 00:27:08.280 William Cheng: Because all you care is whether that page table. Well, actually, a four page table entry, you need to manipulate it right because when you're doing copy on write your first you have to set it to read only. So they don't really have to reflect exactly why is that a VM area right 212 00:27:10.020 --> 00:27:11.190 William Cheng: Because you're doing copy on write 213 00:27:15.120 --> 00:27:15.360 Lalit Gupta: Oh, 214 00:27:17.220 --> 00:27:18.450 Lalit Gupta: Okay, so 215 00:27:19.800 --> 00:27:26.160 Lalit Gupta: In which case is Candice. Candice to be different this VM and this that and the pasty will entry, but we should 216 00:27:26.460 --> 00:27:41.220 William Cheng: We should always be, you know, I mean, always assume the worst case that that can be done guys. So, for example, right, I mean, how you know you need to copy on write right if the BMA flag is private, right, and also the protection over here is is rewrite 217 00:27:42.930 --> 00:27:49.950 William Cheng: Right, that by definition, you know, if the if the memory segment is private and rewrite you are performing copy on right 218 00:27:51.630 --> 00:28:06.420 William Cheng: Okay, so that means that when you set up the page table entry, you know, before you, you know, be be before you actually, you know, carbon copy on write well in that case should be read only. And, you know, from that point on, you know, if you 219 00:28:07.440 --> 00:28:12.750 William Cheng: If you try to write to it, then in that case you need to perform copy on write and from this point on that page table entry will be right. 220 00:28:14.370 --> 00:28:15.180 Lalit Gupta: OK. 221 00:28:17.340 --> 00:28:21.960 William Cheng: So again, the VM area just give you a hint of what to do in case, in case you get a page home. 222 00:28:27.960 --> 00:28:40.140 Lalit Gupta: Okay, so it seems like this this database. The page differently, but can change depending on when we do copy after we to copyright and before that it becomes a read only to rewrite 223 00:28:40.320 --> 00:28:43.800 Lalit Gupta: You and this is equal to zero, right, to, to be invalid. Yeah. 224 00:28:46.560 --> 00:28:47.070 Lalit Gupta: Yes. 225 00:28:47.370 --> 00:28:50.130 William Cheng: It is invalid and everything else is wrong. So you just ignore it. 226 00:28:53.100 --> 00:28:55.740 Lalit Gupta: But this VM a plotter roughly the same. 227 00:28:57.030 --> 00:29:03.510 William Cheng: Well, because when you create a memory said when you have to, you have to remember it, because that's that's the memory segments created by the 228 00:29:04.530 --> 00:29:08.700 William Cheng: Well, I mean, in the beginning, when you do the hello program the memory segment is created by the loader. Right. 229 00:29:08.970 --> 00:29:19.110 William Cheng: So the loader tell you that this memory segment is read only this memory segment is rewrite. Well then, then you have to follow the instruction to remember them that this memory segments read only. And the other segments. Right. 230 00:29:19.890 --> 00:29:27.060 William Cheng: Yes. Okay, so this way you will implement things correctly right if you ignore the instruction from the loader. Well, then in that case doesn't work. 231 00:29:31.380 --> 00:29:37.650 William Cheng: Okay, and later on when you do the end map system call you try to map them, you know, memory segment on the DIS into 232 00:29:38.700 --> 00:29:44.610 William Cheng: This into your address space. So in that case, you need to look at the arguments and map my, I guess it's a map does 233 00:29:45.330 --> 00:29:51.150 William Cheng: The, the argument of of em map is very similar to VM map, map where the first function that we look at. 234 00:29:51.960 --> 00:29:58.380 William Cheng: Okay, so in that case you can map a file into your address space read only rewrite, you know, these different ways. Again, you need to remember how you map it right 235 00:29:58.560 --> 00:30:05.700 William Cheng: Because at the time when you map it he checked for permission to make sure everything's okay and then from this point on, you're going to use it. So again, you remember how you 236 00:30:07.140 --> 00:30:10.860 William Cheng: How you set up the protection when you first when you create the memory segment. 237 00:30:25.860 --> 00:30:32.670 Lalit Gupta: Did is just like a minor doubt like it not doesn't even matter. So it's a cardinal API ex ex ex Nazi 238 00:30:35.010 --> 00:30:36.300 William Cheng: Or no API. 239 00:30:38.340 --> 00:30:38.670 William Cheng: Alright. 240 00:30:39.810 --> 00:30:45.270 Lalit Gupta: So if you go to this user land entry. Why, yes, the user and anti friendship. 241 00:30:45.270 --> 00:30:47.220 William Cheng: Okay, yeah, the assembly call. Yeah. 242 00:30:48.060 --> 00:30:50.610 Lalit Gupta: Yeah, so we have this first interact disabled. 243 00:30:50.940 --> 00:30:55.110 Lalit Gupta: Yeah. And then, why, why are we setting this IPL till after this interface disabled. 244 00:31:01.230 --> 00:31:05.040 William Cheng: Um, you know, when you said IPL too low. 245 00:31:13.440 --> 00:31:18.300 William Cheng: So, so let's say we can call this function right the IPL is is high. 246 00:31:20.040 --> 00:31:27.990 William Cheng: Okay. And then if you set up if you don't disable interrupt and you said IPL too low, then maybe something terrible get delivered 247 00:31:29.400 --> 00:31:34.980 William Cheng: So we here if you disable interrupt and then you said IPL too low then in a row, and I get a little bit 248 00:31:36.630 --> 00:31:42.180 Lalit Gupta: But even if he said the IPL too high, we should not also get the word because we have into stable, they interrupt. 249 00:31:42.960 --> 00:31:50.970 William Cheng: Well, so what happened is that when you go into the user space right as soon as you get into us page you want to enable interrupt maybe doesn't use a space program can always be preempted. 250 00:31:51.720 --> 00:31:59.880 William Cheng: Yes. Okay. So, therefore, you want to sort of set everything as low as possible so IPO needs to be below and also the, you know, we need to be, you know, 251 00:32:01.260 --> 00:32:07.200 William Cheng: I guess we'll you execute I return instruction, he will change from interrupt disable to enable 252 00:32:07.800 --> 00:32:08.610 Lalit Gupta: Oh, OK. 253 00:32:09.690 --> 00:32:16.740 William Cheng: OK. So I think there's an implied enabling interrupt me as if I return. And that's why you haven't disable it first. 254 00:32:18.000 --> 00:32:23.430 Lalit Gupta: Okay, okay. Then, then this low makes sense because then after that all their church should be 255 00:32:24.480 --> 00:32:24.990 Lalit Gupta: Accepted 256 00:32:25.860 --> 00:32:26.850 William Cheng: Well, so 257 00:32:29.100 --> 00:32:35.430 William Cheng: So this is kind of like, you know, chapter two, I will we tried to wind up the alarm clock, we need to, sort of, you know, disable 258 00:32:36.420 --> 00:32:45.360 William Cheng: We need to block the signal or something like that. So I think this is related to, you know, waiting for something as simple and as you and you got to make sure that you know asynchronous event cannot mess you up. 259 00:32:46.260 --> 00:32:52.080 William Cheng: So the right way to do it is to, you know, sort of the same in this case you're dealing with the anaerobic disabled first and then you can set IPL too low. 260 00:32:53.520 --> 00:32:56.640 William Cheng: Okay, if you don't disable it. I think there's going to be a race condition or some sort 261 00:33:11.160 --> 00:33:12.210 Lalit Gupta: Cool, so 262 00:33:15.390 --> 00:33:19.440 Lalit Gupta: Can you can you repeat it in this this particular set this 263 00:33:20.010 --> 00:33:28.080 William Cheng: So in chapter two. I did there was this example we try to, you know, why not have the alarm clock. And then there's a possibility that we might miss it. Right. 264 00:33:28.410 --> 00:33:35.310 William Cheng: So, therefore, what we do is that we blocked the signal first right and then why not be alarm clock and then we're going to wait for in one atomic operation. 265 00:33:36.600 --> 00:33:46.590 William Cheng: Okay, so I think the idea we hear this code is also very, very similar. We need to, you know, a block something and then India when we execute I return instruction that on blocks it 266 00:33:46.980 --> 00:33:53.100 William Cheng: And you know, I don't know, maybe you're not really waiting for interrupt, but I'm block and then you wait for the interruption one atomic operation. 267 00:33:54.360 --> 00:34:01.500 William Cheng: But in but in this case you when you go into the user space. Okay, so I think if you don't do these kind of things properly, you're going to end up with a race condition. 268 00:34:02.640 --> 00:34:08.790 William Cheng: Okay, okay, by looking at this code, I cannot tell exactly where the race condition it but I'm thinking that this must be the reason 269 00:34:10.740 --> 00:34:18.360 William Cheng: Okay, you can want to make sure you don't have a race condition this you know this code over here is written by the Brown University people and we assume they know what they're doing. 270 00:34:18.750 --> 00:34:34.350 William Cheng: Okay, so the proper way to, to, to not to have a race condition over here is you know you disable the interim and you said, I feel too low. And then what you do. I return you enable a narrow and never interrupt. And then, you know, if you rub is going to happen is going to get delivered safely. 271 00:34:38.370 --> 00:34:39.090 OK. 272 00:34:41.010 --> 00:34:50.820 William Cheng: OK. And again, before you know this Cohen men in the middle of here whenever you see a bunch of assembly coach says, Oh, well, you know, those things are CPU dependent right because they're assembly code. 273 00:34:51.090 --> 00:34:55.320 William Cheng: So therefore that's hardware abstraction layer cover. I will. You're using the horror objection. They are code over here. 274 00:34:55.500 --> 00:35:04.230 William Cheng: You want to make sure that you don't get another interrupt because if you get interrupted going to destroy data structure inside of our websites and so therefore I need to you know make sure bad things, doesn't happen. 275 00:35:05.100 --> 00:35:12.690 William Cheng: Okay, so, so therefore you have to disable to interrupt. Okay. And then in order for you to get ready to re enable the interrupt you need to say IPL to look 276 00:35:19.380 --> 00:35:19.890 William Cheng: So good. 277 00:35:20.040 --> 00:35:25.620 William Cheng: I think the other way to do it is that you said IP out low right before you execute I return. 278 00:35:26.670 --> 00:35:27.030 Lalit Gupta: Okay. 279 00:35:27.270 --> 00:35:38.940 William Cheng: But you know, I think the code is not written that way because over here. Here's the assembly code, right. It's kind of hard to insert a C function call in the middle of assembly code. So what they do is that they actually they switch the order 280 00:35:44.310 --> 00:35:56.550 Lalit Gupta: Okay, this seems like something similar mean the idea because instead switch there is a thing. I think at some point, you said there there's going to be a 281 00:35:57.420 --> 00:36:12.960 Lalit Gupta: This how this condition. And this seems like the idea seems like seems similar kind of thing we have to hold the CPU and then we have to wait for an asynchronous event in a correct way so 282 00:36:15.690 --> 00:36:15.990 Lalit Gupta: Okay. 283 00:36:16.380 --> 00:36:17.400 William Cheng: Okay, I'm laughing 284 00:36:20.790 --> 00:36:21.120 William Cheng: Yeah. 285 00:36:26.130 --> 00:36:26.700 William Cheng: You got it. 286 00:36:27.870 --> 00:36:28.350 Lalit Gupta: Thank you. 287 00:36:45.330 --> 00:36:48.420 William Cheng: See, this is why I'm asking people to read the code, read the code. 288 00:36:49.200 --> 00:36:51.540 Lalit Gupta: Yeah, there's a hint lake on 289 00:36:54.390 --> 00:36:59.220 William Cheng: The right question to say, well, why did they do this, why, why, and then maybe that's a good reason. 290 00:37:03.210 --> 00:37:08.550 Lalit Gupta: I think you know pieces of the doubt. I think 291 00:37:08.670 --> 00:37:08.970 That 292 00:37:13.350 --> 00:37:23.130 William Cheng: Alright, so, so I'm going to end the you know the today's live lecture, then. Okay. Okay. Thank you. Alright. Bye. Okay, bye.