WEBVTT 1 00:00:02.490 --> 00:00:17.340 William Cheng: Okay. Welcome to the week 12 discussion section. So, last time I get a I gave a sort of a introduction to Colonel three. So today, we're going to look a little more about Colonel three so 2 00:00:19.650 --> 00:00:34.590 William Cheng: So in Colonel three, you know, I guess the first thing you have to do is to implement the P frame object. So last time. Toward the end of the last discussion section I mentioned those three function that you're supposed to do. So once you finish doing that you run 3 00:00:35.730 --> 00:00:46.890 William Cheng: BFS test again with S5 FS equal to one. Make sure you can pass all the tests. So now you are ready to run user space program. So you said VM equal to one, then in that case. 4 00:00:47.730 --> 00:00:55.860 William Cheng: You know insight, you're in a proc run. What do you need to do is I, you need to take the unit proc and go into user space. Okay. 5 00:00:56.580 --> 00:01:00.810 William Cheng: So, so the way that you do is that you call this function called Colonel exactly 6 00:01:01.350 --> 00:01:04.980 William Cheng: The first argument is the program that you want to run in the user space. 7 00:01:05.310 --> 00:01:12.600 William Cheng: And what it will do is that it will build the address space and then you will go into the user space and now it's going to start doing on demand page and all that kind of stuff now. 8 00:01:12.930 --> 00:01:21.240 William Cheng: Alright, so, so, so one of the important things for Colonel exactly is that it will invoke the loader and the loader is the one that will build your address space. 9 00:01:21.990 --> 00:01:31.770 William Cheng: There's again the the address space implementation and when x is using virtual memory map. This is also known as VM M AP. Okay, so some of the terminology is going to be a little 10 00:01:32.280 --> 00:01:39.090 William Cheng: You know, sort of a confusing because there's the end map system call is MMA p. So this one is VM ma p 11 00:01:39.690 --> 00:01:46.830 William Cheng: They are very similar, but they're completely different stuff okay so yeah memory map is the map a file into or something else. 12 00:01:47.160 --> 00:01:56.040 William Cheng: But basically, that is, is to map a file into your address space. Okay, so the virtual memory map is to do all kinds of mapping altogether so. So in a way, they're related. 13 00:01:56.670 --> 00:02:00.510 William Cheng: But again, you know, whether there's a V or not makes them, you know, it makes it makes a big difference. 14 00:02:00.930 --> 00:02:08.100 William Cheng: In the lecture or sometimes I will use the term memory map so there's there's only one kind of memory map. There's no physical memory map. There's only virtual memory map. 15 00:02:08.640 --> 00:02:16.980 William Cheng: So virtual memory, memory map is basically the same thing, right, except that what you're talking about the memory map system call why, in that case, you'll only creating one memory segment. 16 00:02:17.400 --> 00:02:29.700 William Cheng: Okay, the virtual memory map. It's a linear lists of memory segment. Again, the picture. So look like this. We start with the process control block and then it will point to so PCB and we next is what is a property or I proc underscore 17 00:02:30.420 --> 00:02:40.230 William Cheng: Rock underscore te. That's the PCB. And then there's the BMX so underscored. He is the data structure as what this one is the virtual memory about data structure which 18 00:02:41.340 --> 00:02:49.440 William Cheng: Which is the less right every this list element over here is known as the VM area t. So sometimes we just call it VM areas of how we call the VM, a 19 00:02:50.190 --> 00:02:56.790 William Cheng: So they're all mean the same thing. Yeah. Alright. So inside the VM area. There's a start addresses and address. And then there's the 20 00:02:57.720 --> 00:03:05.010 William Cheng: You know, the protection and also with the there's private or share. So again, for we need, you need to look at the header file to find out exactly what's in it. Okay. 21 00:03:05.640 --> 00:03:17.250 William Cheng: So we will use the term VM a VM area to refer to VM area t the values in VMware above is not what's in winning. So I'm going to just look at the header file to see and try to sort of figure out, you know, what's relationship. 22 00:03:17.790 --> 00:03:25.830 William Cheng: And again, that for the tech segment of the data segment at the beginning you know they they they point to this fall object, but found the last 23 00:03:27.240 --> 00:03:30.990 William Cheng: I guess from the last lecture, we see a little more detail right inside a file object over here. 24 00:03:31.440 --> 00:03:37.920 William Cheng: There's a vino object inside the vino there's the MO BJ. So over here is actually pointed mmm LBJ okay 25 00:03:38.340 --> 00:03:49.650 William Cheng: For these other memory sideman. Well, what they do is they they appointed anonymous object and then if you want to implement copy on write together with for you how to use shadow objects. OK. So again, all these things. I guess I've, you know, 26 00:03:50.820 --> 00:04:00.780 William Cheng: He, you got to get used to it. Yeah. One of the important things about is how to implement a VM area right VM area is a memory segment, how to implement as a memory segment. 27 00:04:01.290 --> 00:04:11.940 William Cheng: Memory segment is composed of multiple page frames there. So, therefore, you know, so, so get the memo. BJ is the one that will manage a page frame for a 28 00:04:12.570 --> 00:04:18.090 William Cheng: Uniform memory segment. Okay, so what's tricky about that is that they're actually a linear list of ammo BJ. 29 00:04:18.360 --> 00:04:30.060 William Cheng: The top ones over the top one, as we described in the lecture that the beginning part over here, their shadow objects. The last one at the bottom is either the one inside a be node or, you know, 30 00:04:30.510 --> 00:04:44.040 William Cheng: It's going to be an anonymous object. Alright. So again, this is the, this will be the case when the VM area is Matt privately if it's mapped share then then you know then then there'll be there'll be no shadow object, right, because we don't know. 31 00:04:44.850 --> 00:04:50.460 William Cheng: All right, and in the kernel FAQ Colonel three FAQ is really, really long. So again, you know, take a quick scan. 32 00:04:51.270 --> 00:04:55.890 William Cheng: Will you see this picture, you know, instead of current FAQ. So again, try to read it a little more carefully. 33 00:04:56.460 --> 00:05:06.660 William Cheng: Because that's one of the main thing that you have to do as soon as you start running your first user space program, right, because you have to build it, you have to build the address space for it and and all these memories segment. They have a PageRank. 34 00:05:07.050 --> 00:05:14.790 William Cheng: Okay. So, therefore, you have to use mmm LBJ to to to to get all these patriot. Right. The mmm LBJ the job is to manage patients there. 35 00:05:15.120 --> 00:05:26.850 William Cheng: Alright, so, so, so the picture again the retro over here is that I think also you lecture I keep using the example, as I said, if you have a memory segment that's 10 kilobytes law. We're going to implement that using three, you know, three page rain. 36 00:05:27.210 --> 00:05:34.200 William Cheng: Because every page name is four kilobytes in size, right. So, therefore, you need to have inner peace rent to cover the entire memory segment. Okay. 37 00:05:34.620 --> 00:05:39.630 William Cheng: So here's another example over here, right. Here's one page one, page one to page three page rain. 38 00:05:40.230 --> 00:05:44.430 William Cheng: This picture is a little weird, because the memories that when does it start with a page align address 39 00:05:44.670 --> 00:05:51.060 William Cheng: That this memory segment is the pink area over here. So the, you know, there's memory side will start from here and then it goes all the way to the end over here. 40 00:05:51.240 --> 00:05:57.780 William Cheng: So in this case, how do you cover with Patreon, right, if you take the starting address over here if you just, you know, zero out the last Hall bits. 41 00:05:58.140 --> 00:06:03.930 William Cheng: Together, you're going to end up with a page on line address the page online address is going to be the first memory location for PageRank. 42 00:06:04.620 --> 00:06:07.770 William Cheng: Okay. So, therefore, you know, if we add our if you look at this address 43 00:06:08.130 --> 00:06:16.050 William Cheng: The address is not page line. If you want to get a page line now jives with governmental last hobbits ok and then you're going to end up with, you know, the, the first address of this PageRank. 44 00:06:16.530 --> 00:06:24.900 William Cheng: OK. So again, bye bye bye knowing exactly where a memory segment as you can sort of figure out how many pages and you have and this page frame in the virtual address space. 45 00:06:25.110 --> 00:06:29.910 William Cheng: They have to be continuous right because because the virtual address inside a memory segment. They're all contiguous 46 00:06:30.720 --> 00:06:39.300 William Cheng: Yeah, so the picture that I draw here is that, you know, here you know for this memory segment I need three patients to cover it, but the memo BJ can actually have more than three page right 47 00:06:39.810 --> 00:06:49.590 William Cheng: Okay, so, so, so this does and what we do is over here as a bunch of pace rain or this one is called page number zero paste on one page to page three. And remember a page. Now it's just an array index. 48 00:06:50.010 --> 00:06:58.530 William Cheng: Okay, so therefore this mmm LBJ is going to manage a bunch of his friends were this memory segment is using page, you know, paste on one, two, and three. 49 00:06:59.100 --> 00:07:06.870 William Cheng: Well, so the way this is done in the Windows kernel is that they use this other the you know the, you know, this variable inside the VM areas know as BMA off. 50 00:07:07.320 --> 00:07:10.020 William Cheng: The amount of its offset and it's a page offset. 51 00:07:10.410 --> 00:07:21.840 William Cheng: Okay, so what what does say over here BMA off it goes to one that means that this one the first year. The first pastry and there are using over here is page number one and the second one over here it's page number two, and the third one over here is based on three 52 00:07:22.770 --> 00:07:25.080 William Cheng: Okay, so if you have a memo budget and manage all these 53 00:07:25.350 --> 00:07:35.310 William Cheng: These four page frame. The first one over here is paste on 01 and two, and three. So that means that this page for him is actually sitting right here at this patients in right here and this patient sitting right right here. 54 00:07:35.880 --> 00:07:47.220 William Cheng: Okay, so it's very, very important to understand the relationship between the demo BJ and the page now and what they will do is that it will point to a particular page rank and this page frame employment part of your address space. 55 00:07:48.270 --> 00:08:00.810 William Cheng: Okay, alright. So read the colonel FAQ about page. Now, you know, and also the next few effect items that follow it. Okay. If you have any question asked me. Okay, don't assume something just asked me, alright. 56 00:08:01.650 --> 00:08:09.060 William Cheng: So these are crucially understanding how to build an address space, you know, for you, for a user process. Right. Some people will happen is that in the beginning they sort of Miss understand how these 57 00:08:09.360 --> 00:08:12.600 William Cheng: Things work they spend a lot of time struggling with getting hold to work. 58 00:08:13.440 --> 00:08:21.150 William Cheng: So, so again you know you have asked questions right because I'm here to help. If you don't ask me a question. There's no way for me to figure out what will will kind of help you need. 59 00:08:21.510 --> 00:08:26.850 William Cheng: OK, so again you know the the message. Ever since the females semester is to ask question as question asked questions. Yeah. 60 00:08:28.710 --> 00:08:39.090 William Cheng: Alright, so, so, so these to pay your next few slides. All the bottom part, very important. So I'm going to sort of read through them and sort of explain to them. You know what they mean. Because again, they all talk about the same picture over here, right. 61 00:08:39.300 --> 00:08:48.060 William Cheng: The address space is made up of a list of non over overlapping VM areas. Okay, so all the memory segment or VM area or as region there. I mean the same thing. 62 00:08:48.240 --> 00:08:53.280 William Cheng: They're not overlapping because each one of them is a memory segment right it's a memory segment overlap or doesn't make sense. 63 00:08:53.610 --> 00:09:01.170 William Cheng: Okay, so therefore it's very important to understand that they do not overlap. So if you have an address space that overlap. Well, it means that you have a bug inside your kernel. 64 00:09:01.980 --> 00:09:07.770 William Cheng: Okay. It's as simple as that. Don't, don't ask a. Can I have this what you're not allowed to have overlapping VM area. 65 00:09:08.100 --> 00:09:21.000 William Cheng: Okay. So, therefore, you know, that's a lot out there every VM areas of every segment right contiguous virtual memory locations over here again physically. They're all over the place, right, because every page map to a different page managed by the buddy system. 66 00:09:21.960 --> 00:09:29.130 William Cheng: Okay, well what they were originally managed by that. But this is once you've allocated. There are no longer in the buddy system, you put inside a page frame and you manage that. 67 00:09:29.400 --> 00:09:35.460 William Cheng: Okay, so talk to the physical address. It's not contiguous. I mean, the physical address is contiguous within a page. Okay. 68 00:09:35.940 --> 00:09:44.100 William Cheng: Go from one place to the other. The physical address is all over the place. But the virtual address is continuous for memory segment. Okay, again, very important to understand. Yeah. 69 00:09:44.970 --> 00:09:51.480 William Cheng: All right. In the above, it's shown us right um every segment has a start address. And then there's a number of bytes in that memory segment. 70 00:09:51.660 --> 00:09:58.410 William Cheng: So the notation that we use is that what is a square bracket at the beginning to mean that this so so so this is called animal right 71 00:09:58.920 --> 00:10:08.430 William Cheng: And, you know, it all starts with a number ends with a number. So on the left hand side over here, the square bracket says the left hand side is closed. That means that include the first address over here. 72 00:10:08.790 --> 00:10:18.360 William Cheng: Okay, we add our plus count count the number of bytes. Here, the right hand side over here. It has open parentheses. That means that that side is open. That means that it does not include a number 73 00:10:18.840 --> 00:10:31.770 William Cheng: There. So, therefore, this you know this, you know, this particular notation means that you're going to start with the DDR right so VA DVR, and then VA DDR plus one or plus two, all the way to the add ons plus minus one. 74 00:10:32.550 --> 00:10:36.630 William Cheng: Okay, because that's the last thing. So we add a plus com doesn't belong this interval 75 00:10:37.320 --> 00:10:46.350 William Cheng: Alright, you gotta get used to this notation, some of the comments inside the the kernel source code uses particular notation, right, the left side is always close and the right side is always open. 76 00:10:46.950 --> 00:10:50.310 William Cheng: Okay, so it doesn't include the ADD ONS plus count now. 77 00:10:51.120 --> 00:10:59.040 William Cheng: All right, which means that the next memory segment can actually start at the ADD ONS plus count mad because you know this doesn't include that by and the other one close by. Yeah. 78 00:10:59.610 --> 00:11:11.040 William Cheng: All right, and typically VA DDR. The first, you know, virtual address of a memory segment. Typically it's page align. OK. So the way you know, why does it typically because I don't know for sure that if this is always the case. 79 00:11:11.700 --> 00:11:21.870 William Cheng: Alright, because if I say something. Sometimes I owe you say that. Anyways, I'm not sure. Okay. Typical is page ally. Can it be not page line. I think so. I'm not sure. All right. 80 00:11:24.120 --> 00:11:31.530 William Cheng: Okay. The Colonel manager you know the the colonel manages memory and pages, right, the allocated now pages so that the memory segment. 81 00:11:31.710 --> 00:11:45.390 William Cheng: Can fit inside if this is the memory segment over here, we need three page frame and to cover. So again, you need to do, point your math in order for you to figure out exactly how many page, page for me. You need to cover to entirely cover the this memory segment now. 82 00:11:45.720 --> 00:11:53.130 William Cheng: Above it takes three virtual pages to cover the memory segment right each virtual page needs to be mapped into a physical page there. 83 00:11:53.700 --> 00:12:06.030 William Cheng: So in the kernel source code and also in some of the lecture slides I use the term VF N and VPN right VPN is the virtual page number when I go over Chapter seven, you know, I use the term virtual page number 84 00:12:06.510 --> 00:12:14.670 William Cheng: In the kernel, they often use the term virtual frame number. So again, a frame of pages. The same thing so virtual page number of virtual frame. Remember, they mean exactly the same thing. 85 00:12:15.090 --> 00:12:20.370 William Cheng: There. So these are the virtual page number so they are the leading 20 bits of a virtual address 86 00:12:21.270 --> 00:12:29.580 William Cheng: Okay, very important to understand the virtual frame number the virtual page number. They are the leading pointy bits of a virtual of a virtual address now. 87 00:12:30.240 --> 00:12:38.820 William Cheng: So, so, so, you know, if you're writing a hex, you will get 11012345 right yeah because each one of these letter represent for bids four times I go to 20 88 00:12:39.030 --> 00:12:45.450 William Cheng: So the number usually says, Okay, well, you try to write address it. Will you try to print addresses always printed in hex. 89 00:12:46.110 --> 00:12:48.420 William Cheng: Okay, if you want to ask me a question. Don't send me 90 00:12:48.990 --> 00:13:00.900 William Cheng: A decimal number because it doesn't make any sense to me. Right. I'm just going to send you another email to say, Please, tell me the, you know, please tell me what is the, you know, what is the hex representation, because you need to get used to look at things and it has number 91 00:13:01.590 --> 00:13:10.140 William Cheng: If it's an address, look at as hacks number, right, because what it is 12345678 right that's a 32 bit number you divide it in half. 92 00:13:10.410 --> 00:13:18.450 William Cheng: The first five characters over here is the virtual page number the virtual free number and the last three characters over here is 12 pages long. So it's the offset within that page. 93 00:13:18.900 --> 00:13:23.010 William Cheng: Okay, if you give me a decimal number that there's no way for you to figure this out. 94 00:13:23.730 --> 00:13:31.830 William Cheng: Okay, don't waste your time with decimal numbers. Now, whereas you know you're used to printing these numbers in hex. Yeah. So, so if you want to in debugger. So piece. 95 00:13:32.130 --> 00:13:36.180 William Cheng: So you will print things he has can used to doing something like that where you're printing addresses. 96 00:13:36.840 --> 00:13:43.230 William Cheng: Now a physical page live. I'm in the quote unquote live inside a PageRank guys. Anytime you see a page train 97 00:13:43.950 --> 00:13:50.520 William Cheng: You know, you know that the inside a page for and there's a physical page right so if it's garbage. You can remember the physical page number 98 00:13:50.970 --> 00:14:01.710 William Cheng: Or the physical page address doesn't really matter because because if you take the physical page number. All you do is the left shifted by 12 days you're going to page a line address. So that will be the fiscal page number right so they're equivalent that 99 00:14:02.400 --> 00:14:12.660 William Cheng: All right, the pastry, my man is ready. Mm hmm. We do over here. If an MO BJ manage right there in the picture above over here and pays rent. They are number from zero to n minus one. 100 00:14:13.020 --> 00:14:21.930 William Cheng: You know, for for that. Mm. OB GYN right this example over here, this object manage for page right so the page. Now I'm over here is going to be called 012 and three 101 00:14:22.980 --> 00:14:31.110 William Cheng: Okay. And I think in lecture I mentioned before, you know, some of these page rain. They are not in memories that are sitting on this. So you can actually bring in from a distant memory. Yeah. 102 00:14:31.890 --> 00:14:37.980 William Cheng: Not really implement as a linguist of year again the colonel FAQ show them as a as a legless 103 00:14:38.730 --> 00:14:47.130 William Cheng: Conceptually, just think about simple thing of them as an array or lingers doesn't really matter in the actual implementation in winnings. They use the hash table. 104 00:14:47.730 --> 00:14:54.690 William Cheng: Okay. So, therefore, if you want to look up a particular patient. You have to use the hash table function in order for you to perform a lookup operation now. 105 00:14:55.350 --> 00:15:02.430 William Cheng: That's okay. The terminology is called look up we inside a look up, you're given a key and you try to try to find that object. Right. 106 00:15:03.060 --> 00:15:14.370 William Cheng: So so so as I mentioned in one of the lectures over here for the page rain, then you know the key for page rain is the mmm LBJ is that on the page frame. Plus, you know, together with a page now. 107 00:15:14.700 --> 00:15:22.470 William Cheng: Okay. So, therefore, if you want to look for this page rank. What should you do right you call it look our function with this mm LBJ and patient me go to two 108 00:15:23.430 --> 00:15:27.090 William Cheng: Okay, and then it would tell you whether this particular page ran his memory resident or not. 109 00:15:27.450 --> 00:15:34.020 William Cheng: And so, so, you know, if it's not memory Rosa, maybe you know you're not supposed to have it. Or maybe you know it's 110 00:15:34.410 --> 00:15:44.010 William Cheng: Sitting on the desk. So again, you know, that depends on the algorithm that we mentioned the chapter seven, or you need to sort of figure out, you know, you follow the algorithm, you should be able to find a pastry. Yeah. 111 00:15:45.720 --> 00:15:55.380 William Cheng: All right, one mm LBJ may manage paste ran for multiple VM area. So again, may over here says, I'm not 100% sure because if I say the only managed page number one. 112 00:15:55.680 --> 00:16:03.690 William Cheng: You know, for, for, for one, you know, VM area if I if I'm wrong, and being big shopper. So therefore, I'm gonna say may even though I don't know if this can happen or not. 113 00:16:04.230 --> 00:16:09.660 William Cheng: Okay, I'm at. I didn't design winnings. I'm not, I have no i don't have this information. Yeah. 114 00:16:10.110 --> 00:16:19.230 William Cheng: Alright, so the VM ARV Amira tells you were three page rain are for the corresponding VM area. So this so this way, it is possible. Again, I don't know if this happens when 115 00:16:19.770 --> 00:16:23.520 William Cheng: One mmm LBJ. So let's say I have an emoji manage 10 page frames. Right. 116 00:16:23.850 --> 00:16:39.240 William Cheng: 1234 510 page I'm over here. So maybe one you know VM area use these, you know, here's one VM area BMA over here. This one use these three page rank that another VM. A over here use these for PageRank. 117 00:16:40.200 --> 00:16:48.360 William Cheng: Okay, it's totally possible. I don't know if this happens or not. Okay, so, so, so, you know, so, so just be aware that this might this might be happening. Yeah. 118 00:16:49.290 --> 00:16:55.230 William Cheng: All right, if we may or may not be zero. Since you don't have a map and clarified to address space. 119 00:16:56.070 --> 00:17:06.870 William Cheng: Okay, so, so, so, you know, so in this example right over here I have a VM area right this VM area I map it funded this into my memory into memory, right. So, so, again, the way you do this using a memory map. 120 00:17:07.050 --> 00:17:12.720 William Cheng: You map a fall into your address space. You can also map a portion of the file into your address space. 121 00:17:13.470 --> 00:17:18.570 William Cheng: Then, so you don't have to map the entire fight you either space or so, so, so what happened is that when you look at the 122 00:17:19.140 --> 00:17:29.400 William Cheng: Demand pages what MF system call he will tell you how to map a file into outer space. So, so, let's say, here's my file right here's my file I divide my file also into for killer I pages. 123 00:17:29.760 --> 00:17:34.320 William Cheng: There are four kilobytes four kilobytes like this, right. So this is, you know, can be a very, very large file. 124 00:17:34.590 --> 00:17:44.940 William Cheng: Okay, so what I can do is I can map three of these four kilobytes file into my address space, but I will start from page number one. Right. So there's a page 012 over here. So 0123 over here. 125 00:17:45.180 --> 00:17:49.740 William Cheng: Right. So what I can do is I can map these 12 kilobytes over here into our address base. 126 00:17:50.490 --> 00:18:00.960 William Cheng: Okay, because there's no rule to say that you're required to map starting from page number zero okay you can only you can also just map, you know the the the the the the next three pages into outer space. 127 00:18:01.350 --> 00:18:06.210 William Cheng: Right. So in this case, when we met them into our address space, but this one will be paste on one. There's one more piece number two and 128 00:18:06.780 --> 00:18:14.670 William Cheng: Number three. So the way the other way, you sort of think about it is that this page down tell you which page number from a file, then you map into address face. 129 00:18:15.720 --> 00:18:28.830 William Cheng: Okay. But again, it doesn't really have to be a file. Okay, well you can sort of think about them all when I when I tried to map a, you know, part of a file into my address space the page. Now tell me where to start in that we're just, we're just stuck inside that file. 130 00:18:30.570 --> 00:18:36.750 William Cheng: Okay, so again, we'll do on demand page at the beginning, you know, all you know all these all these patients are sitting on this thing sitting inside of our 131 00:18:36.960 --> 00:18:45.570 William Cheng: When you to only man page you're going to bring them into your memory one page at a time, and only the page that you need right all the pages that you don't need. They sit on the desk. 132 00:18:46.500 --> 00:18:57.690 William Cheng: Okay, so again, very important to to understand exactly what these pieces I'm called correspond to so you can also think about them as an array index instead of file where you divide the fall into four kilobytes pages, right. 133 00:18:59.250 --> 00:19:11.250 William Cheng: OK, so again we Colonel three FAQ is your question you can ask me paste frame may not be present, you know, for mmm LBJ right this mmm we're over here I have four page read maybe none of them are memory resident 134 00:19:12.540 --> 00:19:25.980 William Cheng: Okay, so, so, so again, one of the very important thing that I say in the end of chapter seven. Okay, is that for the bottom object which is a memo BJ inside the vino or am mo BJ. That's a anonymous object. 135 00:19:26.640 --> 00:19:36.990 William Cheng: Okay, their pace rain can be you know memory Reza, or they don't have to be memory resident okay if they are not memory resident those to memory mm LBJ know how to create them. 136 00:19:37.470 --> 00:19:48.660 William Cheng: Right, because if there are a if the bottom object is the one that's inside the vino well then it has connection to the fall object, it can ask the file object to bring the patron from a distant memory. 137 00:19:49.290 --> 00:19:54.030 William Cheng: Okay, so therefore that Ma ma BJ can actually create, you know, can, can, can, can create these PageRank. 138 00:19:54.510 --> 00:19:59.190 William Cheng: Okay. Similarly, if you are anonymous object anonymous object can create a patient out of thin air. 139 00:19:59.580 --> 00:20:14.610 William Cheng: So therefore, if they're not memory resident, you say, making members and they say, okay, they just create a page for him another member resident ok for shadow object, you know, if you know if a patient is not you know members if a patient has no memory resident. What does that mean, 140 00:20:15.630 --> 00:20:24.090 William Cheng: Well, as I remember a shadow object and only keep track of pace rain that was originally copy on write but and they are, they have been modified 141 00:20:24.960 --> 00:20:33.690 William Cheng: Okay. So, therefore, if a patient is not memory resident instead of shadow object. That means that it doesn't belong there because it hasn't. You know, the because you haven't performed copy. All right. 142 00:20:35.040 --> 00:20:46.890 William Cheng: Okay. So, therefore, you know, if you have a shadow over here. Here, here's my shadow object, okay, when I tried to look for a patient inside of shadow update and if it's not there. What do I have to do I need to follow the pointer and go to the next object below it. 143 00:20:49.380 --> 00:20:56.310 William Cheng: Alright, so, so again, when you try to look up a patient for a shout out yet. You can look it up for reading. Alrighty. Well, he's had to read a patient for reading 144 00:20:56.460 --> 00:21:05.250 William Cheng: And Vista memory resident he's had a shout out yet. You follow the pointer and keep going down because eventually sooner or later you're going to hit a bottom object and the bottom logic know how to create a page, right. 145 00:21:05.910 --> 00:21:11.640 William Cheng: Okay, if you are look up a pastry. I'm over here for writing. Okay, how do you write a very short object. 146 00:21:12.330 --> 00:21:20.610 William Cheng: Okay. So remember, there's a link list of shadow objects, right, all the way pointed about them object over here. The first one over here is is for writing 147 00:21:21.000 --> 00:21:30.990 William Cheng: All the other ones. You know, so, so, you know, whenever credit or whatever we do a fork recreate a brand new shutter object. And I say everything below are frozen. 148 00:21:31.710 --> 00:21:41.070 William Cheng: Okay, so that means everything below here become read only. So, therefore, if you want to look up a page rank for writing, then you know then has to be inside that object. 149 00:21:42.660 --> 00:21:55.200 William Cheng: OK. So again, if this particular memory segment you are doing copy on write, which means that this this memory segment is private there and then you try to create a patient for writing it has to go into the shadow object. 150 00:21:56.700 --> 00:22:04.620 William Cheng: Right because private needs copy on write anything. And then if you want to write everything below the first shutout yeah they're all frozen. So, therefore, you can only right into the first shot object. 151 00:22:05.970 --> 00:22:12.750 William Cheng: Alright. So again, these are all very important things to remember. So since we're doing the on ramp AJ in the beginning, none of the Patriots are 152 00:22:13.560 --> 00:22:25.110 William Cheng: Present in the memo BJ as patients are broadening the memory, they become resident. Yeah. So, so the resident over here. You can also sort of think about this is a form of caching net because the data actually be on to the desk. 153 00:22:26.310 --> 00:22:37.020 William Cheng: Okay. So, therefore, what you do is that you bring it into memory you catch you catch the data into your memory. So you can work on it. What, why is this costume, right, because we are not allowed to, you know, go through this directly 154 00:22:38.070 --> 00:22:45.030 William Cheng: Right, if we want to modify anything on any data on this Web to bring into memory we modify the data in memory. And then when we're done. We'll be right back to the desk. 155 00:22:45.900 --> 00:22:52.350 William Cheng: Okay, so therefore, one way to sort of think about these pages frame is that they are cash there caches for what the actual data understanding on this. 156 00:22:52.710 --> 00:23:00.600 William Cheng: Yeah, so therefore they are cash inside the corresponding mmm we do over here. If the page. Ray is modified, then this patient become dirty. 157 00:23:01.410 --> 00:23:10.530 William Cheng: Right again what what a 30 or so, so, so a patient is queen, meaning that the copy in memory is exactly the same as the company on the desk right so god this is caching. 158 00:23:10.920 --> 00:23:17.790 William Cheng: Terminology in the patient is clean. Let me see exactly the same as data on this, if they're dirty. That means that it's not the same as the data on desk. 159 00:23:18.690 --> 00:23:22.830 William Cheng: There. So, therefore, if you try to close the file. He needs to he needs to be written back to the desk. 160 00:23:23.250 --> 00:23:30.870 William Cheng: Where as well as I mentioned that cook your page ID, man. They're going around, look for patient or dirty and all that kind of stuff. Right. So again, it's very important to understand the terminology of 161 00:23:31.080 --> 00:23:40.380 William Cheng: Clean up clean page rate versus a dirty PageRank right the clean page training the patient exactly the same data is what's on the desk 30 page ran, meaning that has been modified. Yeah. 162 00:23:42.930 --> 00:23:53.730 William Cheng: Alright, a Patreon is identified by. Mmm. Oh, we did I manage it and the index into the patient that mm LBJ managers, right. So, in the current FAQ, and also in the you know the end of chapter seven. 163 00:23:54.360 --> 00:24:03.150 William Cheng: We use notation. Oh, comma n to name a to identify a particular page rank right over here is mmm LBJ, it's an object. 164 00:24:03.390 --> 00:24:17.220 William Cheng: Object or mobo via and no be here is the page numbers again and paste on has to be a very small array index. Okay. Some people use virtual page number of physical page number one. In our case, you know the the currents going to blow up. 165 00:24:17.880 --> 00:24:21.030 William Cheng: Okay, because you know this number supposed to be a small number, right. 166 00:24:25.080 --> 00:24:39.060 William Cheng: Right, so. So again, this is your VM app right a virtual memory map. There's also this other data structure know at the pace table the page table is a temporary data structure that you construct so that the hardware can do address translation, then 167 00:24:39.720 --> 00:24:44.040 William Cheng: The page table maps of virtual page number to a physical page number by performing address translation. 168 00:24:44.610 --> 00:24:54.540 William Cheng: Now in the above picture we fn one two and three years VF N one bfm VF and to over here needs to be mapped to the physical page that live inside 169 00:24:55.080 --> 00:25:09.390 William Cheng: Pm 2pm 3pm for this, these three guys over here because this one, you know, because the AMA. Off he goes to one. So, this method. This this after this after this right and the virtual page the virtual page over here map to the physical page that's inside PageRank. 170 00:25:10.620 --> 00:25:14.370 William Cheng: Alright, so, so again, this is how the table supposed to to to to to 171 00:25:14.910 --> 00:25:21.330 William Cheng: To set to to to set up. Okay, so when you try to, you know, sort of setup for address translation. 172 00:25:21.540 --> 00:25:28.980 William Cheng: You need to find you know you need to find information about these PageRank because inside the pastry and it will sort of give you all kinds of information or you have to do that. 173 00:25:29.730 --> 00:25:39.060 William Cheng: So inside every patient. There's one important feel we are a copy F add our VIP add our is of high voice start. Alright. So again, it's just a pointer. 174 00:25:39.600 --> 00:25:43.740 William Cheng: It's a page rain that contains a colonel virtual address for the corresponding physical page. 175 00:25:44.490 --> 00:25:54.420 William Cheng: There. So again, every page rain refer to a physical page. How do you write data into that physical page, you have to use a kernel of virtual address the colonel virtual address is inside the PageRank. 176 00:25:54.930 --> 00:26:04.920 William Cheng: Okay, so, so, so, so the this kernel virtual address is going to be a page a line address. So if you want to add you as a single bite inside a physical page, you need to take 177 00:26:05.250 --> 00:26:13.950 William Cheng: The, you know, the PM at Dr. Over here is a page line address, you need to add the offset, you need to add the offset to it. So this way you can write a single bite into that page. 178 00:26:15.600 --> 00:26:21.510 William Cheng: Alright, so, so again, you start with a virtual drive to chop down into two to have the left half over here is the virtual 179 00:26:21.960 --> 00:26:33.720 William Cheng: frame number of the virtual page number. The rest of it is called the asset within that page, you add the offset within that page 2pm add, are you going to get a kernel virtual address for you to access one bite of data. 180 00:26:34.290 --> 00:26:38.730 William Cheng: Okay, or two buys a will or whatever the unit you want to address now. 181 00:26:39.420 --> 00:26:48.480 William Cheng: All right, there is a function called PT, which is a stable PT virtue, physical, what does it do it converts a virtual address to a physical address. So over here again reedy 182 00:26:48.960 --> 00:26:58.470 William Cheng: So you need to grab you know I get this is in the page table that see file. So given a virtual address he knows how to compute the corresponding physical address. Yeah. 183 00:27:01.830 --> 00:27:10.620 William Cheng: All right. Alright, so again this is a reminder that, you know, even though in x86 CPU. They have a multi level page table, we don't really want to write code for the multi level page table. 184 00:27:11.160 --> 00:27:19.890 William Cheng: You know, luckily the Brown University people they wrote the code for you. They build an abstraction, as if the page table is a two level or the basic, you know, 185 00:27:20.310 --> 00:27:30.900 William Cheng: Pick a page table. Okay, so this way you have a nice and easy interface, you know, for your, your photo. That's an easy interface to provide a bunch of function for you to call 186 00:27:32.250 --> 00:27:40.080 William Cheng: Alright, so, so again, when you try to, you know, so somebody wouldn't try to program the page table. They say, How do I, how do I program. The multi level page level. Don't do it. 187 00:27:40.770 --> 00:27:53.760 William Cheng: Okay, use the abstraction that are provided to you by the Brown University of evil. So in so. So look what these function PT underscore something I think there's a function called PT map. Okay so PT map is how you set up a case table entry. 188 00:27:54.900 --> 00:28:03.300 William Cheng: Or so that's that's how we need to learn how to use PT map. I think there's maybe another couple of functions inside the page table that see file. Those are the function that you need to learn how to use 189 00:28:04.410 --> 00:28:09.840 William Cheng: Okay, so, so, so anyways so so scan through the code and try to sort of figure out what you have to do. Yeah. 190 00:28:11.520 --> 00:28:20.910 William Cheng: All right, some some extremely, you know, this is the most important GDP command Colonel three really long. You gotta get used to it. Colonel info VM M mapping involved. 191 00:28:21.510 --> 00:28:30.450 William Cheng: You know, it's really long current prod PV Ma ma P right as a PBN and IP address space. So this command prints out what your address space look like 192 00:28:31.680 --> 00:28:35.730 William Cheng: Okay. So anytime you say, What is my address space. Okay, you're right, y'all. You do this. 193 00:28:36.120 --> 00:28:45.210 William Cheng: The last argument over here. This is a VM ma P. Right. This is the VM and a p underscore te star right that's the data table, we have the last argument. 194 00:28:45.510 --> 00:28:55.110 William Cheng: Okay, so some of the function that you know one of the function arguments over here this time so you so you can actually also print this one out using, you know, using any compatible data structure. 195 00:28:55.620 --> 00:28:59.250 William Cheng: Okay, but most often time this will be the command that you use. 196 00:28:59.880 --> 00:29:08.400 William Cheng: Okay. Anytime you get a pastry said well what what is, what is my address but it look like what what my address space that's me. I am current product, right. So, therefore, I use the current price. 197 00:29:09.360 --> 00:29:20.220 William Cheng: VM ma p. So, this way. I know my address right. Alright, so, so, so, so this is the most important you know the one of the most important you know GDP command Colonel three 198 00:29:20.610 --> 00:29:23.370 William Cheng: The loader bills the address space for user space program. 199 00:29:23.850 --> 00:29:32.670 William Cheng: Okay. So at the beginning of the loader. What it will do is that it will construct an empty address space as soon as it finished constructing an empty address space, you can actually use it using command already 200 00:29:33.090 --> 00:29:37.770 William Cheng: Okay, but what does that in in the middle of constructing though the empty the the 201 00:29:38.340 --> 00:29:44.220 William Cheng: The, the empty address space. It doesn't set the current projects PV IMAP because if you go there, you're going to see a null pointer. 202 00:29:45.000 --> 00:29:55.590 William Cheng: Well, guess what it will do is it will use us a temporary variable, try to build the address space. So again, you can say, Colonel info VMware mapping over here, followed by that argument of the right type, and he will tell you what it looks like. 203 00:29:56.190 --> 00:30:07.410 William Cheng: Okay, but be very, very careful if you I'm hooking hooking ponder over here, don't use this command, because this commands with me using Python Python assume that your kernel is it your kernel is inconsistent state. 204 00:30:07.860 --> 00:30:15.420 William Cheng: Okay, so if you're in the middle of hooking hooking pointer. You call this function call, you know, a Python is going to crash and then your current was gonna crash. 205 00:30:15.990 --> 00:30:22.560 William Cheng: So, therefore, is going to be really bad. Okay, so make sure you do this only at the beginning of a function and that function. If you want to know what your address face look like 206 00:30:23.370 --> 00:30:29.970 William Cheng: That. So the user space build the address base again with the address space is a linear list of VM area. So that's what the loader were built. 207 00:30:30.210 --> 00:30:41.100 William Cheng: So get used to running this come out what the loader is building different memories admins a look at a member. Second one, it looks like after your user space program is loaded loaded with Bill the address space and now 208 00:30:42.480 --> 00:30:47.820 William Cheng: Now there's a final address space. Okay, so without the address page representation, you cannot handle pitfall. 209 00:30:48.750 --> 00:30:55.830 William Cheng: Okay, when you had a paste. Remember how I described as well right when you get a baseball, you get a virtual address right here's VA DDR 210 00:30:56.010 --> 00:31:05.400 William Cheng: The virtual address, you're gonna get a baseball. You come inside a colonel, you know this. What this virtual addresses you walk down the list of VM area, find out which memory segment it belongs to 211 00:31:06.330 --> 00:31:11.580 William Cheng: Okay. So, therefore, if you don't have a young so if you don't have your address space, you don't have the area on, then there's no way for you to do that. 212 00:31:12.780 --> 00:31:21.480 William Cheng: Okay, so therefore once you finish building natural space, you need to look at it this way it looks. I see if it makes sense. Okay, try to guess what you're looking at. 213 00:31:22.560 --> 00:31:25.020 William Cheng: Okay, and it has to make sense. Okay. 214 00:31:25.890 --> 00:31:35.460 William Cheng: All right. And then when you get your first original page for our I thought as soon as you, you know, finished building the loader finished building outer space, what he will do is that it will go into user space. 215 00:31:35.940 --> 00:31:39.270 William Cheng: Right, so this is this is what the colonel exactly the right, Colonel. Exactly. 216 00:31:39.480 --> 00:31:47.370 William Cheng: Is the exact system called but but it's using the Colonel. So what it will do that involved the loader to put your address space and then we're going to use your space, right. 217 00:31:47.550 --> 00:31:53.190 William Cheng: And since we're doing on demand agent. When you go into your space. The first thing that will happen is that you're going to get a pitfall. 218 00:31:54.510 --> 00:32:05.790 William Cheng: Okay. So, therefore, you know, there's a function called handle baseball that's where you're going to handle your first page. Well, the first the first thing you do, where you get your first page file is is my address space does my address space look right. 219 00:32:06.870 --> 00:32:11.250 William Cheng: Okay, if you had to say this is wrong. What is the point of handling patient. It's not going to work. 220 00:32:12.960 --> 00:32:19.350 William Cheng: Okay, so therefore, when you get your first legitimate paste all you have to ask the question, Is my address space. Okay. 221 00:32:20.460 --> 00:32:26.100 William Cheng: All right. If it doesn't look okay then forget it. Right. Okay. So I strongly encourage you to. I mean, nobody's listening to me. 222 00:32:27.210 --> 00:32:43.290 William Cheng: All right, ask your classmate in the class Google group if they are seeing the same thing. Okay, so, so, so, run this GDP command copy and paste that. And then asking your colleague and say there's, you know, this is what I'm getting from my address space. Are you getting the same thing. 223 00:32:44.580 --> 00:32:51.960 William Cheng: Okay, that will be the robbery to ask some people actually says you know what, why don't you tell me what your answers. Okay, I'm not going to show you mine. Just tell me what you look like. That's really rude. 224 00:32:52.620 --> 00:32:59.340 William Cheng: Okay, so don't do that you'll be nice. Okay, show people your address space and ask them, you know, are you, are you guys getting the same thing. 225 00:33:01.050 --> 00:33:06.390 William Cheng: All right, because you know if they tell you that that you know you address a look wrong. This will save you a lot of time. 226 00:33:07.470 --> 00:33:17.640 William Cheng: Okay, because you don't want to spend all your time, you know, wasting on the wrong address space in terms of to figure out how come I can handle my baseball. What is wrong with my. So again, just share the print out over here, copy and paste that 227 00:33:17.970 --> 00:33:28.260 William Cheng: I mean, again, what I recommend is that you know you know this why shows up in a in a terminal window. So, what you should do is that you just copy and paste text and don't copy don't do a screen down 228 00:33:29.310 --> 00:33:37.530 William Cheng: Okay screen down makes it really difficult for other people to copy and paste. So, therefore, you know he he just do do do this using you 229 00:33:38.400 --> 00:33:44.760 William Cheng: In a text mode so other people can actually see that for you doing that right. There's another you know 230 00:33:45.600 --> 00:33:51.360 William Cheng: A Colonel GDP command, not that useful. You can print out what the page table look like you can actually do it right now. 231 00:33:51.720 --> 00:33:56.580 William Cheng: Okay, because because ever since that you starting in carnal one you have a patient while you're using it right you should never have to touch it. 232 00:33:56.820 --> 00:34:09.210 William Cheng: So you can also do the same thing and Colonel info PT mapping info. So, so you can use this kernel info command for any one of these function have something mapping info. So again, there will invoke Python code in Python going know what to do. 233 00:34:09.690 --> 00:34:12.600 William Cheng: So this one is look at the page table mapping information. 234 00:34:12.930 --> 00:34:26.580 William Cheng: Yeah. So this guy's you need to give it a page table. So again, the page table for intel is a pager. So therefore, you're going to get a car proc P underscore a pager. So, this one will print out the the you know the the pace a ball. 235 00:34:27.270 --> 00:34:33.000 William Cheng: So this one is a little harder to read, you know, because you have no idea what you know physical page frame. 236 00:34:33.420 --> 00:34:40.890 William Cheng: The physical pages are allocated and also, it doesn't really matter. You know what, what kind of pay. What kind of pages, the buddy system allocate right 237 00:34:41.760 --> 00:34:49.830 William Cheng: Okay. I mean, that's the entire point of using the the buddy system is that, you know, whenever you look at a page rank it can allocate any, you know, physical page doesn't really matter. 238 00:34:50.190 --> 00:34:52.710 William Cheng: So therefore, this information, typically is not very useful. 239 00:34:53.700 --> 00:35:03.930 William Cheng: Okay, once in a while, you know, you want to see that, hey, you know, did I allocate a new page. So what you can do that. You can use this command before you allocate a new page and then afterwards, see if the the page table allocation is different. 240 00:35:04.890 --> 00:35:11.970 William Cheng: Okay, because sometimes you think that you allocate a new page rain, but as it turns out, you didn't nothing happen well then printing this command you actually see if something that changed. 241 00:35:12.840 --> 00:35:20.760 William Cheng: Okay but but when something changed and you try to explain why is that particular page get allocated. Nobody can explain that to you because a happy inside a buddy system. 242 00:35:21.330 --> 00:35:35.670 William Cheng: Okay, the buddy system just run the algorithm whatever page, you know what, whatever four kilobytes, they found they will just allocate it. OK. So again, don't worry about which one was allocated, it doesn't matter as long as they're allocated, they're going to be okay. Yeah. 243 00:35:38.370 --> 00:35:40.860 William Cheng: All right, so I guess I still 244 00:35:42.450 --> 00:35:47.670 William Cheng: Think I still have a few minutes, so. So in this case, I'm going to, sort of, you know, recent code over here. 245 00:35:48.180 --> 00:35:52.830 William Cheng: We're going to read the code in the user space in the hello does the right car very, very simple. 246 00:35:53.040 --> 00:36:02.820 William Cheng: OK, so again during the first week of Colonel three you're supposed to get hello to work right. So once you said, be able to one us to get how to work. So again, review my last discussion section. 247 00:36:03.270 --> 00:36:10.110 William Cheng: So to mention these may be some of the the you know the the function, you have to implement. So again, I don't guarantee that is complete that 248 00:36:10.290 --> 00:36:14.760 William Cheng: But do you find out there are some function, you have to implement. It's not on the list, let me know. So I can actually fix it. 249 00:36:15.150 --> 00:36:22.140 William Cheng: Yeah. Alright. So you can see that the user space program over here. What does it do, right, the main function is very simple. It called open so you need to get open to work. 250 00:36:22.560 --> 00:36:29.370 William Cheng: The call open again. So you get open to work again and then you make the racism Hall and then it wouldn't call return it. Make the exorcism Hall. 251 00:36:29.940 --> 00:36:37.470 William Cheng: Okay, so therefore, in this case, you know, it's pretty simple. Right. But again, lots of function, you have to do to implement to get the hello provide the work that 252 00:36:38.250 --> 00:36:43.890 William Cheng: Alright, so we're gonna sort of briefly take a look at some of these functions over here that exact I see elf 33 dot c 253 00:36:44.820 --> 00:36:48.750 William Cheng: VN FM and MOBI J obstacle is over here. I guess in the 254 00:36:49.320 --> 00:36:57.840 William Cheng: In the class website on the discussion web page. I have some of these tests over here, the exact I see is how to get into the user space program the elf 32 is the loader. 255 00:36:58.140 --> 00:37:05.370 William Cheng: And then this, you know, this is the code for the n mo BJ inside of vino and all the code over here are written for you already. 256 00:37:06.210 --> 00:37:12.480 William Cheng: Okay, so therefore we need to implement other nm LBJ, what should you do, you should do something very similar to this one. 257 00:37:12.930 --> 00:37:19.230 William Cheng: But again, it's very, very different because yeah because if you read the code over here you will see that all they're doing is that they actually they go to the lower level. 258 00:37:19.890 --> 00:37:24.540 William Cheng: Okay, so they actually called the actual faster to do it right. So, you know, for for shadow object for. Mm. 259 00:37:24.750 --> 00:37:36.240 William Cheng: For for anonymous object, there's no actual file system implementation. So again, you need to implement it from scratch. Right. But again, if you should look at these function to sort of you're looking at a comment and then he also just sort of figured out what you have to do now. 260 00:37:36.870 --> 00:37:47.550 William Cheng: There's access Darcy, we need to look at two of these functions over here. And then there's a system called right which is somebody, you have to employ. You have to implement says I think says, Open is implemented for you already there. So again, 261 00:37:48.060 --> 00:37:52.410 William Cheng: The way we work is that these functions over here are user space function. 262 00:37:52.740 --> 00:37:57.390 William Cheng: Okay, so again, these are system calls. So therefore, they're thin wrapper around track machine injunction call 263 00:37:57.630 --> 00:38:02.040 William Cheng: Once you tap into the kernel. What they will do that. It will call the corresponding kernel version. 264 00:38:02.250 --> 00:38:10.200 William Cheng: Of the assumption the kernel version of these functions. Start with the word sky is all about underscore and then followed by the you know the name of the system called 265 00:38:10.500 --> 00:38:19.140 William Cheng: Yeah, so look for says, Open and look for CES Ryan look for six as an excess of all the SIS function over here, they will be the kernel version of these function. 266 00:38:19.350 --> 00:38:29.100 William Cheng: And their goal is to go to the other one that you weren't already in the earlier, Colonel. There's do open. There's do readers do right do exit right those are all the ones that are you ready implemented. 267 00:38:30.030 --> 00:38:35.430 William Cheng: Okay, so starting from the user space system call you go to the SIS function and then you go to the two functions that 268 00:38:36.960 --> 00:38:42.630 William Cheng: Alright, so, so I'm going to sort of switch to look at those. You know those codes here. 269 00:38:44.040 --> 00:38:44.940 William Cheng: Right here. 270 00:38:47.340 --> 00:38:49.740 William Cheng: All right. Ah, so 271 00:38:51.030 --> 00:38:57.810 William Cheng: Let me see what, what am I supposed look so hello. We look at them already, right. So now what I need to look at is the 272 00:38:58.950 --> 00:39:02.850 William Cheng: The exact I see function right so so 273 00:39:04.170 --> 00:39:15.660 William Cheng: Ls so I guess it's in Colonel API exact. I see. Okay, so this function has an important version is called user land entry usual and entry is how you go into the user space. 274 00:39:16.860 --> 00:39:23.070 William Cheng: Okay. So in this case, you know. So this is how you go into the make sure I'm sitting at the right place over here. 275 00:39:26.820 --> 00:39:33.930 William Cheng: Alright, so you can see that you know it disabled to interrupt. OK. So again, this is why inside your switch function in Colonel three 276 00:39:34.590 --> 00:39:40.320 William Cheng: You gotta, you gotta make sure that you hold the CPU, because otherwise, once you go into the user space program, you know, 277 00:39:40.650 --> 00:39:45.420 William Cheng: You will never get to interrupt guys over here to call it disabling Robin and going to the user's Facebook them. 278 00:39:45.960 --> 00:39:51.300 William Cheng: Somewhere in the middle. Over here, I wouldn't go into the user you're straightforward, it will enable you to rob again. But again, if you 279 00:39:51.840 --> 00:40:01.050 William Cheng: Get that is the context of your process. If you don't, you know, you know, call halt inside your switch from here. Once you go into the new space, you will never get interrupted you. 280 00:40:01.440 --> 00:40:04.980 William Cheng: There. All right. Again, the code over here, you can see that it's a bunch of assembly co 281 00:40:05.640 --> 00:40:11.970 William Cheng: Don't ask me how to explain this. I can't explain this. Okay, what's important. Over here is that in the end they execute is very powerful. 282 00:40:12.300 --> 00:40:18.540 William Cheng: You know, a machine shops and I return I return is the only way to go from the colonel into the user space program. 283 00:40:19.230 --> 00:40:22.770 William Cheng: Okay, so therefore, when you come into the kernel with a system called. How do you return 284 00:40:23.040 --> 00:40:34.440 William Cheng: You do I return when you started in Colonel exactly how to go into the user space you call I return. So the only way to go to user space as I return. Right. So again, instead of kernel source go you can graph I return to see, you know what, this happens. Yeah. 285 00:40:34.980 --> 00:40:37.230 William Cheng: Alright, the next function over here is is 286 00:40:37.770 --> 00:40:43.050 William Cheng: Is doing exactly right. So at some point in the user space for why you're going to call 287 00:40:43.290 --> 00:40:50.430 William Cheng: You can make our make the exact system call again the executives, of course, is going to go to assist exact and then it will go to do exactly. And also, again, it will come here. 288 00:40:50.940 --> 00:41:00.960 William Cheng: The colonel. Exactly. This is the function that you will use to to to to run the loader. And then at the end of this function over here. What it will do is it will call user lead entry to contribution space over 289 00:41:01.260 --> 00:41:12.270 William Cheng: There. So again, this is the function that you need to call inside the inner program okay to to to load the user space program and then go into the user space to to run that program now. 290 00:41:12.630 --> 00:41:31.170 William Cheng: Alright so this one. What it will do is that I invoke the loader. The loader is called been FMT low, whatever that is. OK. So the important one is Colonel API elf 32 so I guess they, you know, a Brown University, they are ready to invoke different kinds of loader for 291 00:41:32.640 --> 00:41:47.070 William Cheng: VM to guess Adam of this is true for all Linux ism at least four to 16.04 the format is called elf 32 ok so the executable file format is elf 32 so this particular file understand the elf 32 format. 292 00:41:47.820 --> 00:41:56.400 William Cheng: So if you look at this card over here, what he will do is that it will, you know, open the executable file and again what we talked about in Chapter three of what the executable file look like right 293 00:41:56.610 --> 00:42:01.710 William Cheng: There's a data segment, there's a there's a tech segment. There's data. Second, there's BSS, all that kind of information. 294 00:42:02.040 --> 00:42:07.380 William Cheng: So the yellow 30 to understand that data structure. Okay, so what it will do is that it will open the executable file. 295 00:42:08.010 --> 00:42:18.510 William Cheng: You know, parse that data structure and then build the address space for you. Okay, so where does it what does it do to do to go to space is going to call those function called VM ma P there so 296 00:42:18.810 --> 00:42:31.350 William Cheng: So, Colonel be VM ma P dicey. Right. So this one is your address this implementation, rather, you can see that inside this function there every function over here is now implemented okay so 297 00:42:31.830 --> 00:42:44.580 William Cheng: Create destroy insert find range look up clone your map remove yeah there's a lot of function over here. Okay, so that's one of the first thing you have to do is to implement all these functions. Right. So which one the unique 298 00:42:45.360 --> 00:42:54.930 William Cheng: Okay, you go to the loader over here and look for. So you do a stream search the EM you know VM M AP underscore read those all those phones. You start with VIP 299 00:42:55.200 --> 00:43:05.310 William Cheng: And this way you look for this one, you will see that sometime you know what will you do that, you will get to these things that are you know data structure as okay you ignore this. But again, this is the VM VM map. 300 00:43:06.210 --> 00:43:11.610 William Cheng: Underscore te so this one can use this one as an argument to the colonel GDP command. 301 00:43:12.090 --> 00:43:17.820 William Cheng: The you know the the colonel info VMware mapping for. So the last argument over here can be the data structure right here. 302 00:43:18.240 --> 00:43:25.170 William Cheng: Okay, so if you are in the middle of building your address billing address space, you can actually print out your address space by by using the Colonel. 303 00:43:25.950 --> 00:43:36.990 William Cheng: The Colonel GDP command. Yeah. Alright. So over here, this one is VM app, and then this one is VM is range empty. So this one is one of the functioning of the implement right because you know 304 00:43:37.410 --> 00:43:43.950 William Cheng: In the loader is going to call us or do you have to implement our next one is VM app. This one, Matt, a memory said, you know, 305 00:43:45.030 --> 00:43:56.640 William Cheng: You know, Matt part of the file into address space again, you can see that this is a really, really complicated function because it has many, many function arguments over here. Okay. So read the, the, the comment block read the 306 00:43:58.800 --> 00:44:10.110 William Cheng: Guess you know, read the winnings documentation. We whatever you can to find out you know how to implement this guy. So again, this is a very important function, it maps a part of the file into address face. 307 00:44:11.100 --> 00:44:14.250 William Cheng: OK. So again, the tech segment the data segment, we need about an entire address space. 308 00:44:14.790 --> 00:44:23.370 William Cheng: Inside the executable file. We have a segment within a second boy PSS right so therefore you have to map it into outer space. Otherwise, nothing's going to work. OK. So again, this is a very important function. 309 00:44:23.910 --> 00:44:29.100 William Cheng: The next one over here again VM is range empty and then is via map again VM map right 310 00:44:29.700 --> 00:44:36.360 William Cheng: OK. So again, you need to look at this function VI Colonel VM VM map that see VM AP right 311 00:44:36.660 --> 00:44:49.590 William Cheng: Right. So, this function is right here. Okay, so again, this one, it says argument over here is I. Here is your address space you're going to write from buff into virtual address base of maps starting a VA DDR for size count. 312 00:44:49.980 --> 00:45:02.700 William Cheng: Okay, so this is basically like copying data from one place to the other. Okay, so the data started on inside buff over here, you need to copy them into your address space so copy data into outer space is called writing into your address space. 313 00:45:03.690 --> 00:45:12.630 William Cheng: Well, so again we're mapping that data from the distant memory, right. So once you've added this into memory, maybe sometimes you need to go read the data from the desk and then copy them into memory. 314 00:45:13.800 --> 00:45:20.820 William Cheng: Okay, so sorry, read the data from this and put them into your address face. OK. So again, it says this is what this function does. 315 00:45:21.600 --> 00:45:28.440 William Cheng: This over here. It's called right here. What else is here. They also all these data structures VM map right again that we just saw that 316 00:45:29.220 --> 00:45:41.220 William Cheng: BMA do not create when we create an empty address space as soon as you create a unit. I guess that's why also initialize there, you can actually use the GDP command to print it out. OK. So again, assign it to a local variable. 317 00:45:41.790 --> 00:45:47.550 William Cheng: local variable over here is called map right at the beginning. Over here map is equal to know and then you allocate it, and the point to it. 318 00:45:48.450 --> 00:45:57.660 William Cheng: What else is the VM that fine range again be a map. And then what else is the VM at the short right if you allocate it, you have to destroy it right here. Alright, so that's it. 319 00:45:58.590 --> 00:46:05.730 William Cheng: Well, so you can see that these other function, you have to implement as some of the function over here. You know, like VM map. I think that cause other VMware functions. 320 00:46:06.210 --> 00:46:11.250 William Cheng: Because again, you need to you know to implement all the function that's required in order for you to build the address space. Yeah. 321 00:46:13.170 --> 00:46:21.870 William Cheng: All right, and so that's, you know, this elf 32 Darcy. And then there's the V and Colonel Fs. 322 00:46:23.250 --> 00:46:33.150 William Cheng: VI n. Right. This one is actually in Colonel to source code, right, that you have all the code over here and you don't have to implement them right so you can see that, you know, they have to do 323 00:46:33.630 --> 00:46:43.200 William Cheng: So, so again the VO over here. Oh, in disguise, is the memory management object. Right. The first argument over here is the memory management object. So this is the memory. Memory. 324 00:46:43.680 --> 00:46:54.900 William Cheng: This is the memory management objects Viera function. Right. So again, you see Rafi see put right over here, the function right here. So in this case, if this one is the 325 00:46:56.160 --> 00:47:03.900 William Cheng: Okay, so remember the picture that I drove here, right, instead of arguing. There's a vino object instead of, you know, RJ there's mo right the MO BJ. This right here. So, 326 00:47:04.230 --> 00:47:10.140 William Cheng: By the way somebody would call this mm LBJ sometimes we call it. Mm, oh, something we just call them. Oh, they're all the same thing. 327 00:47:10.800 --> 00:47:16.830 William Cheng: Okay, Mo is the same mo BJ and then the variable name of years old. Right. So again, this one is the MO. 328 00:47:17.400 --> 00:47:27.750 William Cheng: OK, so the memo is inside the vino and the Venus is inside of our so therefore, when they try to increase the reference count on the end, no object. All it does is to increase the reference count on the Beano 329 00:47:29.130 --> 00:47:36.990 William Cheng: Okay, so therefore this case they basically just copy know and then it says ML BJ to be note. So this one is at the top over here. Mmm. Over here. The vino 330 00:47:37.500 --> 00:47:43.500 William Cheng: Okay, so, so there's some really weird secret over here it says the container of the vino to so again. 331 00:47:43.920 --> 00:47:47.670 William Cheng: You need to look at the sea manual to find out what the container of doing over here. 332 00:47:48.030 --> 00:47:57.510 William Cheng: So again, you know, the NLRB jet the MO objects inside of vino using this function, you can actually calculate a negative offset into that data structure and find the vino object. 333 00:47:58.080 --> 00:48:11.310 William Cheng: This is, this is what it does not going to spend too much time on it, so just trust is called a works. Yeah. All right. There's something going to look up page right I'll get this is a lookup function given given the mm LBJ and page number 334 00:48:12.600 --> 00:48:16.680 William Cheng: Right so mmm LBJ and paste on that uniquely identify a PageRank. 335 00:48:17.100 --> 00:48:28.740 William Cheng: Yeah, and then you try to look up this page rank, either for reading or writing. Right. So again, when you perform a look up a reading you need to follow the algorithm, start with the first shadow object. So again, I'm going to assume that 336 00:48:29.310 --> 00:48:33.810 William Cheng: It's going to be a huge topic on. Right, right. Because if you don't do copyrights pretty straightforward. 337 00:48:34.020 --> 00:48:41.580 William Cheng: Okay, you don't copy. All right. There's a linguist of chatter object. So in this case, if you're looking up a page rank for the purpose of reading you need to search for it. 338 00:48:42.120 --> 00:48:49.530 William Cheng: Okay, if you're looking for object for writing, then it goes into the first shadow object, right, because everything below it there read only. 339 00:48:50.640 --> 00:48:57.120 William Cheng: That. So this is how we use the for right argument over here and and this look up a function over here in the end he will. He will return a paste. Right. 340 00:48:57.780 --> 00:49:02.430 William Cheng: Yeah, so, so, and also you can actually return a null pointer. If this particular patient cannot be cannot be found. 341 00:49:02.670 --> 00:49:12.120 William Cheng: Yeah. So again, the last argument over here, this is the return value. So this function return two things. One is an integer to tell you whether it's successful or not. And then the last one over here, you're gonna 342 00:49:12.510 --> 00:49:15.480 William Cheng: If you need to allocate you need that you found a pastry you return right here. 343 00:49:16.500 --> 00:49:22.710 William Cheng: Yeah, alright. So, again, for the, you know, for the V note over here does all these kind of stuff. 344 00:49:23.280 --> 00:49:37.290 William Cheng: So, so again, maybe you should try to understand that. And you can see that yeah yeah she called P for and get and P for and get is one of the first one, she had to implement in kernel three. Okay, so remember MP4 and get over here. What it will do is that he will actually create a 345 00:49:38.580 --> 00:49:42.150 William Cheng: Unified the object or if you cannot find the object, it will create it. Yeah. 346 00:49:43.320 --> 00:49:51.300 William Cheng: Alright, so I guess one important thing I want to point out is that over here. They sort of show you the connection between looking up something versus getting something 347 00:49:51.660 --> 00:49:53.880 William Cheng: Raza remember in Colonel to you have a V get 348 00:49:54.240 --> 00:50:01.230 William Cheng: The guise of the get again what it will do is that, again, we'll look look for it if it exists already, then he will return an object and it will increment the reference car. 349 00:50:01.470 --> 00:50:10.950 William Cheng: If it doesn't exist already what it will do is it'll create your career brand new object that so therefore P for and get over here is going to be the function that will create the object that 350 00:50:11.580 --> 00:50:15.570 William Cheng: If it doesn't exist already, right. So, again, it shouldn't create all the time. 351 00:50:16.320 --> 00:50:23.190 William Cheng: Okay, you need to look it up first. If it's, you know, if it's there. If it exists already, then you need to return an object and incremental reference now. 352 00:50:23.430 --> 00:50:30.540 William Cheng: If the object is not there, then you create it and the reference country people want. Right. Yeah. They also a function called repaid over here. 353 00:50:31.080 --> 00:50:35.880 William Cheng: So the colonel cause a little we're over here for all the other mo BJ. This function is called Phil page. 354 00:50:36.360 --> 00:50:45.510 William Cheng: Okay, so this one is called we page. Well, it's because it's related to the disk object, whereas over here, in this case, when you try to fill a page you feel the data from the desk so therefore it's reading from the desk. 355 00:50:45.780 --> 00:50:55.620 William Cheng: Yeah, so therefore you will see it over here. What it will do is that it will call the the VM ops over here. So again, you will find a vino and the vino has a function called Phil page. 356 00:50:57.600 --> 00:51:06.090 William Cheng: So the Vietnam War here. So again, this is going to be a poly morphic pointer pointing the actual system file system implementation of this function that's also called Phil page. 357 00:51:06.330 --> 00:51:13.650 William Cheng: Right okay inside a virtual classes and i don't know i mean these this the start with a V. Because it's the virtual bosses and function. He doesn't know what to do. You call it the actual process them. 358 00:51:13.860 --> 00:51:20.790 William Cheng: To do this, right. So, again, in this case, we're doing Colonel three. So we have switched to the system file system already 359 00:51:21.870 --> 00:51:25.350 William Cheng: Okay, so this case, you know, you can follow the point of view. So one thing that you can do is you can set a 360 00:51:25.770 --> 00:51:37.740 William Cheng: set a breakpoint right here. And then you can you can in GDP, because they print the right arrow VR ops over here and you're going to see these these pointer these pointers name our system file, file pointer, you'll feel page function. This function, that function. 361 00:51:38.790 --> 00:51:44.880 William Cheng: Okay, so again, you know, try to set a breakpoint over here and then print these things out so that you saw it. So they really know what you're dealing with. 362 00:51:45.720 --> 00:51:51.780 William Cheng: There's also this function called dirty page. So what does it mean 30 page right this is how you make a paste room dirty by calling this function. 363 00:51:52.530 --> 00:51:57.690 William Cheng: Okay, so. So in this case, when you when you try to go to page over here. Again, they call the actual file system dirty patrons and 364 00:51:58.260 --> 00:52:10.050 William Cheng: Clean paste function over here. How do you clean a page, right. So again, this one come from the file system. Will you clean the page you call it the actual file system, the clink a puppy function. What it will do is that I will, it will write a data to the desk. 365 00:52:11.070 --> 00:52:16.890 William Cheng: Okay, so this function YOUR KERNEL LEVEL. Go to sleep. Right. Because, you know, the way you write a page to this is that 366 00:52:17.460 --> 00:52:24.090 William Cheng: You, you know you started this operation and then you wait for it so you can also, it's going to go to sleep, and it's gonna you know the 367 00:52:24.390 --> 00:52:31.020 William Cheng: The, the CPU is going to give them to other Colonel threats. So again, if you have a reference counting bug. Then in this case, you know, over here. 368 00:52:31.470 --> 00:52:38.670 William Cheng: You know you if you recommend the reference, how to do zero then the been over here will get freed up that everything is going to go go go crazy. 369 00:52:39.510 --> 00:52:50.250 William Cheng: Okay, so again, you know, the clean page function over here. This is where you'll Colonel fan by my my fall asleep right so this one, you know, potentially, it's blocking call way. You know what we need to wait for the desk. Okay. 370 00:52:51.300 --> 00:53:00.810 William Cheng: All right, so what else is here, over here. The other thing is access see VI Colonel API access see over here. 371 00:53:01.260 --> 00:53:06.840 William Cheng: Inside this function. There are two bombs. You have to implement address permission range permission I briefly describe them before. 372 00:53:07.110 --> 00:53:13.020 William Cheng: As I wanted to mention these two important function over here, what is called copy from user. The other one is called copy to user 373 00:53:13.830 --> 00:53:16.740 William Cheng: That. So when you you know make a system called you're going to 374 00:53:17.640 --> 00:53:25.800 William Cheng: We make a sizzle call some information that you have are the are in the user address space. Okay, so we're inside the Colonel, you should use the colonel virtual address 375 00:53:26.250 --> 00:53:33.510 William Cheng: Okay, so they ever. What you need to do is that you need, you know, if the user try to pass on the information to the Colonel, you need to copy that data from the user to the Colonel. 376 00:53:33.720 --> 00:53:40.380 William Cheng: Right. What do you typically copy. Well, if you make a system call all the argument is that your system called you need to copy the inside the colonel into the kernel first 377 00:53:40.620 --> 00:53:46.230 William Cheng: There. So therefore, these to function copy from user write the copy you know the copyright use a function over here. 378 00:53:46.710 --> 00:54:01.530 William Cheng: The address over here K. Dr. Dennis is that has occurred or virtual address you add on over here. That means that the user virtual address so copy from user meaning starting from this user address copy this many bites into the kernel virtual address 379 00:54:02.700 --> 00:54:15.270 William Cheng: Alright, so again, this you know this user virtual address that means that it's less than zero XE 0000000 and this one is a kernel virtual drive that means that this one is is bigger than or equal to zero XE 00000 380 00:54:15.810 --> 00:54:28.230 William Cheng: Okay, so this function will copy from the other the other the user space virtual address into the kernel space virtual address. Yeah, I mean, of course, if this user space virtual address if it turns out that the 381 00:54:29.640 --> 00:54:34.470 William Cheng: The the the pace table entry has equal to zero, you're gonna end up getting a colonel peaceful 382 00:54:35.280 --> 00:54:40.740 William Cheng: Okay. So, therefore, you know, you got to be very careful with this function if it ends up like you are calling this function, then 383 00:54:41.070 --> 00:54:48.240 William Cheng: You know if this this user space virtual address has a corresponding case table entry that's invalid. Then there's not gonna, it's not gonna work. 384 00:54:49.020 --> 00:54:55.080 William Cheng: Okay, so remember he's not a colonel, we need to copy every we we need to move data around, you have to have Colonel virtual address 385 00:54:55.560 --> 00:55:05.190 William Cheng: Okay, so will you start with the data inside your users based virtual address, you need to pass into the kernel. So at that point, the page table entry has to has to be good if they're not good. You're gonna be in big trouble. 386 00:55:06.240 --> 00:55:15.150 William Cheng: Okay. All right. You can see the implementation over here, went to the copy from the user to the Colonel. First, you need to check whether you have the permission or not. 387 00:55:15.330 --> 00:55:23.310 William Cheng: If you don't have permission. Well then, then this is, you know, this is a he fall so he fall if all means segmentation fault. 388 00:55:24.210 --> 00:55:29.610 William Cheng: Whereas, in this case, inside the Colonel, you'll kill users baseball bat right because they're doing something that violate the access permission. Yeah. 389 00:55:30.330 --> 00:55:36.660 William Cheng: So if that was successful, what do you would do, is that what it would do is, is that he will copy that data from the user, you know, from 390 00:55:37.350 --> 00:55:45.210 William Cheng: You will copy the data from, you know, from from the, from the user space for my users make use of the Colonel. Okay. Again, this is 391 00:55:45.990 --> 00:55:53.340 William Cheng: How you do this right, so remember that in the colonel 303 in chapter seven lecture slides I give an example. 392 00:55:53.640 --> 00:56:01.890 William Cheng: To say that, you know, if the user space addresses zero x 12345678, how do you actually copy that that that data into the kernel. 393 00:56:02.310 --> 00:56:07.830 William Cheng: Okay, well, you have to do is that you solve the user space virtual address you divided into two parts, right, the virtual 394 00:56:08.280 --> 00:56:14.160 William Cheng: virtual page number followed by the offset using the virtual page number you walked on that linear list of as region over here. 395 00:56:14.640 --> 00:56:22.200 William Cheng: Was a leaderless IBM area, find out which memory segment it belongs to. And also you need to compute which page dumb. It is ok then you find the Patreon. 396 00:56:22.440 --> 00:56:32.250 William Cheng: Inside the page rain. There's a PF add on that I just showed you, you know, at the beginning of this look a little earlier. Use the PFA DDR. That's a colonel. 397 00:56:32.850 --> 00:56:42.180 William Cheng: Colonel virtual address that you can use and that is going to be a page line. Then you add the offset to it. And this way you will actually get the colonel colonel virtual address 398 00:56:43.140 --> 00:56:52.620 William Cheng: Okay, so. So that's the basic implementation of the VM map read function right so you can actually read the outer space and then copy them into this, Colonel. The Colonel virtual dress. 399 00:56:53.760 --> 00:57:00.300 William Cheng: Okay. Similarly over here, you need to copy from the colonel to the user, right. You start with the colonel data structure unit copied your user space. 400 00:57:00.960 --> 00:57:12.930 William Cheng: user space you circle that how do you do it, use this function called via map right, you need to write into your address space when you write data into address space you modify data that's accessible to the user space program. 401 00:57:14.610 --> 00:57:31.290 William Cheng: OK. So again, this is just the opposite from copy from user right you copy from, you know, from from your address space into a kernel into a kernel buffer. And now, copy the user you copy the data on the colonel buffer into the address face or is it again, these two functions are very important. 402 00:57:32.910 --> 00:57:44.550 William Cheng: I think I have one more function to explain. That's the Cisco so VI Colonel API's is called that seat. Well, there's a lot of suffering API. Will you start, you know, firstly, to get things to work. 403 00:57:45.150 --> 00:57:53.940 William Cheng: So there are three function, you have to implement over here says resist right and sis get directory entries over here, right. So, these are the only Daya implemented the end 404 00:57:54.270 --> 00:58:01.410 William Cheng: All the other sis function are implemented for us. What does that mean, what you should look at the code to see what they do because all these three system call you have to do the same thing. 405 00:58:02.040 --> 00:58:10.170 William Cheng: Okay, so, so for CES read. They're actually a lot of stuff over here. Okay, so again this comment block come from the Brown University. 406 00:58:10.650 --> 00:58:17.730 William Cheng: Okay, so I'm not sure whether you have to do all of them. Some people say, oh, you know, something we don't have to do to have to do is is oh yeah you know these are 407 00:58:18.150 --> 00:58:24.240 William Cheng: These other thing from from Brian diversity, they are not our requirement, right, our requirement is the spec that are waiting I lies that 408 00:58:24.570 --> 00:58:39.270 William Cheng: Alright, so, so, so this one is the you know the history function. The goal is to get to do we. Okay, so you need to do whatever it takes to get there. If you look at all the other functions over here. So, for example, assists open, how to do says, Open, oh yes. This opens right here. 409 00:58:40.290 --> 00:58:46.890 William Cheng: Okay, so read the code over here. This is how you implement this over. How do you go from says open to do open right so we can do here. 410 00:58:47.100 --> 00:58:58.260 William Cheng: The goal is to go do open. So what you do is that you call copy from user that's the one that I just mentioned over here. So what happened is that when you come into the kernel all the user space argument are are actually store right here. 411 00:58:58.890 --> 00:59:07.890 William Cheng: Okay, so what do you need to do is that you need to use these functions argument over here and then copy them into a colonel data structures called Colonel arms over here. So what is Colonel ours. Our current are right here. 412 00:59:08.160 --> 00:59:15.270 William Cheng: Okay. So local variable, this local variable you using the colonel stack. So definitely has a kernel virtual address right but you're actually inside a kernel. Of course, yeah. 413 00:59:15.510 --> 00:59:21.960 William Cheng: Colonel, Richard. Yes. So this function copy the data from your address space into this data structure right 414 00:59:22.140 --> 00:59:31.320 William Cheng: And then, what it does is that it costs. I'm kind of a stream to function over here and make a copy of that string and then and then would you will get is that we hear the argument over here is path. 415 00:59:31.620 --> 00:59:43.080 William Cheng: So again, this one will return to a colonel virtual address because all the functions that you have implementing Colonel to they only take Colonel virtual dress, right, because if you give them the user space virtual address, you're going to get a kernel page Hall. 416 00:59:44.400 --> 00:59:56.760 William Cheng: Okay, so therefore, again, the goal is to go to all these do functions over here that you used before. But you got to make sure that every argument over here. They are kernel space virtual address. Okay, so you can see that says, Open does this 417 00:59:57.510 --> 01:00:05.070 William Cheng: What other functions are here says way even assist wave P ID again copy from user. And then he called do way P ID. 418 01:00:05.910 --> 01:00:13.200 William Cheng: You know the stat function over here, or what is it, what does that function do copy from user and then call stream dupe again and then he called do staff. 419 01:00:13.620 --> 01:00:23.160 William Cheng: Right, so you can see the pattern. Okay, so they have what we try to implement. I mean, to get hello to work, you have to, you have to implement this right okay so yeah he follow the pattern over here and try to get it to work. Yeah. 420 01:00:24.750 --> 01:00:34.200 William Cheng: Alright, so I guess I talked quite a lot today already so so when you start implementing a colonel three. So when you get stuck, send me an email. 421 01:00:34.680 --> 01:00:48.030 William Cheng: Next week, next Friday, I will, you know, take a look at the source code for hello and look at exactly what data bytes, going to the address space so so anyways. If you have questions about them. Feel free to to ask me. Okay.