WEBVTT 1 00:00:01.199 --> 00:00:13.500 William Cheng: Welcome to lecture 14 Colonel to is due on Tuesday. One week after the midterm exam if you have come from previous semester, don't look at them. Don't copy them as to get rid of it. 2 00:00:13.980 --> 00:00:22.440 William Cheng: Grading gala is the owner, we will gray. So kind of to is a little different from Colonel one they are testing section B which is the VM FS test. 3 00:00:22.980 --> 00:00:31.860 William Cheng: You're supposed to, you know, create a case shall come in and then he said occasional command, create a child process. And then, you know, run the 4 00:00:32.550 --> 00:00:44.220 William Cheng: VM FS test in the foreground for section see tests over here the commands that are given to you are actually K shell commands in this case. So this guy's. You don't need to run a separate shop process. You simply just call them as 5 00:00:44.700 --> 00:00:53.970 William Cheng: As a shell command that. So again, if you're, if you have trouble doing this. Make sure you send me email after a mega submission. I make sure you verify your kernel submission 6 00:00:55.740 --> 00:00:57.540 William Cheng: Yeah. So I think in the warm up. 7 00:00:59.430 --> 00:01:08.250 William Cheng: Assignment, as some people didn't verify the colonel submission. So sorry. Some people didn't verify their submission. They submitted empty file. So, so please understand it after the 8 00:01:09.000 --> 00:01:13.650 William Cheng: You know, the, the deadline is over. There's nothing I can do. Okay, so when you join, you should do is that when you 9 00:01:13.890 --> 00:01:20.730 William Cheng: Make a submission where you see the ticket. You're supposed to read the ticket right the webpage is very, very clear is that you need to look at the file name. 10 00:01:21.120 --> 00:01:27.720 William Cheng: The file size you need to look at the server timestamp it the file size is only 40 bytes long, then you know that you submit the wrong file. 11 00:01:28.560 --> 00:01:35.910 William Cheng: Okay, so you have to look at a very, very carefully and if you send me the wrong file. There's no way for us to take your file after the deadline is over because said, oh, you know, 12 00:01:36.450 --> 00:01:40.170 William Cheng: Send me their own files, but you have to take it because the the the timestamp of it. 13 00:01:40.770 --> 00:01:53.010 William Cheng: Is before the deadline. It doesn't work that way. Okay. This is the optimism class. We know how to change timestamps on the file system. Now guys, so therefore, again, it just doesn't work. Okay, so make sure you follow the steps. Alright. 14 00:01:54.660 --> 00:02:03.780 William Cheng: Colonel to implementation timeline i by the end of this weekend. Are you need to get cash out to work with the FS again. Watch Week seven discussion section video and of course you're 15 00:02:04.170 --> 00:02:16.860 William Cheng: Supposed to study for the midterm exam because the myth Mitchum worth a lot after the midterm. You only have about one you have one week left, right, so you should fix your coast to pass all the testing BFS. See, and then the favor FS test. 16 00:02:17.670 --> 00:02:25.620 William Cheng: So, so again if you have questions, feel free to send them to me. You should also read the source code you guys to understand how polymorphous em work and all these kinds of stuff. Okay. 17 00:02:27.300 --> 00:02:41.430 William Cheng: All right, the midterm exam is next Tuesday. On July 7. So again, it's a take home exam it go from exactly 10am to 10:30am so again to 10:40am. That means that as soon as the clock is 1040, you have to stop. 18 00:02:41.790 --> 00:02:52.470 William Cheng: Okay, it doesn't mean that you get to work on to the end of the first minute of 1040 that you know so to 1040 over here again the right the interval the right over here is open, so therefore it doesn't include 19 00:02:53.610 --> 00:02:58.290 William Cheng: Guys are all goes to do you know 1039 you know 59 seconds or something like that. 20 00:02:58.980 --> 00:03:08.580 William Cheng: And also, if I don't get assigned plate from you. You will not be eligible to take the midterm exam. So make sure you follow the instruction and you submit your time pledge. If you are 21 00:03:09.240 --> 00:03:17.040 William Cheng: Assigned player. Do we have trouble sending email now. And also please read what you are assigning and then you need to keep your promises that 22 00:03:17.700 --> 00:03:23.520 William Cheng: If you often have internet connectivity problem, you need to practice recording your depth desktop resume. 23 00:03:24.180 --> 00:03:31.110 William Cheng: Look at the June 25 news, either on the cost web page, there's a link so so so so again you need to practice. 24 00:03:31.470 --> 00:03:38.460 William Cheng: Just in case. Bad things happen during your, you know, to do the submission, especially if you're running on a Mac. Okay. If you're running on a Mac. 25 00:03:38.880 --> 00:03:44.820 William Cheng: It is possible when you do your zoom recording for the first time it will ask you to set up all kinds of permission stuff. 26 00:03:45.300 --> 00:03:49.290 William Cheng: Okay, so if you do this during the exam, they, they're going to they're going to freak out. 27 00:03:50.010 --> 00:03:58.230 William Cheng: Okay, so do this as early as possible before the exam. So you can set everything up correctly and do it the second time to make sure that it works and doesn't ask for your permission at the second time. 28 00:03:58.530 --> 00:04:03.780 William Cheng: Okay, why is it set up permission correctly the first time from this point on this, you should continue to work. 29 00:04:04.200 --> 00:04:14.160 William Cheng: OK. So again, make sure you practice because India when when exam calm calm calm and you have to send me really late because you have a system problem with the system. There's nothing I can do. Okay, I have to detox. 30 00:04:14.880 --> 00:04:20.160 William Cheng: You know 5% for every minute that you are late. OK. So again, practice, practice, practice. Right. 31 00:04:21.150 --> 00:04:27.840 William Cheng: If you haven't done the mental rehearsal is supposed to happen on Wednesday. So you can still do it. So just go through the procedure over here. 32 00:04:28.320 --> 00:04:33.120 William Cheng: So in this case you want to, you know, you won't be able to you know make your submission. At the same time, with all your classmates. 33 00:04:33.330 --> 00:04:38.580 William Cheng: But at least you get the basic flavor of what you know what what the exam is going to look like, how is the answers to those little guy. 34 00:04:38.790 --> 00:04:46.740 William Cheng: And you get to practice where you should put all these files so that in the real exam, you'll put it exactly the same place. So this way you can actually save a lot of time. You don't have to look for stuff anymore. 35 00:04:47.220 --> 00:04:52.140 William Cheng: Because again, practice is key. If you want to have a smooth midterm exam. Okay. 36 00:04:53.340 --> 00:05:04.170 William Cheng: And also, if you have an accommodation letter from DSP I sent an email. So you've got accommodation letter from DSP. You need to for it to me as soon as possible as possible. Otherwise, I won't be able to accommodate what 37 00:05:04.560 --> 00:05:12.330 William Cheng: You know the will. Well, well, whatever that set on the accommodation letter. Okay, so again send this information to me as early as possible. Yeah. 38 00:05:13.200 --> 00:05:20.250 William Cheng: Right now we're going to continue with hardware. So last time was to talk about the you know how to use the paste able to provide address translation. 39 00:05:20.940 --> 00:05:29.640 William Cheng: So this is called the basic page table. Okay, pretty much. Nobody uses so so this one is sort of sort of get you going. Oh, what a page table might look like. 40 00:05:30.030 --> 00:05:34.860 William Cheng: Okay, so they don't want to see what kind of problem we have in the space table. How do we actually can improve that. 41 00:05:35.280 --> 00:05:40.590 William Cheng: This is also known as a true lower pay stable because we're going to take the virtual address going to chop it into two parts. 42 00:05:40.800 --> 00:05:45.780 William Cheng: And as I mentioned something called a hierarchical addressing. Right. So the first part over here, address, you know, 43 00:05:45.990 --> 00:05:53.340 William Cheng: The first part will be. It can be a page. And the second part over here give you an offset within that page, right. So again, this is known as the two level page table. 44 00:05:53.670 --> 00:06:00.450 William Cheng: That so they don't all going to see other kind of structure, you know, full, full, full different page table. Yeah. So last time we perform the 45 00:06:01.680 --> 00:06:08.190 William Cheng: Sort of show you what the MMU has to do, I want to address translation. So all those things are done by the hardware. 46 00:06:08.460 --> 00:06:17.610 William Cheng: Okay, there's no software involvement that the job of the organism software is to build a page stable once the page that was built, then you just give it to the hardware, the hardware take over from there. 47 00:06:17.880 --> 00:06:24.480 William Cheng: Okay. And maybe it was hardware and then what it will do is that it will perform all that kind of operation to start with a virtual address and DNS. 48 00:06:24.750 --> 00:06:34.980 William Cheng: End up with a physical address right and in the middle of this process, it will actually have to go across the bus to read a page table entry for memory into the MMU. So this way we can continue to perform address translation. 49 00:06:36.840 --> 00:06:42.930 William Cheng: So let's continue apace. Third one is a kernel data structure sitting in memory, not inside the MMU as well so 50 00:06:43.230 --> 00:06:52.740 William Cheng: If you think about this data structure. There's 1 million entry entries over here is for buys law if you take the entire page table and put it inside the MMU that will take a very, very long time. 51 00:06:53.250 --> 00:07:06.540 William Cheng: Okay, so therefore the paste a boat does not sit inside the MMU what the enemy will do is that they will take this page table entry from the, you know, and you know from from the page table one entry at a time into the MMU as as the. Me neither. 52 00:07:07.500 --> 00:07:13.650 William Cheng: Okay, so therefore this is done at the time when it perform other translation. If it doesn't have this page. They weren't you will go across the bus to get it. 53 00:07:14.250 --> 00:07:18.570 William Cheng: Okay, so, so, so, so then that then, then you will continue to perform address translation. 54 00:07:19.020 --> 00:07:30.120 William Cheng: Now, so during either sensation. We need to read a page table entry again PTS that's what pays a boundary from across the bus at the end of the other sensation you are reading and writing memory. So, therefore, you have to go to the bus again. 55 00:07:30.990 --> 00:07:35.730 William Cheng: Okay. So, therefore, if you are using address translation every memory address in sorry 56 00:07:36.000 --> 00:07:42.510 William Cheng: Every memory access. Now it's going to turn into to memory access because one of them will be reading a page table entry from across the bus. 57 00:07:42.840 --> 00:07:53.160 William Cheng: Now, so therefore, by using the the pace table here. We're going to be running, you know, 100% slower than before, right, because you know actually go into the buses, actually not. Not too fast. 58 00:07:53.700 --> 00:08:06.540 William Cheng: So one of the things is sort of the typical number I will use is that if you do an operation inside the CPU. For example, if you add two very simple number or you could do an operational to staples number is going to cost you on the average one nanosecond. 59 00:08:06.870 --> 00:08:14.970 William Cheng: Because again, these are probably older CPU today CPU memory faster, but when you need to go across the bus to read from memory that's going to cost you 100 nanoseconds. 60 00:08:15.750 --> 00:08:21.090 William Cheng: Okay. So going to the bus is going to cost you 100 times more than doing stuff inside of CPU. 61 00:08:21.900 --> 00:08:30.330 William Cheng: Okay, so in this case you need to go through the memory twice. So he said, this is gonna cost you 200 millisecond instead of just reading and writing by memory over here, which doesn't cost you 100 62 00:08:30.780 --> 00:08:40.980 William Cheng: nanoseconds. That's a millisecond me 100 nanoseconds guys are. This guy is going to be twice as slow or the overhead is going to be 100% just because you are using address translation. 63 00:08:41.910 --> 00:08:46.440 William Cheng: Guys. So this is very expensive, right. So later on we're going to see how we can actually solve this problem. Okay. 64 00:08:46.620 --> 00:08:49.530 William Cheng: So for now, we're going to say that, you know, this is the problem going to live with. 65 00:08:49.710 --> 00:09:00.720 William Cheng: We're going to be very, very slow and it was. We're going to sort of introduce more way to implement the pace table. We're going to see that actually going to get slower and slower and slower, right, and India. We're going to see a way to solve all the speed problem. Yeah. 66 00:09:02.670 --> 00:09:11.400 William Cheng: All right, location, and paste their voice part of the context of a process, right, because when you try to switch on one process to another process every process has their own pace table. 67 00:09:11.850 --> 00:09:20.310 William Cheng: Okay, so therefore, when you switch from one process to the other as part of the contacts you have to load is that the CPU is also the, you know, well, where the page table is 68 00:09:20.730 --> 00:09:29.010 William Cheng: So in this case we need. So I mentioned before, I had the paste. Hey Bobby, or has a face address the base address of the page table is part of the MMU register. 69 00:09:29.910 --> 00:09:37.410 William Cheng: Okay. So this guy's we're going to have a you know the address of the page table here. So in this case, do we need the virtual address into a stable or the physical address of the page table. 70 00:09:38.850 --> 00:09:42.270 William Cheng: Okay. As it turns out, we need the physical address of the page table. Why do we 71 00:09:43.920 --> 00:09:49.320 William Cheng: Why is that right, so the virtual address over here is used by the inner core of the CPU when you perform I go translation. 72 00:09:49.500 --> 00:09:56.880 William Cheng: You need the physical address that page table entry, because that's the address, you need to put over the bus so that you can read the paper entry from across the bus. 73 00:09:57.270 --> 00:10:02.400 William Cheng: Okay, if you put a virtual address onto the bus, one that is going to be useless. So therefore, when you try to use the bus. 74 00:10:02.550 --> 00:10:11.580 William Cheng: You have to put a physical address on the bus. So if you want the physical address of the page table entries over here, we must store the physical address of the page table. The first. Okay, she's got a page that ball. 75 00:10:11.760 --> 00:10:15.000 William Cheng: Or the face. I just would have paid their bill and that has to be a physical address 76 00:10:15.900 --> 00:10:25.290 William Cheng: So therefore inside a menu. So again, we mentioned before, instead MMU we're gonna have a bunch of register. Some of the register is going to have physical addresses over here. You shouldn't be surprised that 77 00:10:25.470 --> 00:10:35.400 William Cheng: The base address will appear stable, it's gonna be a physical address. Okay, so for the x86 CPU, the physical address at a pace table is stored in a register Corsi are three register. 78 00:10:36.090 --> 00:10:44.910 William Cheng: Okay, so in chapter three, all the records that we saw the general purpose, the register, all that kind of stuff. We never see the car through register, we see the index register with see the segment register. 79 00:10:45.420 --> 00:10:52.500 William Cheng: The CIC register is a specialized on the bridge over here and then that will be the first register that will store a physical address 80 00:10:52.800 --> 00:11:00.000 William Cheng: OK. So again, what you prefer address translation, you're going to take the virtual page number left shifted by two bids, which is something that's multiply by two. 81 00:11:00.180 --> 00:11:03.480 William Cheng: And then you add it to the value inside the car three register. 82 00:11:03.660 --> 00:11:12.870 William Cheng: That will give you the physical address and paste. Hey, we're entry and then use this one to put it onto the bus you start a bus operation, read the paper into from across the bus from physical memory. 83 00:11:13.110 --> 00:11:21.840 William Cheng: Into the menu and now the me, you will check all these bits. If all the big checks out over here. What do you do, is that it will take the physical page number over here left shifted by 12 beds. 84 00:11:22.170 --> 00:11:30.870 William Cheng: At the offset to and finally get a physical address. Okay, so it again, it will it will put the physical address under the bus. And so this way you can read and write out the memory location. 85 00:11:31.890 --> 00:11:35.490 William Cheng: Yeah. So again, you know, all these things are sort of coming together right here. Okay. 86 00:11:36.420 --> 00:11:44.130 William Cheng: All right, so that's the other. The, the basic to level page table so so again every process is going to have their own pace table. 87 00:11:44.460 --> 00:11:49.650 William Cheng: So this guy is going to say that, you know, for the blue process. There's a blue page table for the pink processes that are pink page table. 88 00:11:50.280 --> 00:11:55.470 William Cheng: What about the operating system, the operating system may have its own page table, or may not, so again, this depends on the 89 00:11:55.860 --> 00:12:05.460 William Cheng: Operating system implementation. Right. Some operating system, the operating system has their own pace able some doesn't guys over here we're going to say that the opposite of that has also have their own pace pace their boss. I'm going to color green right here. 90 00:12:06.030 --> 00:12:19.260 William Cheng: Okay. So, depends on who's running inside the CPU. I'm going to stop writing the inner core the CPU anymore. He has a wizard right CPU raffle. You don't understand that this is the inner core of the CPU. So the inner core the CPU can turn blue can turn pink or 91 00:12:19.530 --> 00:12:31.440 William Cheng: Green or whatever it is. So this guy is when it before I go translation, it needs to know the right register into the MMU and we saw before, for the Intel CPU. The MMA register is the car through register. 92 00:12:32.160 --> 00:12:39.690 William Cheng: OK. So again, what we need to imagine is that the base address for the page table. We can will be loaded into the MMU so that. Mmm. You can do address translation. 93 00:12:41.670 --> 00:12:49.320 William Cheng: Into physical memory over here we're going to divide them into four gigabyte pages over here. So every page table entry has a physical page numbers. I'm joined them like a pointer. 94 00:12:49.500 --> 00:12:57.030 William Cheng: That will point to these physical pages, right. So for the blue armor points here for the pink one over here and for the lesser points here for the pink one of the points here, you know, etc. 95 00:12:57.960 --> 00:13:08.940 William Cheng: OK. So again, you know, all you have is a physical piece number that that's an array index that will tell you which page and the physical memory that you need to access. Okay, I just turn the picture around. But basically, so same picture. Yeah. 96 00:13:10.500 --> 00:13:24.540 William Cheng: Alright so so yeah what's inside MMA, is that me contains the hardware that perform the address translation, you know, the shift the ad start. So even starting the bus operation is driven by the mmm you read the data from across the bar that's done by the MMU when it 97 00:13:25.110 --> 00:13:30.090 William Cheng: When it takes the data inside the inside of CPU. It goes into the MMU and the MMU or 98 00:13:30.330 --> 00:13:42.870 William Cheng: You know, will actually, you know, to all the checks to see the validity bit of said to see if you're violating the access rights for that page and then eventually it will take the physical address do all the shifts and do the ad. Again, all these things happen inside MMU 99 00:13:43.200 --> 00:13:53.970 William Cheng: Okay, so what does the MMA right the MMU is a single register, which is the base address of the page table, plus a bunch of hardware that would do address translation. Okay, so that's the moderator and mute. Yeah. 100 00:13:55.830 --> 00:13:58.680 William Cheng: Alright, so when he's had to accept the virtual address 101 00:13:58.950 --> 00:14:07.410 William Cheng: That you either the validity, but equal to zero or where he's had a right to a member location that's read only as in this case, you can generate page fall. So in this example, we are 102 00:14:07.590 --> 00:14:13.320 William Cheng: I'm trying to generate a virtual address 20,000 or be here. As it turns out, you got to pay for all. So, so, yeah. 103 00:14:13.770 --> 00:14:20.310 William Cheng: You know we just saw before how you provide your translation rights, and will you read the page table entry, you find out that either validity equal to zero. 104 00:14:20.490 --> 00:14:31.410 William Cheng: Or you access is incompatible with the protection bit. Is that a patient when g. So, in this case, we're going to generate again over here. This is called a page on all doesn't call the segmentation while anymore because we're doing paging 105 00:14:31.710 --> 00:14:39.210 William Cheng: Okay, so what we're going to do a page for over here. We're going to try into the operating system. So now what is albinism supposed to do, right. So if you're going to get a page for 106 00:14:39.450 --> 00:14:43.830 William Cheng: page table does not have to request the diagram. So maybe the equal to zero over here. 107 00:14:44.520 --> 00:14:50.790 William Cheng: Okay, we're trying things out all businesses are so what the audience is, I will do is that it will walk down that linear listed as region. 108 00:14:51.360 --> 00:14:59.520 William Cheng: Okay, and try to sort of figure out what needs to be done if it turns out that he can actually repair this page fall. So in this case, the patient will not turn into a segmentation fault. 109 00:14:59.850 --> 00:15:05.010 William Cheng: Because we still use the word segmentation for to me that it's a bad page for that you know you don't know how to fix. 110 00:15:05.280 --> 00:15:13.680 William Cheng: That. So if a patient can be fifth can be face. We're going to continue the color page Hall, but if it turns out it cannot be fixed. It turned into a segmentation pot now. 111 00:15:14.220 --> 00:15:19.380 William Cheng: So this goes, what do we do that if it turns out that the page can be fixed. Maybe this page is sitting on the desk over here is over here. 112 00:15:19.620 --> 00:15:27.660 William Cheng: On this, there's a page, there's a backing store on the desk. That's where the data is. So in that case, you need to transfer the data from this into memory. So in that case, what do you have to do. 113 00:15:27.870 --> 00:15:34.530 William Cheng: You need to call the buddy system to allocate a new page over here, right. So what you do is I need to ask the buddy system for free page, Frank. 114 00:15:35.400 --> 00:15:42.690 William Cheng: Okay, so I already starting to use the word page frame, right. So again, if you read the textbook or read some other places, they will say, you will allocate a new page friend. 115 00:15:43.290 --> 00:15:51.780 William Cheng: So when clearly yeah well you know it's allocating one physical page. But again, the reason we call her paste room is that as soon as you allocate a physical pain you sticking out of PageRank. 116 00:15:52.530 --> 00:16:02.700 William Cheng: Okay. So, therefore, this guys want to allocate a new page where and when we say allocating a new page rate. That also means that you allocate a new page using the buddy system and you stick that page just take that page instead of page right 117 00:16:03.120 --> 00:16:14.190 William Cheng: There. So once you have a patient over here, you can write a bunch of stuff on it. And then what you will do is I need to transfer data on the desk into memory because because that's one of the reason you gotta be. You gotta pace fall because the data is not in memory. 118 00:16:14.640 --> 00:16:19.410 William Cheng: So, therefore, you got to start at this operation over here and your kernel throw will fall asleep. 119 00:16:20.250 --> 00:16:24.270 William Cheng: That and eventually when the data transfer is complete you gonna get auto completion into raw 120 00:16:24.450 --> 00:16:29.370 William Cheng: Your kernel. So I got woken up and down, it knows that that data has been completed over here. So what it has to do is 121 00:16:29.550 --> 00:16:37.680 William Cheng: Is that it needs to go to the page table over here and modify the pace table entries are set the equal to one and then set it to rewrite or read only whatever the 122 00:16:37.920 --> 00:16:45.300 William Cheng: Value is so yeah what the colonel will do is that it will look at the as region to know exactly what to do what all these bits inside the page table entry. 123 00:16:45.690 --> 00:16:49.140 William Cheng: Guys. Oh, yeah. For example, if you're doing copy on write that in that case you have to set 124 00:16:49.530 --> 00:16:53.640 William Cheng: All the page table entry to the right values. So next time you can actually provide a copyright 125 00:16:54.000 --> 00:17:00.330 William Cheng: Okay, so, so, yeah, when you when you are doing your kernel three assignment you need to sort of figure out exactly how to set up a stable n g 126 00:17:00.690 --> 00:17:08.280 William Cheng: So that everything will fall will function correctly. Okay. When you finish setting everything up and you have the physical page number over here and I'll point to this page. 127 00:17:08.490 --> 00:17:18.120 William Cheng: And now vehicles to why you set up everything. And now you're really ready to return three users, Facebook, when will you return to the user space program again the user space program I originally 128 00:17:18.690 --> 00:17:22.410 William Cheng: Tried to create a memory reference and it generally a peaceful 129 00:17:22.740 --> 00:17:29.430 William Cheng: Okay, so, so again, it pays pays well get turned into a segmentation for the should never return and this guy, since the return front of paintball 130 00:17:29.610 --> 00:17:39.630 William Cheng: That means that we need to try this operation. One more time. So again, we need to access virtual just 20 20,000 or we need to perform address translation. We're going to read the page table entry from the pace table. 131 00:17:40.020 --> 00:17:46.320 William Cheng: On the page, page table from across the bus into MMU and then we're going to check the validity bit check the check the 132 00:17:46.830 --> 00:17:53.730 William Cheng: You know, check out the protection birth, all that kind of stuff. If, if it turns everything is fine. We're going to take the physical page number over here and then 133 00:17:54.450 --> 00:18:01.980 William Cheng: We're going to lecture by bits added to the offset over here. And then finally, generate a memory reference and now the memory reference going to reference, you know, 134 00:18:02.370 --> 00:18:11.280 William Cheng: Reference this page over here. It's a physical memory loss, or in this case, this is the page, we just brought in from that this into memory. So if we continue, we're going to end up assets and data. 135 00:18:12.600 --> 00:18:17.550 William Cheng: Inside this particular page. Okay. And then when the second time you do this, you should not get a page called again. 136 00:18:18.120 --> 00:18:29.280 William Cheng: Yeah, so this is what I supposed to have a, you know, doing a paste all okay you're going to end up, you know, trapping the current ones and hopefully when you return you will not get a page fall, will you, will you access the same page. Yeah. 137 00:18:31.740 --> 00:18:42.120 William Cheng: Alright, so over here says, oh, x is going to fix a stable and restart the user memory reference by simply return back into the user space program and now instead of CPU the CPU, I should take care 138 00:18:42.600 --> 00:18:52.590 William Cheng: Bye bye bye bye referencing that memory location. One more time. Well, as okay this is done inside a hardware where all the copying, all this kind of self. This is done by the Colonel. The Colonel needs to do the right thing. 139 00:18:52.860 --> 00:19:01.230 William Cheng: And eventually it will fix up the pace table over here. Again, this is a software duty structure. And then when he returned to the user space program. And now the hardware would take over again. 140 00:19:02.070 --> 00:19:08.370 William Cheng: Okay, so again this is part of our software and part of software that are done in order for you to handle baseball. Yeah. 141 00:19:10.620 --> 00:19:22.170 William Cheng: Alright, so what is the problem with a. So I guess we were sort of finished introduction, with the basic page a board level page. They're both. So there are two main problem number one is the one that I mentioned already, you know, you have 100% overhead. 142 00:19:22.680 --> 00:19:33.480 William Cheng: Okay. So, therefore, that might be too big. So we're going to, sort of, you know, we're now we're going to sort of sort of be aware of that. There's this problem, but we actually we're not going to fix this. We're going to fix it. At the end of 143 00:19:34.500 --> 00:19:38.490 William Cheng: The day at the end of the Howard. Howard discussion there. 144 00:19:38.970 --> 00:19:49.800 William Cheng: Alright, so the other problems that the pace table over here is too big. Right. It's four megabytes over here. So if you think about on your machine. If you're running 50 different processes every process needs four megabytes of memory. 145 00:19:50.070 --> 00:19:56.940 William Cheng: 50 times 4 million by you're going to end are using 200 megabytes, just for just for using all the page table. 146 00:19:58.110 --> 00:20:06.000 William Cheng: Okay, so there's no that would be a total waste right and and also if you look at our pace it over here. There's 1 million entry over here. How many entries are we actually using 147 00:20:06.990 --> 00:20:11.220 William Cheng: That we mentioned before in the, I guess, in chapter four, we saw that. Very simple. 148 00:20:11.490 --> 00:20:22.830 William Cheng: I guess at the end of Chapter three, we saw that very, very simple example. We have three pages in the tech stack. We have one data segment over here and one stacks like man, we're only using five out of 1 million entries over here. 149 00:20:23.310 --> 00:20:33.090 William Cheng: Okay, so all the other entries over here, what they have, they have equal to zero for all the other entries over here. So in this case, this is four megabytes of memory. We're basically wasting four megabytes of memory. 150 00:20:33.360 --> 00:20:43.170 William Cheng: Okay, how many, how many pages that weren't you do we really need if we only have five entries over here that we need five times the times for we only need 20 bytes and we're allocating four megabytes of memory. 151 00:20:44.370 --> 00:20:48.810 William Cheng: Okay, so that would be the first thing that we're going to try to solve is try to start to solve the space problem. 152 00:20:48.960 --> 00:20:58.800 William Cheng: But again, typically there's a space time trade off where he tried to solve the space problem. The time problems going to get worse and worse and worse. And in the end, we're going to solve all the time problem in one shot that 153 00:20:59.610 --> 00:21:04.740 William Cheng: As I'm going to first look at the solution for the space problem. So how do you sell disappear space follow 154 00:21:05.460 --> 00:21:13.470 William Cheng: Right. I mean, you know, we, here we have a linear data structure which is not array. Right. So if the array take up too much space, you know, even a real 1 million entries over here. 155 00:21:13.980 --> 00:21:19.470 William Cheng: So as it turns out that this is sort of a sparse array because, you know, a lot of the data search over here that are no pointers. 156 00:21:19.920 --> 00:21:29.520 William Cheng: So in this case, you know, what is going to be the solution, right, the typical computer SAS solution is that you're going to use the tree data structure. Use a hierarchy to solve your problem, or are you going to use a hash table Tu, Tu, Tu, Tu 157 00:21:30.180 --> 00:21:39.150 William Cheng: Tu, Tu, Tu replaces this table right because India. What is this table do this table is simply a map data structure that will map a virtual page number to a physical page number 158 00:21:40.140 --> 00:21:47.760 William Cheng: Okay, so in that case it doesn't really matter what data structure you use. You can use a tree to use a hash table because they are all capable of doing this lookup operation. 159 00:21:48.420 --> 00:21:54.330 William Cheng: Or as we're going to tell so so so we're going to try to like take a look at some of these a you know a solution is over here. 160 00:21:54.570 --> 00:22:00.600 William Cheng: So again, this case is a general scaling problem because the array doesn't scale very well going to end up allocating too much memory. 161 00:22:01.080 --> 00:22:08.880 William Cheng: So we're gonna look at a hierarchy, you know, and also the also another solution is to look at Hash. Hash table. 162 00:22:09.750 --> 00:22:16.830 William Cheng: Now we're also going to talk about one of the thing over here. This is actually belong to the hierarchy over here. It's called a virtual linear paste table. 163 00:22:17.130 --> 00:22:24.450 William Cheng: So in this case, we're going to end up using a pace table in virtual memory. So again, you know, the, the, the patient for that we saw over here. 164 00:22:24.810 --> 00:22:29.220 William Cheng: With that we saw before they are prepared by the colonel and the Colonel can only use them. 165 00:22:29.460 --> 00:22:39.960 William Cheng: You're using virtual addresses. Okay, so, so, so, so in that case, you know, the, the, the patient will actually sit inside the virtual address space. So over here, this, as you know, the pace table also seen inside a virtual address space. 166 00:22:40.530 --> 00:22:44.220 William Cheng: It doesn't really make much sense. Right. So they're all going to sort of see exactly what it says. 167 00:22:44.640 --> 00:23:00.120 William Cheng: Right, so we're going to see two approaches. One is use hierarchical, you know, accuracy, and the other one is use the hash table that so first we're going to look at a hierarchical addressing the first approach was actually pretty. Oh I nobody do this anymore. It's no as page segmentation. 168 00:23:01.170 --> 00:23:05.370 William Cheng: So this guys want to take our virtual address, you know, divided into two parts. That doesn't really work on to 169 00:23:05.700 --> 00:23:15.420 William Cheng: Whatever we divided into three parts of. So in this case, we're going to take our 32 gig virtual drive chopped into three parts. The first one is known as a segment number. So that's what this is called segmentation. 170 00:23:15.840 --> 00:23:22.110 William Cheng: Okay, because it's kind of like segmentation over here. Therefore base over here for the summer registers or two to four years gonna be 16 location. 171 00:23:22.500 --> 00:23:26.490 William Cheng: This is kind of like our segmentation. When we support the memory map out 172 00:23:27.030 --> 00:23:36.360 William Cheng: Let's remember the memory map out. We need for peers abysmal register and then we probably going to allocate another 12 your peers to visit marriage. I'm going to end up with the 16th debates register. So then 173 00:23:36.600 --> 00:23:43.410 William Cheng: You know, using the pace table entries analogous to a baseball register. So, this you know so this particular method come from basically segmentation. 174 00:23:44.340 --> 00:23:50.220 William Cheng: OK. So again, I'm going to have one of them is going to be the tech segment. The other one is going to be a data segment and at the bottom of yoga yes tag or something like that. 175 00:23:50.460 --> 00:23:54.810 William Cheng: Right. But in this case, they only have food, you don't have 16 entries over here for the segment table. 176 00:23:55.470 --> 00:24:02.460 William Cheng: Okay, so the second part over here is going to use the middle 16 bits over here. So this one is going to be known as the page number or the virtual page number 177 00:24:02.610 --> 00:24:06.480 William Cheng: I mean, the other sort of thing about is that the virtual face number is 2020 bits over here. 178 00:24:06.660 --> 00:24:15.480 William Cheng: We're going to chop them into to the first part is known as the segment number which is for business law and the middle part over here is known as the page number and that one is going to be a 16 bit long. 179 00:24:16.020 --> 00:24:24.570 William Cheng: OK. So again, the middle part over here is going to be used as a re index to edit to access the second level page table. Okay, so in this case we're going to end up with a hierarchy. 180 00:24:24.720 --> 00:24:29.310 William Cheng: There are three different level over here eventually you're gonna you're gonna end up getting getting to a physical page. 181 00:24:30.030 --> 00:24:36.510 William Cheng: Now, so how do you prefer edit translation over here, right. So, yeah, I'm going to use the first four bullets over here to access the segment table over here. 182 00:24:36.690 --> 00:24:51.180 William Cheng: The segment tables only 1616 entries law. The first one is 012 all the way to 15 over here. So again, you will use the segment number as an array index and that will give you one of the segment table entries over here. So what does the second table entry look like 183 00:24:51.720 --> 00:24:59.520 William Cheng: A look just like a page table entry. Okay. He has validity about over here is equal to zero, that means invalid otherwise vehicles. The one that means is valid. 184 00:24:59.700 --> 00:25:05.430 William Cheng: There is real and raw, you know, those kind of access this over here. And then finally, there's also a physical page number 185 00:25:05.880 --> 00:25:12.690 William Cheng: Okay, so when you use the segment number of here to access the southern table if it turns out vehicles to one and the access everything checks are 186 00:25:12.870 --> 00:25:20.370 William Cheng: You will take the physical page number over here left shifted by 12 bits and that will give you the base address for the, you know, for the page table. 187 00:25:21.630 --> 00:25:29.790 William Cheng: Okay, so again this is a physical place number will you left, you have to give it away. You still get a physical address so so the physical address will be the base address for the second level page table. 188 00:25:29.970 --> 00:25:39.120 William Cheng: Okay, what do you do with a second level page A BALL AGAIN YOU USE THE MIDDLE 16 bits over here as an array index. So in this case, it will go from 012 all the way to, to, to the 16 minus y. 189 00:25:39.780 --> 00:25:45.330 William Cheng: Guys are the second level paste that was very, very big right let me. It's much smaller than the previous page table, but it's still pretty big. 190 00:25:45.600 --> 00:25:52.830 William Cheng: So this guy is one of your 16 bits over here as as one of the entries over here. Again, this one is the pace table entry has to be there has a protection beds. 191 00:25:53.070 --> 00:25:56.940 William Cheng: If everything checks out over here. You're going to take the physical page number instead of a 192 00:25:57.120 --> 00:26:05.940 William Cheng: Left shifted by 12 days you're going to get a page alive address you add the offset to air. So the other piece, la, la Dodgers over here is going to point to the base address of the single page. 193 00:26:06.180 --> 00:26:12.090 William Cheng: And they use the offset over here to add to the base address and now you get a memory location and that will be the physical address 194 00:26:13.230 --> 00:26:16.740 William Cheng: Okay, so when you perform address translation like this, you know, 195 00:26:18.600 --> 00:26:23.340 William Cheng: So, so let's guys how much memory. Did you actually say rise up before we're using four megabytes of memory. 196 00:26:23.760 --> 00:26:30.330 William Cheng: So in this case, every entry is over here has to to the site every table in the middle here. It's going to have to to the 16th entries over here. 197 00:26:30.780 --> 00:26:37.620 William Cheng: To the six equal to 64,000 each one of them is four bytes long, so this is going to be 256 you know 198 00:26:38.460 --> 00:26:42.900 William Cheng: kilobytes in size. Okay. And how many of the second level page, they will do we need 199 00:26:43.410 --> 00:26:47.790 William Cheng: Guys are so for example if we have the tech segment over here. We're going to need one of the page table over here. 200 00:26:48.000 --> 00:26:51.750 William Cheng: If we have a data segment SPSS over here. We're going to have a second one over here. 201 00:26:51.930 --> 00:26:58.200 William Cheng: And then maybe was have the heap segment. We're gonna have the third one over here. And then the last one of you is going to be a stock. We're going to point to one of them over here. 202 00:26:58.410 --> 00:27:09.630 William Cheng: So in this case, the, the yellow one. Are we are going to end up having for yellow page table. Each one of them is 256 kilobytes. If you multiply that for you're going to end up with one megabytes of second level page table. 203 00:27:10.440 --> 00:27:17.070 William Cheng: Guys, a soda with four megabytes. And now we cut it down to one megabyte so in this case will only cut it down to 25% 204 00:27:18.060 --> 00:27:25.170 William Cheng: Okay. Is that a lot i mean it's it's still. Yeah. No, it's not nothing but again it's not very, very much. Right. So that's one of the reason people don't do this. 205 00:27:25.620 --> 00:27:31.710 William Cheng: Don't do this today, because in the end, the savings, not very, very much. Okay. And again, if you don't have a tight end if you don't have a heat segment. 206 00:27:31.950 --> 00:27:37.980 William Cheng: Here. Okay, you will have the tech segment data segment segment. So in this case, the middle one over here is going to be. I 207 00:27:38.400 --> 00:27:44.250 William Cheng: Have three of these take a page table in the middle, all the other entry in the segment page table. They all have equal to zero. 208 00:27:44.940 --> 00:27:52.170 William Cheng: Okay. So, therefore, if we go to zero, that means that the physical paste number is going to be invalid. So therefore, they don't point to any of the second level page table. 209 00:27:53.100 --> 00:28:02.820 William Cheng: Well guys, and this guy went to end up with 700. So, you know, bye bye bye bye three, you're going to end up with 768 kilobytes over here. So again, it's smaller than one megabytes, but it's still pretty big. 210 00:28:03.060 --> 00:28:08.760 William Cheng: Right, because if you end up with with 50 different processes, you're still going to end up using quite a bit of memory, just to store the page table. 211 00:28:09.510 --> 00:28:13.770 William Cheng: That what's even worse is that over here. So if you're using this one. 212 00:28:14.370 --> 00:28:21.060 William Cheng: Well, you need to access memory over here. How many times do you have to go across the bus. Right, so, so, so you over here for the segment. 213 00:28:21.450 --> 00:28:27.390 William Cheng: For the segment you know table entries over here. This is also city sitting across the bus and physical memory, right. 214 00:28:27.660 --> 00:28:39.270 William Cheng: The page table entries over here sitting across the bus and physical memory. And then the final location that you did X is over here again city across the buzz in physical memory. So in this case, the overhead is going to be 200% you're going to be running three times a slow 215 00:28:40.500 --> 00:28:53.280 William Cheng: OK. So again, this one is still wasting a lot of memory is even going to be slower. So again, this is really not very, very popular this day. So again, this is kind of, you know, people introducing into transitional period when they move from segmentation two pages. Okay. 216 00:28:54.870 --> 00:29:01.170 William Cheng: Alright, the next one over here are sort of divide the virtual of paste on break into two different parts of yours, a little differently. 217 00:29:01.620 --> 00:29:06.090 William Cheng: So this is known as the floor map a stable, also known as the multi level paste table. 218 00:29:06.450 --> 00:29:14.490 William Cheng: So again, this is three level right. Why is it called multi level because it can actually be extended into a 64 bit format which we're going to talk about a little later that 219 00:29:14.820 --> 00:29:20.340 William Cheng: So when take the richer page number over here, divide into two parts, we divide them into two equal parts. 220 00:29:20.580 --> 00:29:32.550 William Cheng: The first time is over here is no at the pace directly number and the second one over here is known as the page number that so the page directory number is going to access a top level paste a ball no as the pace directory table. Does that sound familiar 221 00:29:33.450 --> 00:29:43.890 William Cheng: Right so so remembering your current one instead of the process control blogging. There's something called page dirt that's one of these guys because this is this. This is the architecture that's used by by by the Intel CPU. 222 00:29:44.190 --> 00:29:52.140 William Cheng: Go. So when you're using the x86 CPU, then you are using a for map page table and the virtual address over here is going to chop things or two or three parts. 223 00:29:52.380 --> 00:29:58.230 William Cheng: 10 minutes 10 best for my child. That's the first step is known as the page directly number again it's used as an array invest 224 00:29:58.590 --> 00:30:02.940 William Cheng: That will give you a paste directly entry instead of page document to you again every entry looks like. 225 00:30:03.330 --> 00:30:06.630 William Cheng: A stable entry. There's going to be the VB is that can be a protection in this 226 00:30:06.840 --> 00:30:12.330 William Cheng: And there's going to be the physical page number if everything checks out, you will take the physical page number and left shifted by robots. 227 00:30:12.480 --> 00:30:19.980 William Cheng: You're gonna get a base address for the second level page table, you're going to use the middle can bits of you as an array in the US and that will give you a pace table entry. 228 00:30:20.130 --> 00:30:24.930 William Cheng: You check the veba you check the protection because if everything checks out, you will take the physical page number 229 00:30:25.110 --> 00:30:31.710 William Cheng: Left shifted by 12 days you're gonna get a base address of the physical page and you add the offset to her and that will give you a memory, memory location. 230 00:30:32.640 --> 00:30:39.090 William Cheng: Now, so again, it sounds exactly like the P segmentation, right, except that the piece of paper size over here is a little different. 231 00:30:39.330 --> 00:30:51.660 William Cheng: What is going to be the page sample size over here for the page directory table over here we're going to use templates to address it. So that means that we're going to need to to the 10 locations over here. Okay. So two things would have 1024 and every page. 232 00:30:52.110 --> 00:30:58.410 William Cheng: Of yours for by law. How big is the page directory table the pace directory table over here is four kilobytes in size. 233 00:30:58.770 --> 00:31:06.000 William Cheng: But what about the second level page table over here. The second level paste table also have to to the 10th century over here risers. There'll be 1024 entry. 234 00:31:06.180 --> 00:31:13.620 William Cheng: Every one of them is going to be four bytes law. So again, the second level paste a ball but here's four kilobytes all and how big is the physical page. It's four kilobytes all 235 00:31:13.950 --> 00:31:20.910 William Cheng: That's why we like four kilobytes. Okay. Because everything is four kilobytes. Right. So in this case, if you want a page director table. What do you do 236 00:31:21.300 --> 00:31:26.910 William Cheng: Right you are, somebody says that give me a page. If you want a second level page table. What do you do you ask the buddy system. So give me a page. 237 00:31:27.060 --> 00:31:33.990 William Cheng: If you want a physical page over here. So again, you ask the buddy system for everything. And every time he will give you a page. And that's exactly what you need. Yeah. 238 00:31:34.800 --> 00:31:41.940 William Cheng: Right. So this guy is what is the minimum page table overhead. Right. So again, I'm going to sort of take a look at our small program that we read before 239 00:31:42.120 --> 00:31:47.850 William Cheng: You know, for the main call sovereign, something like that. So in that case, we need the tech stuff, man. We need the data plus BSS segment. 240 00:31:48.060 --> 00:31:58.710 William Cheng: And in this guy will also need a snack snack man everything in the middle of the equal to zero. Right, so therefore the tech side is, again, this is entry number zero this entry number one is not enter number 00 over here. 241 00:31:59.010 --> 00:32:10.860 William Cheng: Is actually an accessible so and so entry number one over here is going to be the tech stack manager number to over here will be the data plus BSS. And then the last one over here is going to be 1023 that will be the array index. 242 00:32:11.190 --> 00:32:17.820 William Cheng: That. So the Yellow Pages are both via we only require three of them, right. So, so the tech savvy. Nobody is going to point to one of them. 243 00:32:18.060 --> 00:32:26.160 William Cheng: And then the data seven plus b. So, the point. The second one, and the stock segment over here. Well, again, point to the base address of the third, you know, the third page table. 244 00:32:27.030 --> 00:32:33.390 William Cheng: Okay. So in this case, this is going to be our smallest program that will have a text document data segment attacks. I've been over here. So in this case, 245 00:32:33.720 --> 00:32:37.200 William Cheng: What is going to be the cause of the page table in terms of number of bytes. 246 00:32:37.590 --> 00:32:42.240 William Cheng: Okay, so this data structure we mentioned this is four kilobytes rise over here for cannibalize four kilobytes. 247 00:32:42.450 --> 00:32:54.210 William Cheng: And then this data structure over here is also four kilobytes. So in this case, all we need is 16 kilobytes. So we just cut our, our page table overhead. So, by the way, why do I say the pace that was overhead. 248 00:32:55.050 --> 00:33:00.690 William Cheng: Now, because if you don't have address translation. You don't need page table at all. So therefore, the entire page table over here is going to be overhead. 249 00:33:00.840 --> 00:33:08.580 William Cheng: Right. So we started out with four megabytes would cut it into one megabytes cut into several hundred and 68 kilobytes. And now we cut it into 16 kilobytes. 250 00:33:09.240 --> 00:33:15.390 William Cheng: Okay 16 kilobytes. It's kind of small right you know your relative to four megabytes OVER HERE, THIS IS A make a huge savings. 251 00:33:16.380 --> 00:33:21.120 William Cheng: OK, so again into over here. We're doing this right over here. In this case, we're going to end up with 68 kilobytes. 252 00:33:21.840 --> 00:33:30.300 William Cheng: So so so again this will be the minimal page table overhead. If you use more table entry will be here. So we're going to end up with, you know, Mama, mama meatball overhead. 253 00:33:30.840 --> 00:33:38.130 William Cheng: Well, they have to guess in the best case over here all we require over here is to use 16 kilobytes over here to build your page table now. 254 00:33:40.020 --> 00:33:42.630 William Cheng: Alright, so the main job over here again. 255 00:33:42.960 --> 00:33:50.820 William Cheng: We still have 200% overhead, right, because whenever you try to access this memory location over here instead of going to the bus only wise. Now you have to go to the bus three times. 256 00:33:50.970 --> 00:33:57.060 William Cheng: One to read the page directly entry and one to read the page table entry. And finally, you need to read or write this memory location. 257 00:33:57.510 --> 00:34:08.940 William Cheng: Okay so 20% overhead, you're going to be running three times slower than before. So that's still going to be a major job. So again, you know, the it's going to get worse and worse in any idea we're gonna sort of solve all these problems. Okay. 258 00:34:10.230 --> 00:34:15.360 William Cheng: All right, so, so again for the x86 CPU I since they have a, you know, 259 00:34:15.900 --> 00:34:30.870 William Cheng: Forward web page table over here. So inside the x86 CPU. There's a register called the car to register the CFO register contain the base address or the physical address for the the physical base address for the page directory table. 260 00:34:31.500 --> 00:34:41.040 William Cheng: Okay, so that's why you Colonel assignment inside the process control browser. Remember we mentioned that the location of the the page table is part of the context of your process. 261 00:34:41.490 --> 00:34:49.350 William Cheng: Right. So we see that in Colonel one inside the practical joke, blah, there's a page directory page or directory pointer that points to this particular address 262 00:34:49.770 --> 00:34:54.630 William Cheng: Okay, I just want to sort of briefly mentioned that your current on Simon. That address is actually a virtual address 263 00:34:54.810 --> 00:35:02.280 William Cheng: Which means that when you are ready to put it inside a car through registering into the CPU, you need to cover that virtual address into a physical address again. How do you do that. 264 00:35:02.640 --> 00:35:10.140 William Cheng: Well, we mentioned before, you can use the page frame object to convert a virtual address and your physical address by using all that information that starting from you know from our page where 265 00:35:10.350 --> 00:35:15.660 William Cheng: Eventually you will get a physical address and he will. He will. He will. He will you'll put the physical address into the CRP register. 266 00:35:16.200 --> 00:35:26.850 William Cheng: That's okay. Inside the cardinal data structure. It's okay to keep a virtual address as long as right before you're going to replace the data is going to put data into the car to register you convert that into a physical address and that will be doable. 267 00:35:27.450 --> 00:35:35.820 William Cheng: Guys okay inside your kernel source code graph for the lowercase c are three. And you see how are the CRC retro being used inside the Linux kernel. 268 00:35:36.600 --> 00:35:42.240 William Cheng: Okay, so this way you're going to see how they're they're getting bogged right. So yeah, since you don't really know and you know too much about Colonel three year 269 00:35:42.390 --> 00:35:50.940 William Cheng: You just take a look at it right now and then forget about it. So they don't worry you, will you work on your kernel three you can come back and look at these yeah hopefully they will make more sense of that. Yeah. 270 00:35:53.310 --> 00:35:53.820 William Cheng: All right. 271 00:35:55.380 --> 00:36:05.130 William Cheng: Oh, that's over here. This is why I just mentioned over here so so weeks runs on sad CPU sad CPU usage for my page table in the hardware and the pace pace that went to, as I mentioned, 272 00:36:05.670 --> 00:36:12.600 William Cheng: Before it doesn't really look like this. You have to look at the entire city three or three to six programmers manual to see exactly what it looks like. 273 00:36:12.930 --> 00:36:20.940 William Cheng: But for, you know, to make your programming a little easier inside the wind is current all the programming abstraction is a two level page table. 274 00:36:22.410 --> 00:36:28.380 William Cheng: Okay, so what does that mean, right. So if you want to ask them the pace table entries over here, even though in reality the pace of all over your look like this. 275 00:36:28.620 --> 00:36:31.230 William Cheng: Do you want to write code is set up to level page table. 276 00:36:31.530 --> 00:36:38.160 William Cheng: The answer is no, right, because it's too complicated. So what you will do is that you actually so so the Brian versus people and they're very nice. 277 00:36:38.370 --> 00:36:42.810 William Cheng: They write an abstraction. Make it you know make the pace. While we're here, look like an abstract data type. 278 00:36:42.960 --> 00:36:49.200 William Cheng: So what you will do is that as long as you have a virtual paste number over here, you can actually set the entry over here for a page table entry. 279 00:36:49.350 --> 00:36:55.500 William Cheng: And reality. What it will do is that it will convert into setting up a stable into over here, you know, for the multi level page table. 280 00:36:56.280 --> 00:37:05.640 William Cheng: Okay, so therefore inside your kernel three your primary abstraction is a to lower paste a ball. So all you need to do is to learn how to use that abstraction. Right. So again, it's abstract data type. 281 00:37:05.850 --> 00:37:10.950 William Cheng: All you need to do is to find out what function to call. So you can actually set all these payable entries 282 00:37:11.610 --> 00:37:16.440 William Cheng: OK. So again, the code or there is very complicated for setting up a page table like this. 283 00:37:16.620 --> 00:37:23.310 William Cheng: If you want to learn how to do that spend five minutes and forget about it after the semester is over, you can, you know, try to learn all you want. 284 00:37:23.490 --> 00:37:34.080 William Cheng: But during the semester over here, you should not try to spend all your time trying to understand exactly how this work, okay, because as it turns out, it's extremely tricky are the code they wrote inside of Linux kernel. 285 00:37:34.830 --> 00:37:41.610 William Cheng: Okay, so even though, conceptually, it doesn't look too bad. But in the end, the code is very, very ugly that right. So you've got your warning already 286 00:37:43.500 --> 00:37:50.130 William Cheng: Okay, so, so that's the you know the interface. They've also. The next thing we're going to sort of briefly look at. It's called a linear page table. 287 00:37:50.580 --> 00:37:52.950 William Cheng: So in this case, the pace table over here. 288 00:37:53.400 --> 00:38:01.710 William Cheng: So here we said at the pace that well here is going to be in the virtual address space. The reason we say that is that the face address for this page table over here is going to be a virtual address 289 00:38:01.950 --> 00:38:07.290 William Cheng: Okay, well, all the other page table. We're just talking about over here, the base address with a patient who has to be a physical address 290 00:38:07.710 --> 00:38:14.850 William Cheng: Okay, so this way you're going to take the base address over here. You add add an offset to her and the page table, ensure that you get over here also contain 291 00:38:15.540 --> 00:38:22.920 William Cheng: This guy's the the the address for the page table entry is going to be a virtual address. So therefore, again, it's going to be subject to page fall and things like that. 292 00:38:24.150 --> 00:38:29.250 William Cheng: Okay, so this is done by the Digital Equipment quote I think the one that invented the mini computer 293 00:38:29.610 --> 00:38:38.970 William Cheng: So they have a really strange architecture. So they take the virtual guys over here again chocolate into three parts. The first part over here is only two bits long. They call this the space bit 294 00:38:39.600 --> 00:38:54.090 William Cheng: OK, so the spaceman can be 00010 and why why in binary. Okay. As it turns out, Robin is that in the space 00. This is the lower portion of the user address space the zeros one space over here. It's going to be typically use for the stock space. 295 00:38:54.840 --> 00:39:02.310 William Cheng: That and maybe why is it all we hear a dog will be the space that will actually have a physical page table, which means that the base address. We're going to use a physical address 296 00:39:03.120 --> 00:39:09.930 William Cheng: Okay, so in that case over here. And as it turns out of space one one is never used. So, therefore, in this case, you know, for the for the Digital Equipment called 297 00:39:10.440 --> 00:39:21.780 William Cheng: Your computer, they only use three different spaces. Okay, so what it will do is that they will use the first two bit over here at keep the first your space register and again what it will do is that it will actually give you sort of some sort of a 298 00:39:22.830 --> 00:39:27.810 William Cheng: They will give you a virtual page table over here where some of the entries. I'll be here, you can actually get a pace fall 299 00:39:28.320 --> 00:39:36.150 William Cheng: Okay, so this case. The base is going to be a virtual address and you add entries to it over here using the middle part of you who is the virtual page number and that will give you an array index. 300 00:39:36.360 --> 00:39:43.050 William Cheng: And then the pace of branches over here is going to give you a second level page table and the second level page table is inside of physical address. Yes. Okay. 301 00:39:44.160 --> 00:39:56.580 William Cheng: So so so again the ideation sessions to look a little bit confusing the text will show you this picture over here. I'm going to mark an X over here because we don't really, you know, we don't really worry about the linear page, you know, the scheme anymore because nobody uses anymore. 302 00:39:57.810 --> 00:40:04.530 William Cheng: Okay, so yeah. Would you would you would do is that you're going to start out in your virtual address space either page 00 or page or page 01 303 00:40:04.800 --> 00:40:12.450 William Cheng: And you're going to take a virtual address number over here, added to the the the the the base register which is depends on the 304 00:40:12.840 --> 00:40:15.000 William Cheng: depends on what's inside the space, space over here. 305 00:40:15.390 --> 00:40:22.680 William Cheng: And get a space of it over here, can only be 0001 so again depend on the space, but you will use a different registered over here, you add the virtual 306 00:40:22.950 --> 00:40:29.520 William Cheng: The virtual page number two and that will give you the patient manager for for the, for the second level page table. So the second level. 307 00:40:30.030 --> 00:40:32.250 William Cheng: is guaranteed to be in the one zero space. 308 00:40:32.610 --> 00:40:38.490 William Cheng: Right. So in this case, the address and it will give you over here. All you do is to add one zero in front of her. And now we're going to use a different 309 00:40:38.700 --> 00:40:50.520 William Cheng: The sort of a different register inside a CPU. So this one is a one, zero space, you know, paste them over here and then again you use that to point to the base address. They use a virtual page number as an array index. 310 00:40:50.730 --> 00:40:56.790 William Cheng: And that will do a paste Global Entry you check the validity of doing all that kind of stuff. And then finally, you take the physical page number over here. 311 00:40:57.390 --> 00:41:07.800 William Cheng: So for the VAX 11 seven at over here the offset is only nine visible. So, therefore, you take the physical page number left shifted by nine Beth at the offset to it. And that will give you a face physical memory location. 312 00:41:08.610 --> 00:41:21.060 William Cheng: Right. So what's important to understand over here is that only the second level paste table which is in space, one, zero. That's a real pace table. All the other ones over here is actually in virtual space over here. So in reality, there's really no page table right there. 313 00:41:21.570 --> 00:41:24.930 William Cheng: Okay, so it says actually done in this particular way that 314 00:41:26.400 --> 00:41:30.750 William Cheng: Alright, so in this case over here at the middle of this page don't want to over here. How big is it 315 00:41:31.200 --> 00:41:39.780 William Cheng: Right, the virtual page number over here is 21. This is even bigger than the one we talked about before. So in this case, each entries over years for buys over here. So in this case, 316 00:41:39.930 --> 00:41:51.330 William Cheng: There's going to be 2 million entry. So this data is going to be a megabytes in size. Okay, so let me twice as big as four megabytes. So again that's another reason we sort of don't use them anymore. You know PPI 317 00:41:52.950 --> 00:41:54.780 William Cheng: Because in this case is wasting a lot of memory. 318 00:41:56.310 --> 00:42:04.950 William Cheng: And also one of the first level paste a ball we get. OK, so the first level page table over here. As it turns out, we don't really need the entire data structure that's going to take up a megabytes. 319 00:42:05.490 --> 00:42:12.060 William Cheng: Because, you know, in the 00 space. If you look at your address space 00 space is the one that you have a tech segment that data center and the heap segment. 320 00:42:12.360 --> 00:42:19.710 William Cheng: Only the beginning part of your address space that that's be use that. So, therefore, in this case, we can actually use a much smaller paste table that look like this. Okay. 321 00:42:19.860 --> 00:42:31.470 William Cheng: So here is the 00 space page table, only the first few entries over here is is valid because all we need to do is to implement the tech segment data center and the BSS in a dynamic region over here and the rest of the equal to zero. 322 00:42:32.400 --> 00:42:41.970 William Cheng: Okay, so in this case inside of X 11 seven inside the fax machine over here. What they will do is that they actually have a length registering is that the CPU to tell you how many entries over here. 323 00:42:42.630 --> 00:42:54.300 William Cheng: How many, how many entries over here are valid. So the rest of it doesn't even have to exist. Okay, so they call this you know that this page that over here is going to exist in the virtual address space because a lot of the entries over here that only exists. 324 00:42:55.290 --> 00:42:58.380 William Cheng: Okay, so, and also you can do the same thing with the staff over here. 325 00:42:58.770 --> 00:43:02.910 William Cheng: The stag over here will look like a site. The struggle, we will look like this. Right. You start from the bottom over here. 326 00:43:03.090 --> 00:43:12.780 William Cheng: And you go to the top. So again, for the 01 space page table, only the bottom and few entries over here are valid. So again, all you need to do is remember how many entries that the bottom over here. 327 00:43:13.590 --> 00:43:16.710 William Cheng: So therefore, the zero white space page here, but can also be very, very small. 328 00:43:17.370 --> 00:43:26.430 William Cheng: There but in the end, the one zero space patients tables still take up one day to take up a megabytes. So in the end. This approach also, you know, use up too many patients entries 329 00:43:27.210 --> 00:43:42.060 William Cheng: Yeah so. So in the end, also use up. Too many. Too much memory that and also in the modern program over here. The address page look a little different because, you know, we started off as very so therefore, even in the 01 a space a paste them over here. We're gonna start envy and 330 00:43:43.140 --> 00:43:47.880 William Cheng: End up with a lot of entries over here because what allocate many, many a stack space. 331 00:43:48.150 --> 00:43:58.650 William Cheng: Inside our address space. So therefore, we're going to end up taking a lot of memory. So this will take a lot of memory and also we're going to start mapping funding to address space. So again, the 00 space piece that we're also going to be found very big 332 00:43:59.040 --> 00:44:07.740 William Cheng: So in the end, that's one of the problem with the the mini computer is that they use up too much memory to support all these processes. Okay. So, therefore, we don't do this anymore. Okay. 333 00:44:09.720 --> 00:44:18.930 William Cheng: Alright, the next kind of there so so now we're done with, you know, using hierarchical approach the employment page table. So the next thing we're going to look at look at how you implement a stable. 334 00:44:19.320 --> 00:44:25.380 William Cheng: Using a hash table that. So what is a hash table right so the high state, what would you do that, you divide, you know, 335 00:44:26.520 --> 00:44:37.290 William Cheng: The way you perform look up. Is that your has your key into different buckets inside every bucket, there's a conflict resolution chain or collision resolution Chang and then you walk out on this, try to look for something that 336 00:44:37.740 --> 00:44:42.720 William Cheng: Look, look, look, look. You got to walk out of the collision resolution chance you're going to look for the key. 337 00:44:43.110 --> 00:44:48.480 William Cheng: So guys, we can use the same concept to implement a page table. Okay, so this is what it looks like. Over here that 338 00:44:49.110 --> 00:44:57.780 William Cheng: So, so in this case over here. In this example, we're going to have four different buckets. So what we're going to do that, we're going to take the virtual page number over here, we're gonna we're gonna send it to a hash function. 339 00:44:58.170 --> 00:45:02.760 William Cheng: There. So here's a function that will take a virtual page number and compare them to to bits. 340 00:45:03.060 --> 00:45:11.670 William Cheng: Of so got two books can be 00011011 so that will give you four different buckets over here and then inside every partner is going to be a collision resolution Chang. 341 00:45:12.180 --> 00:45:16.320 William Cheng: Okay. So inside the collision resolution resolution Chan. What we need to do is that we need to look for the key. 342 00:45:16.920 --> 00:45:24.120 William Cheng: Okay, so therefore we need to design. This is what will be the key, right. The key is the one that you send it to the hash table. So in this case, the key will be the virtual patient number 343 00:45:24.570 --> 00:45:34.920 William Cheng: Okay, so what we need to do that, we need to come to the first data structure of yours. Okay, this is a single mailing list. We're going to walk out of a single link that's going to compare the toggle over here against our virtual page number. So yeah, what does attack. 344 00:45:35.430 --> 00:45:43.140 William Cheng: So the tag is like, you know, when you go to the supermarket, you try to look up prices on the IDA you pick up the idol. You see there's a tag on it. The tag. Want to tell to 345 00:45:43.650 --> 00:45:49.920 William Cheng: Tell you the information about that particular item. Okay, so in this case the tag over here will give you are the virtual patient number 346 00:45:50.400 --> 00:45:59.490 William Cheng: Okay, so you need to compare the virtual page number that you're using as a key over here, computer against attack it very equal, that means that the pace table entry right here is the one that you're looking for. 347 00:46:00.210 --> 00:46:09.840 William Cheng: Okay, if they're not equal, that means that this pretty good pace table entry is actually for some other virtual page number. So in this case I need to walk down my collision resolution chance to look for the next tab. 348 00:46:10.560 --> 00:46:17.790 William Cheng: So definitely this place inside one of the partners over here is going to be the link partners, again, the link to the next pointer, you follow this part over here. Go to the next. 349 00:46:18.030 --> 00:46:25.890 William Cheng: Entries over here and then you read the tab over here, compare against your virtual page number if they are equal, that means that this is the page table entry that you're looking for. 350 00:46:26.100 --> 00:46:33.990 William Cheng: That if they are not equal. That means that you need to follow the link over here. Go follow the next one to go to the next one over here compared attack against the virtual page number is 351 00:46:34.170 --> 00:46:40.950 William Cheng: Equal to this is the page table entry that you're looking for. Otherwise, you follow the link point over here. So the next one over here is appointing all 352 00:46:41.490 --> 00:46:46.680 William Cheng: Okay, so when you follow the link part over here. If you get to know. Again, you're going to get you could get another page for all 353 00:46:46.920 --> 00:46:57.900 William Cheng: You guys okay you're trying to optimize this, that, and the audiences that will try to sort of figure out how to fix this page fall if we cannot fix this patient is going to turn into a segmentation. PAUL Yeah alright so this is what a hash. 354 00:47:00.120 --> 00:47:01.980 William Cheng: Hash table. The look at 355 00:47:02.490 --> 00:47:08.130 William Cheng: The pace that weren't true is going to look just like the page table entry before there's a be bit over here, there is the production bit 356 00:47:08.310 --> 00:47:14.970 William Cheng: And there's a physical page number again. You take the physical page number left shifted by our booth at the offset to and they're going to get a physical memory location. 357 00:47:16.110 --> 00:47:19.620 William Cheng: Okay. So in this case, what is going to be the performance of the hash, space, space. 358 00:47:20.100 --> 00:47:23.940 William Cheng: The space table, right. So what is going to be the smallest 359 00:47:24.210 --> 00:47:28.140 William Cheng: You know overhead for a foot foot foot foot foot for you, for you to implement the hyperspace stable. 360 00:47:28.320 --> 00:47:39.210 William Cheng: Now, so in this guy so so that's about it. In the best case, we're still going to end up with four buckets over here and the collision resolution change the look the lingo is over here in the best case, the length of equal to one. 361 00:47:39.870 --> 00:47:48.300 William Cheng: Okay. So in this case, all these things, doesn't exist of yours. All we are having over here are these for you know for data structures over here, how big is each one of these data structure. 362 00:47:48.870 --> 00:47:57.780 William Cheng: Okay, we mentioned before, the page table entries over here is four bytes. All right, the tab over here is going to be for baseball. What is the link for the link over here just a pointer to the next. 363 00:47:58.110 --> 00:48:06.600 William Cheng: Elements and Linda is also, again, it's going to be for baseball. So one of the status or two over here is going to be taught by law we have for that. This is 48 364 00:48:06.960 --> 00:48:14.160 William Cheng: This is 48 bytes long not 48 kilobytes not 40 megabytes. So in this case, the page table overhead over here is going to be 48 by song. 365 00:48:14.850 --> 00:48:22.230 William Cheng: Okay, so we just cut the page table over here from four megabytes to 48 bytes. OK. So again, there's no free lunch. What about the speed 366 00:48:23.070 --> 00:48:36.720 William Cheng: There. So, in the worst case scenario, over here, right. This case of conflict resolution German. In this example, you only have linguists have three. Okay. So in this case, if the page table entry that we're looking for here is inside over here, how many times you have to go into memory. 367 00:48:37.950 --> 00:48:47.700 William Cheng: Okay, so when you try to compare the talk against the virtual based on my where's the time when the tag is sitting, you know, I mean, again, this entire data structure is page table, they are sitting across the bus. 368 00:48:48.180 --> 00:48:52.440 William Cheng: Okay, so therefore, when you try to read the title, you need to go to the zoo you go across device. 369 00:48:52.620 --> 00:49:00.450 William Cheng: And then you compare them. They are not equal. And then you need to go to the link and now you go to the bus. The second time, right, and then you follow the point over here, go to this location over here. 370 00:49:00.630 --> 00:49:03.660 William Cheng: And then you're going to compare to tie you read the buses. The third time. 371 00:49:03.840 --> 00:49:09.420 William Cheng: And you you compare against the virtual page number, they're not equal. And then you get fetch the link again. You got to this point over here. 372 00:49:09.600 --> 00:49:19.500 William Cheng: And then you finish the time again than this kind of the fifth time and then you find out that this tab over here is the same as virtual page number. So now you're going to read the paper entry, you're going to go to the bus. The sixth time 373 00:49:19.710 --> 00:49:29.640 William Cheng: To get a pay stub or entry and then you check the validity of a shocker production bit you take the physical address lifts up by 12 years. And finally, you are you going to visit the physical memory over here at the seventh time 374 00:49:30.870 --> 00:49:39.450 William Cheng: Yeah. So in this case, you're going to end up with 600% overhead and you're gonna end up running seven times slower. And in this case, you know, the comp the collision. 375 00:49:40.470 --> 00:49:51.150 William Cheng: Collision resolution J conflict resolution gender. I mean the same thing right conflict collusion, the same thing. So this guy is the conflict resolution change the length over here, equal to three, you're going to end up with 600% overhead. 376 00:49:51.510 --> 00:49:56.310 William Cheng: Okay, what is this length over here is equal to 10 you're going to end up with 2,000% overhead. 377 00:49:57.300 --> 00:50:07.380 William Cheng: OK. So again, you can see the space time trade out I'm doing really, really well in the space, even if I have a lot of more of these data structure. In the end, each one of these theaters are only cost me 12 bytes. 378 00:50:07.800 --> 00:50:12.840 William Cheng: Okay, so I'm being super efficient in space. But in the end, the performance over here is going to be terrible. 379 00:50:14.100 --> 00:50:26.220 William Cheng: OK. So again, the typical space on trade off. So, so, so this is so this is again. So if you really want to say space over here, this is the best way to go. And later on we're going to see how you actually saw the time problem that 380 00:50:26.880 --> 00:50:38.850 William Cheng: High so to cut down the conflict resolution. The other thing that we can do is I, we can actually put a bunch of pace table entries over here and kosher them together. So this is the cluster, you know, the cluster hash page table. 381 00:50:39.240 --> 00:50:44.250 William Cheng: Okay, so in this example via whenever, whenever we're going to sort of cluster three of them together. So what do we want to do that. 382 00:50:44.610 --> 00:50:49.380 William Cheng: Okay, because in reality, our address space is really not scattered all over the place. 383 00:50:49.590 --> 00:50:58.410 William Cheng: Or address space is typically contiguous right if you have a tech segment over here the tech segment is going to be have contiguous pages over here. So, so you know as i get i guess if you have 384 00:50:58.590 --> 00:51:05.940 William Cheng: You know, sort of study a data structure class, you will learn that the hash table works really, really well. If the access partner is completely random. 385 00:51:06.510 --> 00:51:16.500 William Cheng: Okay, so in this case the the content of the collision resolution chain for every bucket. There will be other, they're going to end up to be the same length or about the same length. So in this case, the hash. 386 00:51:17.100 --> 00:51:27.900 William Cheng: Hash page that will perform really well. Yeah. But in reality, the atmosphere is actually continuous. So therefore, we're going to actually is more reasonable to implement a cluster based on the cost of hash page table. 387 00:51:28.320 --> 00:51:39.630 William Cheng: That. So this is what we will do is that we're going to take the virtual address over here. I want to buy into two parts. One is the the other the virtual as the page number over here. And then what we'll do is that we're going to take the, you know, 388 00:51:40.020 --> 00:51:48.780 William Cheng: Take a virtual page number over here. We're going to feed it to the hash table. So in this case, the hash table only give you two. But guess what, it's like a zero on the other ones bucket about bucket one 389 00:51:49.140 --> 00:52:01.200 William Cheng: Okay. So then let's do exactly the same thing. We're going to take the tab over here and compare against the virtual page number if it is the same. That means that you know the the patient went through that we want is going to be inside this data structure. 390 00:52:02.220 --> 00:52:06.060 William Cheng: So inside this theater shorter when I have a page table entries. Which one do you need 391 00:52:06.270 --> 00:52:15.450 William Cheng: We're going to use the next three days over here and that will give you, you know, 000 is going to give you this one and 1234567 they will give you one of these patient more entries over here. So, 392 00:52:15.840 --> 00:52:25.080 William Cheng: You can put a tag against the Virtual Box number here if they're equal. Use the next three days over here to give you a paper entry and he has validity today you check the 393 00:52:26.310 --> 00:52:30.090 William Cheng: Check the production bed and if everything checks out, then the physical page number over here. 394 00:52:31.980 --> 00:52:36.060 William Cheng: Give you the base address or physical page and they use the offset over here to give you a virtual address 395 00:52:37.020 --> 00:52:42.960 William Cheng: So in this case, you know. So in this case, you know, your overhead is going to be over here is going to be a little bit bigger because it's 396 00:52:43.410 --> 00:52:49.650 William Cheng: A little bigger. So between. Yeah. Why do we do this right, we're trying to cut down the length of the collision resolution check 397 00:52:49.950 --> 00:52:54.660 William Cheng: Right. How much do we gotta do we gotta on the arrows want to cut down the length of the collision resolution change. 398 00:52:54.840 --> 00:52:59.430 William Cheng: By a types, right, because we're going to cluster arrow them together and put them to one at one of these data structure. 399 00:52:59.550 --> 00:53:07.080 William Cheng: So again, it's a good old space I'm trade off that data structure over here is a little bigger, but then the length of the conflict resolution change. That'd be a little shorter. What 400 00:53:08.880 --> 00:53:11.700 William Cheng: Oh I so I guess. 401 00:53:13.680 --> 00:53:18.300 William Cheng: Okay, there's only one thing that we need to look at over here. So I guess I'm gonna sort of finish the last one over here. Okay. 402 00:53:18.720 --> 00:53:21.990 William Cheng: So how do you actually, you know, sort of make the page table here even smaller. 403 00:53:22.500 --> 00:53:31.800 William Cheng: Okay. So as it turns out, they are for every process. If you use a separate page table. So in the end, we're going to still end up with quite a bit over here because a lot of processes over here. There was shared the same page table. 404 00:53:32.370 --> 00:53:42.030 William Cheng: Okay, do I share the same page with a boy entry. And again, because they are sharing the same page frame and the patient will point to the same a physical page. So therefore, so in this case they're actually the last sharing going on. 405 00:53:42.600 --> 00:53:53.610 William Cheng: Okay, so therefore the final page over here but well again is called the inverter page table. So I think in the good old days, or the the the Macintosh operating system. They actually say 406 00:53:54.000 --> 00:54:03.510 William Cheng: That the other the Mac, PC actually use a use of CPU called the Power PC. Check the park PC, Chip, I believe that they use the inverter page table. 407 00:54:03.840 --> 00:54:09.090 William Cheng: There. So in the inverter page table over here. There's only one page table. That's you, that's shared by the entire system. 408 00:54:09.810 --> 00:54:17.010 William Cheng: That is kind of weird that, you know, so if you look up the definition or inverter page table. There was a that this is a page table that's indexed by the physical page number 409 00:54:17.580 --> 00:54:24.270 William Cheng: OK, I can never understand why why why people sort of wrote it that way, because how do you index something by a physical page number 410 00:54:24.570 --> 00:54:31.200 William Cheng: Well, you can't really do that, right, because in order for you to perform. I look up, you need a virtual page number. And now that eventually will give you a physical page number 411 00:54:31.440 --> 00:54:36.510 William Cheng: Right, so you can really start with the physical page number and that will give you a physical page number so that doesn't make sense to me. 412 00:54:37.080 --> 00:54:45.420 William Cheng: Okay, but, you know, that sort of terminologies that when people talk about the inverter pace. They will, they will sit on the page table for some reason is in that index metaphysical page number 413 00:54:45.690 --> 00:54:57.540 William Cheng: Then, so the way this is implemented over here is that since this page table over here to share by the entire process over here in order for us to see if a patient a potential over here is the one that we need. We also need to involve the process identifier. 414 00:54:58.440 --> 00:55:07.830 William Cheng: That. So there will be provided as you want to do the following. We're going to take the virtual address chocolate into two parts over here again the virtual page number is gonna it's gonna be a first 12 is over here. 415 00:55:08.010 --> 00:55:15.900 William Cheng: And the officer is going to be the last fall base over here. Yeah. So what we do is, I'm going to combine the virtual page number with the process ID and feed me 416 00:55:17.670 --> 00:55:21.810 William Cheng: feed into hash function and the hash function or view is going to give us a hospice paste 417 00:55:23.040 --> 00:55:28.020 William Cheng: Give us a bucket number the bucket number, it's going to give us the entry point into the inverter pace able 418 00:55:28.950 --> 00:55:36.900 William Cheng: OK. So again, we're going to take the virtual space number combined with the process ID feed it to a hash function is going to give us a bucket number the bucket number over here is 419 00:55:37.260 --> 00:55:40.710 William Cheng: Going to contain a pointer pointing to our entry inside inverter page table. 420 00:55:41.310 --> 00:55:50.490 William Cheng: Okay. So look at this guy's ago we need to check if the hash table entries over here is going to be the one that we're looking for. So we need to compare against the virtual page number and also the process ID. 421 00:55:50.820 --> 00:56:00.000 William Cheng: Okay, so therefore the the data structure over here is going to come in the process ID and attack, we're going to compare the process ID against the process of the, the, the, the process ID. 422 00:56:00.270 --> 00:56:05.430 William Cheng: Of the, the process is running out of CPU and also going to compare to talk against a virtual patient number 423 00:56:05.820 --> 00:56:09.960 William Cheng: Okay, if there are the same. That means that this is the pace table entry that we're looking for. 424 00:56:10.170 --> 00:56:15.270 William Cheng: If they are not the same. Again, we need to follow the link pointer over here, which is the next pointer pointing the next 425 00:56:15.510 --> 00:56:22.170 William Cheng: The next the next data structure is our hash table. Okay, so then when we go to the next entries over here. Again, what, what should we do right 426 00:56:22.380 --> 00:56:28.560 William Cheng: The next century is over. You're also have a p ID also have a tad we're going to compare the P idea against the p it here competitor tab again this one. 427 00:56:28.770 --> 00:56:36.510 William Cheng: If they are the same, then this is the PTA that we're looking for. Otherwise, before the pointer to the next one. Compare the page or the passes it compare to that. 428 00:56:36.750 --> 00:56:41.490 William Cheng: If they're equal and and this is the patient will ensure that we're looking for. Otherwise, we're going to keep falling Linda's over here. 429 00:56:41.610 --> 00:56:50.280 William Cheng: So in this case, the lingo is can be pretty long over here, I sort of get we only using one inverter paste table and this page table up here. It's going to share by all the processes. 430 00:56:51.120 --> 00:56:54.720 William Cheng: That. So this is going to be the way that you minimize the page table overhead. 431 00:56:55.410 --> 00:57:02.130 William Cheng: Gavin. And this is again the conflict resolution Django. The collision resolution junk can be very, very low again the speed is going to be really, really bad. 432 00:57:02.400 --> 00:57:10.470 William Cheng: Okay, so now we are done with solving a space problem. And then, you know, in the next part of the lecture, we're going to see how you solve the speed problem. Yeah.