WEBVTT 1 00:01:10.770 --> 00:01:11.670 William Cheng: Welcome to lecture. 2 00:01:54.480 --> 00:01:55.200 Lalit Gupta: I have a question. 3 00:01:56.820 --> 00:01:58.620 Lalit Gupta: I just six 4 00:02:00.870 --> 00:02:01.620 William Cheng: Which is nectar. 5 00:02:02.070 --> 00:02:06.630 Lalit Gupta: Nectar six I think slide 41 or 42 6 00:02:06.630 --> 00:02:10.800 Lalit Gupta: Lectures 616 1616 okay 7 00:02:11.370 --> 00:02:13.500 William Cheng: All right, like just 16 8 00:02:16.440 --> 00:02:17.340 William Cheng: sua slide number 9 00:02:18.120 --> 00:02:21.090 Lalit Gupta: 41 earlier for that. 10 00:02:27.780 --> 00:02:29.220 William Cheng: So that's 42 11 00:02:30.720 --> 00:02:31.170 William Cheng: This one. 12 00:02:32.280 --> 00:02:33.330 Lalit Gupta: Yes, yes. 13 00:02:34.770 --> 00:02:35.160 Lalit Gupta: So, 14 00:02:37.110 --> 00:02:39.450 Lalit Gupta: I'm wondering, like, when we do this. 15 00:02:40.680 --> 00:02:52.350 Lalit Gupta: Copy on right so there will be one page, left, right, and we do copy and right so it will display be like a free free by the page or demon 16 00:02:53.820 --> 00:03:04.110 William Cheng: Well, so, you know, it is possible, the grandparent is still using the page. So there needs to be some kind of a data structure inside a kernel basically do some kind of a reference counting 17 00:03:05.130 --> 00:03:10.290 William Cheng: So if nobody's using it. What a free it up. But if somebody's still using it. Then, then you should keep it around. 18 00:03:11.730 --> 00:03:13.320 Lalit Gupta: Okay, so okay so whenever 19 00:03:14.430 --> 00:03:21.240 Lalit Gupta: You know, whenever someone is not referring to that. That means the reference has to go down by one 20 00:03:21.630 --> 00:03:24.210 William Cheng: Yeah so. So in our current assignment. 21 00:03:24.900 --> 00:03:27.630 William Cheng: The pace frame object doesn't have a reference count. 22 00:03:28.110 --> 00:03:37.170 William Cheng: Okay, so it's somebody who owns the page frame. They probably have a restaurant right so so at some level, we don't know exactly. I mean, again, this is all in the implementation dependent 23 00:03:37.530 --> 00:03:43.440 William Cheng: At some level, there has to be some kind of a reference cow that count how many processes are using this page. 24 00:03:44.850 --> 00:03:49.950 William Cheng: Right, if the number of processes are using this page. Go down to zero, then in that case you can free it up. 25 00:03:52.500 --> 00:03:53.040 Okay. 26 00:03:55.710 --> 00:04:03.480 William Cheng: So I think in the in the kernel in the winning source code. If you just keep looking for sort of a field is that a data structure called ref count. 27 00:04:04.290 --> 00:04:13.530 William Cheng: There's quite a few all over the place. So maybe one of them will keep track of, you know, the number of page frames that are you know the number of processes are sharing a piece right 28 00:04:17.250 --> 00:04:17.490 So, 29 00:04:21.030 --> 00:04:38.370 Lalit Gupta: Far this quarter three, even though we are doing this. The this free of this memory will only take place at the very end therapy when we, when the, when the pager demand and dial process will break up to our page or 30 00:04:39.420 --> 00:04:44.940 William Cheng: No, no, no, it's not. I know. So whenever you def Chrome and the reference count to zero. You can free it up. 31 00:04:46.650 --> 00:04:50.970 William Cheng: And we're just like the colonel to source code, right, if you look at the V put code. 32 00:04:51.240 --> 00:04:57.780 William Cheng: You know where you detriment. The Reno's reference count zero inside the function we put it will watch your free lap. 33 00:04:59.580 --> 00:05:00.570 William Cheng: So you don't need to pay 34 00:05:01.080 --> 00:05:01.590 For this 35 00:05:08.550 --> 00:05:13.620 William Cheng: So the purpose of the page idea is to take a page frame that somebody is using right now. 36 00:05:13.800 --> 00:05:18.930 William Cheng: And then they say well you know i i know you're using it, but I need the memory. So, therefore I'm going to free it up. 37 00:05:21.090 --> 00:05:23.010 William Cheng: So page idea is more aggressive than that. 38 00:05:24.660 --> 00:05:31.530 William Cheng: Okay, it will take away a piece frame from somebody who's using it. And then what it does that it will you will adjust the pointer to say, now you don't have it anymore. 39 00:05:34.020 --> 00:05:34.590 Okay. 40 00:05:35.670 --> 00:05:36.120 Lalit Gupta: And 41 00:05:37.470 --> 00:05:38.370 Lalit Gupta: And then 42 00:05:39.390 --> 00:05:48.930 Lalit Gupta: At some point, we call this part bomb, then we will then do we have. So the page number of pages going to decrease right 43 00:05:49.950 --> 00:05:50.160 Lalit Gupta: So, 44 00:05:51.780 --> 00:05:56.340 William Cheng: Number physical pain is always fixed. Why, because it depends on how much physical memory that you have 45 00:05:57.120 --> 00:06:03.060 Lalit Gupta: No, no vendor forking it like every time we forget the number of spiritual to me like until we do some 46 00:06:04.230 --> 00:06:12.750 Lalit Gupta: Operation. The interview to some right operation, the number of page one directly asked from the memory won't decrease 47 00:06:13.020 --> 00:06:19.650 William Cheng: Right, if you, as long as you're sharing it then then yeah, then then then they allocate al Qaeda new one. 48 00:06:20.310 --> 00:06:27.180 William Cheng: But one, you know, one thing that will that will keep increasing right because when you for code, which I'll process you sharing your sharing the stack. 49 00:06:27.930 --> 00:06:41.310 William Cheng: Okay, but as soon as you return from a function, you have to write to the stack. Right. So, therefore, in that case, you have to make a copy of the copy of one of the the page for me inside the stack. So, so, so, so in that case the number will always start increasing, you know, slowly. 50 00:06:43.920 --> 00:06:59.640 Lalit Gupta: Okay, but if it increase and if it agrees and have them like will ok we'll, we'll the form of like if it, if it do too many times, then it seems like we will run out of memory. Memory and the page or demon has to like create things right. 51 00:07:00.060 --> 00:07:13.740 William Cheng: Okay, for the, you know, for for for four weeks, right, when you talk about for bomb. It's a program running on Linux, right. Okay, so we need the way they do the fourth bomb is that when you create a child process, pretty soon the parent will die. 52 00:07:15.060 --> 00:07:23.850 William Cheng: I can't remember exactly how the code works and what he so so you you try to create quick as a good because it inshallah process, but they're all pretty soon they will die. 53 00:07:25.050 --> 00:07:25.620 Lalit Gupta: Okay. 54 00:07:25.860 --> 00:07:27.690 William Cheng: Okay, so therefore you will not use our memory. 55 00:07:31.260 --> 00:07:32.730 William Cheng: And just keep working like crazy. 56 00:07:33.780 --> 00:07:46.350 William Cheng: So, so it says it's kind of a big exercise on you know multi processing multi you know those kinds of stuff and also to make sure that your, your code in doing forecast is is perfect. 57 00:07:49.230 --> 00:07:56.130 Lalit Gupta: Also, when we do this for King, we have the data in the address space, we have this 58 00:07:57.270 --> 00:08:03.420 Lalit Gupta: The user space and this kernel outer space in the form we only have to worry about this user, right. The colonel. 59 00:08:04.020 --> 00:08:06.360 William Cheng: The Colonel doesn't have an address space. 60 00:08:06.990 --> 00:08:10.170 William Cheng: The Colonel knows everything. It doesn't need an address based data structure. 61 00:08:13.800 --> 00:08:15.930 Lalit Gupta: So what does the. So I think when one of the 62 00:08:17.430 --> 00:08:22.260 Lalit Gupta: Data TG before user user speech when you before the Colonel. What is that 63 00:08:23.370 --> 00:08:29.580 William Cheng: Yeah, so the, you know, so, so that's how the the address space is allocated right but but once you get inside, Colonel. 64 00:08:29.850 --> 00:08:42.960 William Cheng: You know all the user processes share the same kernel right so so once you get inside a kernel. What will you try to access address beyond zero XE 0000000 you are inside the Colonel, so. So in that case, you don't need the address space anymore. 65 00:08:44.460 --> 00:08:55.050 William Cheng: So remember, I will. I guess for for this class, most of the time we're talking about a monolithic Colonel right if you're, if you have all the Colonel. When you finish compiling the Colonel. The Colonel sitting on this. 66 00:08:55.650 --> 00:09:01.170 William Cheng: So at that point, you know, if you start running the Colonel. The Colonel knows exactly how many memory location that is using 67 00:09:01.440 --> 00:09:08.490 William Cheng: One memory locations for what you know he knows exactly what's what's going on inside the kernel. It doesn't need a data structure to represent what it already knows 68 00:09:11.790 --> 00:09:16.500 Lalit Gupta: Yes, for, for you, for, for, for, for a single process, we will, they will be 69 00:09:19.830 --> 00:09:22.800 Lalit Gupta: So every don't have like different kernel or 70 00:09:24.930 --> 00:09:26.940 William Cheng: Share right but the happen is that, you know, 71 00:09:27.000 --> 00:09:27.240 The 72 00:09:28.710 --> 00:09:36.720 William Cheng: The Colonel doesn't really know what it's running right so when you run one user space program versus another using Facebook as far as the code is concerned, it's just a user space when 73 00:09:36.930 --> 00:09:48.090 William Cheng: So the colonel visit assume that all their address spaces are different. So that's why they need a data structure to represent every different address space. Well, they all share the same kernels of the Colonel. The Colonel knows what the colonel looks like. 74 00:09:52.050 --> 00:09:58.050 William Cheng: For example, what's inside the Colonel. The Colonel has a slap alligator that can allocate you know process control blog. 75 00:09:58.410 --> 00:10:10.170 William Cheng: Well, it doesn't need an address made representation for is to use the, the, you know, full, full, full, full version you to do, to, to use a sub alligator because he has a global variable that already know how how to use it right 76 00:10:15.150 --> 00:10:23.760 William Cheng: The Colonel doesn't need to know that, you know, here's a data structure that represent the colonel texts that man, here's the data structure. They represent the kernel stacks admin doesn't need that. 77 00:10:26.670 --> 00:10:35.580 Lalit Gupta: But we do what we do are like doing one to one mapping for the colonel, like the one GB outer space of the colonel part 78 00:10:36.180 --> 00:10:43.500 William Cheng: Yeah, if you have less than one GB or physical memory. The Colonel can map directly from the colonel address space, the physical address space, right. 79 00:10:44.250 --> 00:11:03.090 William Cheng: So in the weeks I think a winning said 256 megabytes. So it doesn't have one gigabyte. So what happened is that starting with zero XE 0000000 all the way to zero XE F, F, F, F, F, F, F right there is a way to map every kernel, you know, virtual address to a physical address 80 00:11:04.620 --> 00:11:09.240 William Cheng: Okay, but I don't know if it's actually, you know, the courage and needs that much memory so 81 00:11:11.280 --> 00:11:12.330 Lalit Gupta: I suppose the Phoenix. 82 00:11:13.890 --> 00:11:16.320 Lalit Gupta: Okay, so it seems for us. 83 00:11:17.610 --> 00:11:29.340 Lalit Gupta: In the Phoenix starting from zero x 000 and up to the point we will have like some like 200 or 356 megabytes, whatever. 84 00:11:29.670 --> 00:11:31.590 William Cheng: Right, this is 256 megabytes. Yeah. 85 00:11:32.970 --> 00:11:36.060 Lalit Gupta: Until that we will do a one to one mapping and after that. 86 00:11:36.210 --> 00:11:39.870 William Cheng: What you could do a one to one mapping. I don't know if it's actually done that way. 87 00:11:42.990 --> 00:11:43.320 Oh, 88 00:11:44.580 --> 00:11:53.040 William Cheng: Because, again, this is implementation dependent. Right. So conceptually, you can do one to one mapping and then the colonel can easily access every memory location. So maybe some kernel says, I don't need that much. 89 00:11:54.810 --> 00:11:55.350 Okay. 90 00:11:57.810 --> 00:12:19.830 William Cheng: So if you have to increase those three, there is a command inside the colonel three FAQ is, you know, it's a, it's kind of long. So it's you know it. This is a GDP command colonel colonel info. Right. And then there's one of the one that I asked people to actually this is right here go there. 91 00:12:30.030 --> 00:12:32.760 William Cheng: Oh, sorry. It's the other lecture slides. 92 00:12:33.780 --> 00:12:36.000 Lalit Gupta: We, I want to ask this question on this slide. 93 00:12:36.480 --> 00:12:41.190 William Cheng: Okay, so, so, so this command over here, right, let me 94 00:12:42.750 --> 00:12:43.380 William Cheng: Oops. 95 00:12:47.400 --> 00:12:51.210 William Cheng: Hold on him something is blocking me right here. Okay, there's this command. 96 00:12:52.860 --> 00:13:05.250 William Cheng: Command print out the user address space. Okay, so what you can do that. You can change via map over here to pt two main page table. And then over here, instead of using be a map you can say a pager. 97 00:13:07.470 --> 00:13:07.950 Lalit Gupta: Okay. 98 00:13:08.340 --> 00:13:15.360 William Cheng: So, so this is the kernel information using the function PT nappy info which print out the mapping of the page table. 99 00:13:15.930 --> 00:13:30.180 William Cheng: Okay, and then current progress era P underscore pager. That's the multi level page table, you know, for the, you know, for for x86 right so if you use this command using PT mapping. So in that case, you're printing the content of the page table. 100 00:13:32.280 --> 00:13:37.440 William Cheng: Or. So by looking at this, you will or you can actually see what the virtual address our map the physical address 101 00:13:39.270 --> 00:13:47.910 William Cheng: That. So if you really want to see how, how does a weenies Colonel map. I don't think it maps the entire 256 megabytes. I think in math a little less than that. And also, you know, 102 00:13:48.990 --> 00:13:56.130 William Cheng: Just like a while. I don't know if it's just like that. Remember that for the winnings operating system they divide the physical memory into different zones. 103 00:13:56.790 --> 00:14:05.160 William Cheng: You know, like the beginning part is the DMA zone, followed by, you know, the normal zone and if all about high memes. All I can't remember if we next does exactly the same thing. 104 00:14:08.310 --> 00:14:11.490 William Cheng: OK. So again, these are implementation dependent, you know, 105 00:14:13.920 --> 00:14:19.470 William Cheng: So, so as far as the colonel programmers can. So we don't really care. You know, we just, we just had to allocate memory always do. 106 00:14:20.640 --> 00:14:22.290 William Cheng: And then we just use that 107 00:14:29.670 --> 00:14:39.180 Lalit Gupta: So the user part of the memory is starting from the 000 to make not included as zero x t 000 108 00:14:39.540 --> 00:14:42.270 William Cheng: Where it goes as B, F, F, F, F, F, F, F. 109 00:14:45.690 --> 00:14:47.190 Lalit Gupta: And this is the only 110 00:14:51.780 --> 00:14:58.050 Lalit Gupta: Address that the user can use and after below that address the corner can use 111 00:14:59.040 --> 00:15:10.620 William Cheng: Yeah, so if the user use anything, you know, beyond zero XE 000000 the way the pace table is set up is that you will get a paste fall and you try things out a colonel. The Colonel will kill the user space program. 112 00:15:14.220 --> 00:15:24.240 Lalit Gupta: Doesn't be next for Colonel TV us all the spaces from zero x. See all the effort. 113 00:15:24.540 --> 00:15:30.000 William Cheng: Right, that's the Colonel. Right. But when you start running the hello program, you have to go into the user space. Once you go inside the user space. 114 00:15:30.300 --> 00:15:40.140 William Cheng: If you try to use anything outside of the you know the the allow range. They ain't gonna try things out of Colonel right so yeah because that's not allowed right user space program is not allowed to look into kernel memory. 115 00:15:42.930 --> 00:15:47.580 Lalit Gupta: Yeah. So when we will wrap inside the Colonel. The Colonel also have to use a virtual address this, right. 116 00:15:47.940 --> 00:15:51.450 William Cheng: Yeah, they're the Colonel, can I use physical address so 117 00:15:51.510 --> 00:15:58.050 Lalit Gupta: They're desperate. It will use is like between zero x C 00 and zero FF 118 00:15:58.710 --> 00:16:10.890 William Cheng: Well, so, so in that case again. What is an address space where address the way we sort of talked about is the address space is an abstraction. Right. So when you say use the address space while the colonel can directly use it. The Colonel doesn't need data structure to represent it. 119 00:16:15.180 --> 00:16:20.130 William Cheng: So for example, when you try to access current progress or Prague and kind of white rice cooker progress. 120 00:16:20.430 --> 00:16:29.280 William Cheng: If you want to use this. You don't have to check any data structure, you just go ahead and use it right because because this one has a virtual address and we know that virtual addresses good inside of current. Oh, so therefore you can just use it. 121 00:16:31.290 --> 00:16:34.830 William Cheng: You don't need a data structure to represent you know whether you can use it or not. 122 00:16:37.500 --> 00:16:38.040 Lalit Gupta: Oh, so 123 00:16:39.720 --> 00:16:39.930 William Cheng: This 124 00:16:40.260 --> 00:16:48.960 William Cheng: Is what this is for Linux and Linux, right when you go to Windows maybe Windows has an address page representation for the Colonel, because part of the colonel can be paged out 125 00:16:51.300 --> 00:16:57.030 William Cheng: Okay, so you have a kernel that can, you know, part of it can be paste. Now, what then you will need a data structure to say which one is paid out 126 00:16:57.240 --> 00:17:03.540 William Cheng: Which part is not paid job. But if you have a monolithic Colonel, nothing can be paid out. Well, then in that case, you don't need a data structure to represent it. 127 00:17:08.190 --> 00:17:11.250 Lalit Gupta: So the car broker does can be anything from zero to effort. 128 00:17:12.840 --> 00:17:23.640 William Cheng: It's a monolithic colonel. So when you finish compiling it right we finish compiling and linking you generate the code or executable the linker will figure out what addresses car proc at that time, it becomes fixed 129 00:17:25.350 --> 00:17:33.180 William Cheng: Let's remember the link or his job is to is to relocation and I wouldn't finish students during relocation corporate get an address that address will never change. 130 00:17:35.940 --> 00:17:36.660 Lalit Gupta: Okay. 131 00:17:38.160 --> 00:17:46.440 William Cheng: Right, so, so anybody your kernel code that's accessing corporate you know after linker is done it been relocated, and he will know the address. You can use the address directly 132 00:17:54.150 --> 00:18:06.540 William Cheng: Let's remember all this somebody's car that we see in chapter three. Right. They say, you know, go to this memory location. But now that memory location has a things memory location. So, therefore, you know, then, then, then we don't we don't need the data structure to represented anymore. 133 00:18:14.010 --> 00:18:22.950 Lalit Gupta: So in prop in the proper underscore rock underscore data structure, we have this. I think the page. Dr. Kind of thing. 134 00:18:24.210 --> 00:18:24.570 William Cheng: Right. 135 00:18:24.630 --> 00:18:31.020 Lalit Gupta: So, so it is this is this page corresponds to corner right 136 00:18:33.210 --> 00:18:37.320 William Cheng: Well, so the page. Yeah. So, so the pace table is a colonel data structure. Yeah. 137 00:18:39.450 --> 00:18:44.700 William Cheng: So if you print the address of, you know, P underscore pager, you will get a colonel virtual address 138 00:18:48.390 --> 00:18:54.870 William Cheng: Right and and i think the page. Stir is just allocated for the pager data structure is a kilobytes in size. 139 00:18:55.440 --> 00:19:08.850 William Cheng: So I think the way you need to create a page or you call you know you call one of those functions, either the slab alligator or maybe you can ask the buddy system for, you know, a kilobytes or something like that. I can't remember exactly how they allocate the page directory table. 140 00:19:12.780 --> 00:19:19.860 Lalit Gupta: Yeah. So, in, in the, in the, I think, I think you there was an option that either you can share the page festival or either we can 141 00:19:20.520 --> 00:19:22.890 William Cheng: Look at it separate. I used to make a copy. Yeah. 142 00:19:24.960 --> 00:19:31.470 William Cheng: For for Colonel one. I think if you if you share it, and if we don't free it up the you can pass all the tests. 143 00:19:33.150 --> 00:19:38.490 Lalit Gupta: But now I'm wondering, why should we, why should we not share it because since we're inside the cardinal and the cardinal is like 144 00:19:38.580 --> 00:19:46.050 William Cheng: Well, you're doing Colonel three right what and then then you need to modify the top three quarters of the page table. So if you share it and it's not going to work. 145 00:19:50.850 --> 00:19:57.390 Lalit Gupta: Okay, so it's because we we want it will also share the top quarter. That's right. We create a problem, but why 146 00:19:58.560 --> 00:20:01.260 William Cheng: It's one. One day the strategy. Either you share the whole thing or 147 00:20:02.520 --> 00:20:03.060 William Cheng: You don't share 148 00:20:03.150 --> 00:20:03.600 Okay. 149 00:20:04.620 --> 00:20:08.550 Lalit Gupta: So, okay, that's the problem was not about the bottom one, for it was the 150 00:20:09.780 --> 00:20:10.500 Lalit Gupta: Top three foot 151 00:20:11.040 --> 00:20:18.750 William Cheng: Right, since we have a monolithic Colonel once you set out the bottom one fourth, you know, then then then it never change. Right. So, so once you get into bootstrap 152 00:20:18.990 --> 00:20:29.370 William Cheng: The bottom once what has been set up already. So, therefore, you know, then they can just share it. But then, you know, big because they're running user space program. But then, then, then you're not allowed to share it anymore. 153 00:20:32.070 --> 00:20:42.720 Lalit Gupta: Okay. Suppose we have two processes. Let's say proc one and talk to so each one each one for each one, we have to create this page da right so so 154 00:20:45.000 --> 00:20:47.310 William Cheng: Well, you can share if you never go into the user space. 155 00:20:51.180 --> 00:20:52.740 Lalit Gupta: Yeah that's it and get in our city. 156 00:20:54.750 --> 00:20:56.520 William Cheng: Well, if you're not sharing, you just make a copy 157 00:20:59.460 --> 00:21:00.780 William Cheng: You always copy from the parent 158 00:21:02.400 --> 00:21:03.330 Yes. 159 00:21:07.590 --> 00:21:16.890 Lalit Gupta: Okay, we will make a copy from the parent and and in any in any of the any of the things that we do, we will do the copy will our copy will 160 00:21:18.240 --> 00:21:22.380 Lalit Gupta: No, no pressure will change the bottom one, one quarter of the thing, only the 161 00:21:23.760 --> 00:21:24.750 William Cheng: Noise The colonel. 162 00:21:26.640 --> 00:21:27.120 Lalit Gupta: Okay. 163 00:21:28.110 --> 00:21:36.120 William Cheng: Everything is predetermined. I mean, it's determined at the combine the link time so I call a pre determined because once you start running the Colonel, nothing will change. 164 00:21:38.130 --> 00:21:42.090 Lalit Gupta: Focus on the top three fourth quarter will change. 165 00:21:42.300 --> 00:21:47.070 William Cheng: Right, because you need to be able to run any program. So the top three quarter, you have to set it up. 166 00:21:56.100 --> 00:21:56.670 And 167 00:22:05.040 --> 00:22:07.680 Lalit Gupta: I have a question on our discussion video, I think. 168 00:22:09.840 --> 00:22:10.260 William Cheng: Okay. 169 00:22:11.880 --> 00:22:16.890 Lalit Gupta: I think this slide 29 video 170 00:22:33.030 --> 00:22:38.070 Lalit Gupta: Yes. Yeah, I was not able to understand, like, like one 171 00:22:39.840 --> 00:22:52.740 Lalit Gupta: There are two things that I was confused on one thing, why we have this three VF N and four Ps and the other one is why why we are having line. Not like like 172 00:22:54.000 --> 00:23:06.240 Lalit Gupta: At them like middle of the VF and not like at the bounce like boundary of the VF N one like why we have not we are we are not aligned initiated thing. 173 00:23:06.540 --> 00:23:18.030 William Cheng: So the DA DEE da. I think one of the slides over here to say, you know, the idea is typically page line. I'm not 100% sure if it's possible not to be paid July, so maybe it's always page line. I just don't know. 174 00:23:21.060 --> 00:23:24.510 William Cheng: Okay, so for the readings programming assignments. Maybe it's always page align 175 00:23:27.300 --> 00:23:33.510 Lalit Gupta: So if you as you were speeding gives them yet, then this, this corresponds to to pay to pay to pay streams. 176 00:23:33.690 --> 00:23:38.910 William Cheng: I know if he landed will be got all go go all the way to the left will be starting right here again you know 177 00:23:39.270 --> 00:23:47.160 William Cheng: This is the example that I give to say, you know, if you have a memory segment that's 10 kilobytes. Right. And each one of them is four kilobytes or then the last one over here, you only use two kilobytes. 178 00:23:49.260 --> 00:23:51.090 William Cheng: But you still have to allocate three pages. 179 00:23:56.670 --> 00:24:06.780 Lalit Gupta: Yes, but why why there is no shade shade shade between from zero to somewhere in the middle. In the VF and one 180 00:24:07.500 --> 00:24:09.090 William Cheng: I mean, this part right here. 181 00:24:09.450 --> 00:24:10.440 Lalit Gupta: Yes, yes. 182 00:24:10.710 --> 00:24:21.630 William Cheng: Yeah, because, because we hear what I said at the bottom over here, this V add is typically page ally. I'm not 100% sure if it's possible not to be page line. So therefore I, you know, since I'm not 100% i mean 183 00:24:22.080 --> 00:24:29.100 William Cheng: I didn't, I didn't write the Venus coat coat. I don't know the intention of the developer who designed Phoenix. 184 00:24:30.540 --> 00:24:30.930 Lalit Gupta: OK. 185 00:24:31.290 --> 00:24:38.580 William Cheng: OK. So, therefore, even, even though every instance that I have seen as far as I can remember when students come to me with that with question and things like that. 186 00:24:38.790 --> 00:24:51.690 William Cheng: The add on, you know, the first before memory segment. The first memory location is always page align, but if you want me to say it, I guarantee that's to be page lab. I don't think I can say that because I didn't know. I didn't invent weeks. 187 00:24:52.860 --> 00:24:57.120 Lalit Gupta: So supposedly fear as Jim the spiritual anything for, for instance, let's say this is pretty aligned 188 00:24:57.480 --> 00:25:03.930 Lalit Gupta: Right, so the, so starting from the very first VF and everything will be shaded till the end. 189 00:25:04.380 --> 00:25:16.800 William Cheng: Right. So in this example, right, my memory segment is 10 kilobytes in size. Okay. I have a memory segment the tech segment data or whatever the segment is 10 kilobytes in size, right, how many patients do I need, I need three of them, right. 190 00:25:18.900 --> 00:25:19.830 Lalit Gupta: Yes, three of them. 191 00:25:20.190 --> 00:25:22.470 William Cheng: So that's, that's why I end up with three right 192 00:25:27.480 --> 00:25:35.940 William Cheng: Right, the memory segments 10 kilobytes long I have to have, you know, and the first memory location is page ally. So therefore, in this case, I have to have three page frames to cover it. 193 00:25:37.320 --> 00:25:45.480 Lalit Gupta: Yes, I was thinking if let's say this offset is Lexi. Lexi to kilobyte this offset. 194 00:25:45.540 --> 00:25:47.520 William Cheng: What is off, which offset. 195 00:25:48.450 --> 00:25:51.000 Lalit Gupta: This this off certain this we add 196 00:25:52.650 --> 00:25:53.790 Lalit Gupta: The beginning 197 00:25:54.990 --> 00:25:56.850 William Cheng: So this is that is typical zero. Yeah. 198 00:25:58.260 --> 00:26:04.230 Lalit Gupta: It looks a group of white, then we have to fill everything till the end of the VF N G. 199 00:26:05.430 --> 00:26:08.190 William Cheng: So, so you add 10 kilobytes to. And that's how you get to the end. 200 00:26:11.460 --> 00:26:13.140 Lalit Gupta: If the memory segment is no 201 00:26:13.410 --> 00:26:14.640 William Cheng: Can kilobytes in size. 202 00:26:16.860 --> 00:26:19.440 Lalit Gupta: Okay. In that case, we have to spell till the end of the way of entry. 203 00:26:20.130 --> 00:26:21.330 William Cheng: Or whatever it takes. Yeah. 204 00:26:24.900 --> 00:26:27.900 William Cheng: Well, because the memory said to his virtual addresses. 205 00:26:28.710 --> 00:26:36.900 Lalit Gupta: Because every segment is 10 kilobyte then it seems we have to come to the end because the first one is to provide the middle one is four kilobyte and and one is four kilobyte 206 00:26:37.170 --> 00:26:38.370 William Cheng: Yeah, so you just do 207 00:26:38.370 --> 00:26:40.800 William Cheng: Some math and figure out exactly how many page my money. 208 00:26:42.150 --> 00:26:42.600 Lalit Gupta: Okay. 209 00:26:43.620 --> 00:26:50.370 Lalit Gupta: And and yeah can you also talk about like via we have three three VF N and the 4pm 210 00:26:51.090 --> 00:27:00.330 William Cheng: Yeah so. So, this one doesn't exist, right, because India, I think I also mentioned in the discussion section to say the MO BJ. They don't implement this as a linked list. 211 00:27:00.990 --> 00:27:08.070 William Cheng: Okay. So they're basically implement it using a hash table. So, therefore, this mm LBJ, in the end, only have these three page rain PageRank, two, three, and four. 212 00:27:11.310 --> 00:27:14.340 William Cheng: I mean, if you have a linked list, then you can really skip anything right. 213 00:27:15.150 --> 00:27:27.600 William Cheng: But in this case, since it's not a link. Plus, you know, you don't really need patient I'm zero. So yeah, I mean, again, this is just a sort of a conceptual a picture, since I did not write weeks I don't know exactly what the intention was 214 00:27:30.360 --> 00:27:31.620 William Cheng: I can only guess 215 00:27:34.350 --> 00:27:37.200 William Cheng: Okay, so, so if you read a corresponding page in the 216 00:27:38.400 --> 00:27:48.780 William Cheng: In the colonel colonel three FAQ, right, you will see that this picture was originally come from a student. The student Joe do this. Okay. And it seems to make sense. So therefore, I'm using it. 217 00:27:49.890 --> 00:27:50.250 Lalit Gupta: Okay. 218 00:27:50.520 --> 00:27:52.530 William Cheng: Okay, because I didn't design reasons. 219 00:27:53.550 --> 00:27:55.980 William Cheng: Okay, I'm just using it as a programming assignment. 220 00:27:59.730 --> 00:28:08.490 Lalit Gupta: Okay, so basically it is implemented using a hash table and we just have to give them all the memory object and that page number and it will find us. 221 00:28:08.820 --> 00:28:25.020 William Cheng: Right, so the memory management Object Manager bunch of page frames. Right. Okay, so these patients are page. Now, one, two, and three. Can I hit page down zero maybe in the wind is the, you know, implementation FEMA off people's to what it doesn't really have paste them zero 222 00:28:27.690 --> 00:28:39.840 William Cheng: Right in this, in this example, show you that VF N one map supposed to be fn to master patient three the FM three, Master Page one for. I mean, does it really matter if you're a patient one or now maybe it doesn't matter, right. 223 00:28:41.220 --> 00:28:43.140 Lalit Gupta: Yeah, actually. Yeah. 224 00:28:43.980 --> 00:28:49.950 William Cheng: Right, I mean the lecture, I called this x y AMP Z. Right. So whether there's w or nice. It's kind of irrelevant. 225 00:29:01.770 --> 00:29:15.180 Lalit Gupta: Also like in the kernel three. So we are using in Colonel three this is five Fs, and you said like, since we have done all the pointer thing. 226 00:29:15.930 --> 00:29:34.560 Lalit Gupta: If you have done everything right, so do we. Does we have at point at any point change it in the code, or are we just have to get in the country dot empty just as five Fs to one and it will automatically be the point that will change or we have to change it by hand in the code. 227 00:29:35.790 --> 00:29:48.150 William Cheng: No, no, you don't have to change any of the code when you said when you said f5 FS equal to one, incomplete. I am K, you know. So again, if you read the code, you will see that it was switched to a different file system right inside the 228 00:29:48.630 --> 00:29:49.470 William Cheng: DFS in it. 229 00:29:50.430 --> 00:29:59.370 William Cheng: VF s&s somewhere inside there, you know, instead of using a ram file system, it will use the system system, and he will use the the code that's provided by Brown University. 230 00:30:00.630 --> 00:30:06.510 Lalit Gupta: Okay so DFS route Vivian will automatically point to the S5. Is this 231 00:30:06.750 --> 00:30:07.500 William Cheng: Yes, yeah. 232 00:30:09.510 --> 00:30:13.050 William Cheng: I mean, assuming your carnal to code is correct. Yeah. 233 00:30:30.870 --> 00:30:33.270 Hardik Mahipal Surana: Good morning, Professor, I had a few questions. 234 00:30:34.410 --> 00:30:34.830 William Cheng: Okay, so 235 00:30:37.020 --> 00:30:42.300 William Cheng: Can I just go back to the previous slide over here. You said there you have question about the first couple of slides. Yeah. 236 00:30:43.650 --> 00:30:49.080 Lalit Gupta: Or accurate. Yeah. In the meantime, end of when I was talking or like asking you, I think it was clear. Yeah. 237 00:30:49.260 --> 00:30:49.950 William Cheng: Okay. All right. 238 00:30:50.160 --> 00:30:52.230 William Cheng: Okay, great. Yeah, say, 239 00:30:52.470 --> 00:30:52.740 Yeah. 240 00:30:55.170 --> 00:30:55.950 Hardik Mahipal Surana: Good morning, Professor. 241 00:30:56.280 --> 00:31:03.630 Hardik Mahipal Surana: Money. I had some questions regarding shadow objects. I think around slide number 45 or 15 lecture 16 242 00:31:04.020 --> 00:31:04.560 Lectures 243 00:31:12.390 --> 00:31:14.250 William Cheng: Okay, so this is slide 45 yeah 244 00:31:14.910 --> 00:31:18.480 Hardik Mahipal Surana: I think for the downward the shadow objects are seen 245 00:31:22.890 --> 00:31:24.660 William Cheng: Okay. Should I go down further. 246 00:31:25.590 --> 00:31:27.030 Hardik Mahipal Surana: Yeah, a few slides. 247 00:31:32.250 --> 00:31:34.170 Hardik Mahipal Surana: Yeah, with the process being escalated. 248 00:31:36.330 --> 00:31:49.800 Hardik Mahipal Surana: Okay, so, Olivia before you introduce shadow objects to us. You mentioned the fact that if were the case where the parent process updates some data before it has a fork. 249 00:31:50.580 --> 00:31:58.050 Hardik Mahipal Surana: And the issue of the child process also getting the data access and then we have to actually go and reset that for us to be able to 250 00:31:59.160 --> 00:32:10.050 Hardik Mahipal Surana: For the child not to see the the updates that the parent does later on. Right. So there you mentioned the problem that we may run out of page frames because of repeated folks. 251 00:32:11.550 --> 00:32:13.290 William Cheng: They might run out the page frames. 252 00:32:14.010 --> 00:32:15.870 William Cheng: Okay, so we're going to assume that the buddy system has 253 00:32:15.960 --> 00:32:17.070 William Cheng: Plenty of page frames. 254 00:32:18.540 --> 00:32:20.160 William Cheng: If you're out of memory. There's nothing you can do. 255 00:32:21.630 --> 00:32:22.050 William Cheng: Once the 256 00:32:22.650 --> 00:32:26.340 William Cheng: Once the kernel memory. It has to panic dies. 257 00:32:28.440 --> 00:32:30.060 Hardik Mahipal Surana: Correct. Okay, let me just 258 00:32:31.170 --> 00:32:48.150 Hardik Mahipal Surana: Check if I have understood this correctly so you you explained a reason to us as to why we need shadow mapping and why the current set of work fails in the case of the parent process, make some data change in make some change in the pages before it has the for 259 00:32:50.160 --> 00:32:50.370 Hardik Mahipal Surana: These 260 00:32:51.570 --> 00:32:57.330 William Cheng: Projects is to, you know, so, so, so, so, so, yeah. So once you this copy on right before the fork. 261 00:32:57.570 --> 00:33:01.980 William Cheng: Know you end up with multiple copies. Right. So the purpose of the shadow objects to tell you where to copy from 262 00:33:04.290 --> 00:33:04.680 Hardik Mahipal Surana: Okay. 263 00:33:04.920 --> 00:33:17.130 William Cheng: Right, like this example there are two page x over here. So when you need to perform so. So after that, we do a fork and then you need to do a copy on write you copy from the first X or you want copies on the second x without shadow objects, you will get confused. 264 00:33:18.930 --> 00:33:27.690 Hardik Mahipal Surana: Okay, so the shared objects merely store the reference of where of the closest page where the new process must copy from 265 00:33:28.890 --> 00:33:31.320 William Cheng: Right. Yeah. Because you use the link this data structure. Yeah. 266 00:33:32.520 --> 00:33:41.970 Hardik Mahipal Surana: Okay, okay. So how does this work when we create threads within a process and we have multiple of kernel stacks. 267 00:33:43.260 --> 00:33:43.890 Hardik Mahipal Surana: For the third 268 00:33:45.210 --> 00:33:47.610 William Cheng: Well that's, you know, I mean, 269 00:33:47.640 --> 00:33:51.780 William Cheng: Obviously we're dealing with page frame so it doesn't really matter whether the patient is in the 270 00:33:51.780 --> 00:33:58.320 William Cheng: In the, in the, in that, you know, data side window in the heat segment or in the stack. Secondly, they're all the same. 271 00:33:59.460 --> 00:34:13.920 Hardik Mahipal Surana: Okay, so it respective they would always so if we were to update, let's say, a variable inside of the first procedure of the thread basically in the memory regions, if we, if we look at the address space regions that two point to an anonymous object. 272 00:34:15.450 --> 00:34:18.870 Hardik Mahipal Surana: So you can point to a shadow object which actually points to an anonymous object. 273 00:34:20.100 --> 00:34:30.540 William Cheng: Right, yeah. So, so the colonel doesn't really care about these detail right the Colonel, as far as I'm concerned, you use, you know, your user program is memory segment instead of memory segment it's implemented using page frames. 274 00:34:30.930 --> 00:34:38.010 William Cheng: And then we're doing copy on write inside the PageRank. It doesn't really, you know, it doesn't really attach any semantics to to do all these things. 275 00:34:40.680 --> 00:34:41.370 Hardik Mahipal Surana: Okay, okay. 276 00:34:41.430 --> 00:34:52.350 William Cheng: Right, the picture that you're over here, right here is a memory segment. It's a privately map memory segment and he would just do all this kind of stuff doesn't really matter whether this is stack or this is you know he was this is you know data segment or whatever. 277 00:34:53.580 --> 00:35:02.520 Hardik Mahipal Surana: Okay. So I think in part three of the lecture you explained a case where we create process. See, and then there are multiple data updates that happened. So there are 278 00:35:03.870 --> 00:35:07.170 William Cheng: Continue to there. So over here, eventually, I'm going to create process. See 279 00:35:07.440 --> 00:35:09.720 William Cheng: And then I'm gonna do this modification. Yeah. 280 00:35:10.080 --> 00:35:17.340 Hardik Mahipal Surana: Yes. So basically, as you're doing forks and creating new process, we are creating like a tree of shadow objects. Correct. 281 00:35:17.580 --> 00:35:30.510 Hardik Mahipal Surana: Yeah, so I just want to understand is a shadow object like a light data structure like does, does it require a lot of memory of its own, like is there a possibility, where we run out of memory to allocate us a shadow object. 282 00:35:32.130 --> 00:35:42.930 William Cheng: Well, so if the memories. Yes, this is a memory segment you know example this memory segment only has three page frames. Right. Okay, so what every shadow object can and most keep track of three page for games. 283 00:35:44.610 --> 00:35:45.600 William Cheng: Okay, if this is 284 00:35:46.200 --> 00:35:46.950 William Cheng: The word. I know. 285 00:35:47.640 --> 00:35:48.030 What 286 00:35:49.440 --> 00:35:50.520 Hardik Mahipal Surana: I'm sorry Pisco 287 00:35:51.150 --> 00:36:02.250 William Cheng: Right. So in this example right this memory segment has three page, right. How do we know it has three page. Right, right, because the object at the bottom says x y AMP Z. Right. So there were only three page. Right, right. So when you perform copy on write, you can only do X, Y, or Z. 288 00:36:03.750 --> 00:36:04.110 Hardik Mahipal Surana: Correct. 289 00:36:04.260 --> 00:36:07.170 William Cheng: Okay, so in the worst case, every shadow object will have three page rank. 290 00:36:09.330 --> 00:36:09.870 William Cheng: Okay, but if 291 00:36:10.710 --> 00:36:13.950 William Cheng: This is a memory segment that's that's humongous. That's one gigabyte. 292 00:36:14.790 --> 00:36:18.930 William Cheng: The in that case what every chatter object and have many, many PageRank there. Okay. 293 00:36:19.080 --> 00:36:23.100 Hardik Mahipal Surana: So what really happens when you add another page for him to this bottom object. 294 00:36:25.560 --> 00:36:30.750 William Cheng: So so so in our example we sort of assume that the bottom logic has all the page dreams. 295 00:36:31.140 --> 00:36:40.950 William Cheng: Okay. Because later on. We also look at the other case where you know so. So like in this case over here. Some of the patients are non resident right so we started out with the example we here to say that, you know, 296 00:36:41.460 --> 00:36:53.550 William Cheng: This page for I'm over here. Everything's resident. Okay. So when you say that the number of patient will be here that can grow. So what kind of stuff can grow right the heap segment can grow. Okay, the stack stack man can also grow. 297 00:36:54.330 --> 00:36:54.690 Hardik Mahipal Surana: Yes. 298 00:36:54.990 --> 00:37:01.380 William Cheng: Okay, so in that case. Yeah, but, but eventually when you know at some point it will fill up the address space. Why did not in that case it can grow anymore. 299 00:37:02.580 --> 00:37:14.250 William Cheng: So you can't really go to infinity, right. So if you don't have enough kernel memory eventually when you run on a kernel memory and if everything has recently used well then in that case, you know, your current is going to run out of memory. The economy's gonna die. 300 00:37:17.640 --> 00:37:22.620 Hardik Mahipal Surana: Okay. So you're saying that there's no other case where we don't have all the Patriots to start off with. 301 00:37:24.630 --> 00:37:24.960 Hardik Mahipal Surana: So if 302 00:37:26.220 --> 00:37:31.410 William Cheng: Typically typically typically this is how you start, you start with no patient at the bottom. 303 00:37:31.920 --> 00:37:38.820 William Cheng: Yes. Only way. You asked for it. Then they say oh so so so in the beginning of everything is empty, right when you try to 304 00:37:39.810 --> 00:37:51.240 William Cheng: We do copy. All right, you're going to search all the way to the bottom object and the bottom object says, Oh, well I don't have it, but I know how to create it. Right. So then what it will do is it will create the space when one at a time, whenever you need it will create another one. 305 00:37:53.070 --> 00:38:01.590 Hardik Mahipal Surana: Okay, so what really happens to the size of the shadow object in that case. So initially, if it is empty, the shadow object will not hold any 306 00:38:02.670 --> 00:38:14.520 Hardik Mahipal Surana: References to page frames. Now if you create let's say three page frames the bottom object has three page dream. So what happens to the size because you said the shadow object can hold references to as many page frames that are there in the bottom object. 307 00:38:14.790 --> 00:38:15.390 William Cheng: Right, but the 308 00:38:16.860 --> 00:38:22.560 William Cheng: Full process, B and C. Once you once process leave work will create Great Apostasy right 309 00:38:22.830 --> 00:38:28.740 William Cheng: You reset for copy on right so as far as B and C is concerned, everything below this line or frozen. 310 00:38:29.460 --> 00:38:36.030 William Cheng: Good. Okay. So, therefore, you know, you cannot add more more more more paste right into into the, the, the, the shadow object below. 311 00:38:37.200 --> 00:38:48.510 William Cheng: Okay, other than, you know, other, other than the one that's at the bottom because at the bottom. If there are a patient that's not memory resident on it. Okay, they can still create it, but all the shadow object below that line. They're all frozen. 312 00:38:50.520 --> 00:38:54.960 Hardik Mahipal Surana: Okay. And also, as far as process is concerned. Anything below this line is also frozen. 313 00:38:55.710 --> 00:39:00.840 William Cheng: Faster for process. A, B, and C at the only shadow that you can add them to the first ones. 314 00:39:02.730 --> 00:39:11.370 William Cheng: Okay, so in a way for for every memory segment. The only, you know, patient, they can add to the shadow aka is the first chatter object. All the other ones are considered frozen. 315 00:39:12.780 --> 00:39:14.880 Hardik Mahipal Surana: Okay, so can the shadow of it. 316 00:39:16.230 --> 00:39:29.430 Hardik Mahipal Surana: Like for example in processing. If you let's say I look at some more memory in the heat. So where does that. Is that like a separate bottom object for it or is that directory store in the shadow object, the page frame. 317 00:39:32.010 --> 00:39:40.260 William Cheng: Was over here. It's just a pointer that points to apply to a patient, right, it's a reference to a page. So just a pointer. So just for vice long 318 00:39:40.650 --> 00:39:40.980 Yes. 319 00:39:42.000 --> 00:39:48.480 Hardik Mahipal Surana: My question is that reference is that stone in the shadow object, or do we create a new bottom object for that page for him. 320 00:39:50.160 --> 00:39:52.800 William Cheng: No, no one bottom object is for the memory segment. 321 00:39:55.170 --> 00:40:08.490 William Cheng: Right. I mean, you know, this memory segment right you know as I said at the bottom one over here is the one inside the vino. Okay. So, therefore, that correspond to a memory segment that you map on this into memory, right. 322 00:40:10.140 --> 00:40:16.560 William Cheng: Great. Well, so if you map it from the design the memory, what then you can really grow it unless you somehow make the font bigger 323 00:40:18.420 --> 00:40:25.950 William Cheng: Okay. Oh, of course. If it's a Hebrew stock wondering, okay, Cindy can continue to grow. Rather, you can't really replace that memory segment. 324 00:40:26.610 --> 00:40:27.660 Hardik Mahipal Surana: Oh, okay. I got it. I 325 00:40:28.350 --> 00:40:29.040 William Cheng: Remember segment. 326 00:40:31.020 --> 00:40:31.560 William Cheng: Segment 327 00:40:31.980 --> 00:40:33.090 Hardik Mahipal Surana: Got it, got it, got it. 328 00:40:33.300 --> 00:40:41.100 William Cheng: I guess you could delete the heap segment. If you try to reset Malik and free. I don't know if there's any APIs. We're doing something like that. 329 00:40:41.970 --> 00:40:49.050 Hardik Mahipal Surana: So, so basically, for if you take processes and example there is a separate memory segment which is of reiterate and 330 00:40:50.130 --> 00:40:55.830 Hardik Mahipal Surana: Private nothing but it is an honor. So that will point to a shadow object which points to a different bottom object which is actually 331 00:40:56.940 --> 00:41:03.990 William Cheng: Look at this picture right in this picture eight forks to create be and be forced to create see they're all the same, you know, program. 332 00:41:05.490 --> 00:41:06.030 Hardik Mahipal Surana: Yes. 333 00:41:06.300 --> 00:41:16.920 William Cheng: Right over here. A you know when it first base. He may have you there's a linked list of be a VM area right each one of them represent a representative memory segment. I mean, I'm only joined just one of them. A 334 00:41:18.420 --> 00:41:18.960 Hardik Mahipal Surana: Great, great. 335 00:41:19.350 --> 00:41:25.740 William Cheng: Rise over here I'm just only pay attention to one memory segment that's private the same things that happened to all the other memory segment that are private 336 00:41:26.730 --> 00:41:27.720 Hardik Mahipal Surana: I see. Okay. 337 00:41:28.050 --> 00:41:30.570 William Cheng: But you know the picture will be really ugly if I if I saw 338 00:41:30.690 --> 00:41:31.110 Hardik Mahipal Surana: A Yeah. 339 00:41:31.170 --> 00:41:32.160 Hardik Mahipal Surana: Yeah yeah 340 00:41:33.330 --> 00:41:41.040 Hardik Mahipal Surana: Yeah, I think I got confused because I thought this was like everything, but I didn't realize that it is just one segment and this can be repeated for the same 341 00:41:41.340 --> 00:41:43.590 William Cheng: Right. That's why I draw these arrows. We are right there. Yeah. 342 00:41:46.230 --> 00:41:47.190 William Cheng: So it's a big mess. 343 00:41:48.690 --> 00:42:00.330 Hardik Mahipal Surana: Yeah. So Professor, can you please give some guidance regarding like now looking at know after going through all the lecture material when we start off with, currently, it seems like a lot to just 344 00:42:01.980 --> 00:42:09.330 Hardik Mahipal Surana: Do right in terms of the what's in memory map or them every object files the page frames and the handler and everything so 345 00:42:10.350 --> 00:42:20.610 Hardik Mahipal Surana: I do. I did go through the discussion video to see the phases in which we could split up the implementation, but is there some sort of flow that you could guide us on on on something that we could start off with 346 00:42:21.150 --> 00:42:24.180 William Cheng: Yeah, so let's go there right so that's 347 00:42:31.620 --> 00:42:32.310 Whoops. 348 00:42:34.470 --> 00:42:35.310 William Cheng: We're good to go. 349 00:42:41.040 --> 00:42:42.270 William Cheng: Okay, so 350 00:42:43.320 --> 00:42:55.230 William Cheng: Where's that this is the shadow stuff. Right. Okay. So. So the first thing is you need to get hello to work right. So you need to pay attention to all these all these functions above this red line here about this line right here. 351 00:42:56.460 --> 00:43:10.380 William Cheng: Okay, so what are these functions over here. Right. Okay. So this one. These are the first one you have to do, right, because you know you supposed to do this with do with VM equal to zero. Be equal to zero and S five Fs equal to one. 352 00:43:11.370 --> 00:43:15.180 William Cheng: Okay so clearly. Those are the three things you have to do. And you've got to make sure you pass BFS. 353 00:43:15.660 --> 00:43:27.930 William Cheng: Sorry, I've passed BFS test again because without a reliable file system. There's no, you know, forget about running and a user space program, right, because in order for you to run a user space program, you have to go to the disk and get the address space built 354 00:43:28.680 --> 00:43:31.770 William Cheng: Okay, so this is step one. You got to get these three functions to work now. 355 00:43:33.270 --> 00:43:36.840 William Cheng: Step two is to get the loader to build your address space. 356 00:43:38.700 --> 00:43:54.630 William Cheng: Okay. So remember, there's a loader as an elf 32 right so last time in the discussion section also show you, you know how to look for. So you should do a string search for anything that's VM and a p underscore so so so so the VM AP underscore is one of these functions, right here. 357 00:43:56.070 --> 00:44:00.300 William Cheng: So you got to see which function, you have to implement in order for you to build an address space. 358 00:44:02.400 --> 00:44:07.500 Hardik Mahipal Surana: And creating the artist process involves creating the link list of memory segments. 359 00:44:09.120 --> 00:44:11.730 William Cheng: So, the link is a VM area is called you know 360 00:44:12.960 --> 00:44:24.330 William Cheng: The leaves the VM area is part of the VM app, right, the VM app data structure, I guess, you know, the variable because it's called a map gay the map over here is the virtual memory map. It's your address space. 361 00:44:26.100 --> 00:44:26.460 Hardik Mahipal Surana: OK. 362 00:44:26.700 --> 00:44:29.880 William Cheng: OK, so the job of the loader is to build the address space. 363 00:44:31.200 --> 00:44:32.850 William Cheng: Okay, so you got to get some of these 364 00:44:34.230 --> 00:44:39.270 William Cheng: Things to where you got it. You got to get enough of them to work, work, so that you can finish building the address space. 365 00:44:40.440 --> 00:44:56.550 William Cheng: Okay, okay. So why do you have an address space, you need to clear the page tables that equal to zero for every entry. Okay, so then they need to go into the user space program and then the first thing that will happen is a peaceful right and then you implement this function. 366 00:44:58.620 --> 00:45:04.650 William Cheng: Okay, so this is the third thing you have to do is as a wise you finish building address space, you need to go into the user space as soon as you get into your space you're going to 367 00:45:05.340 --> 00:45:15.360 William Cheng: Run into baseball. So you need to handle. You know, it gives the first page values in the text Tag Manager, you need to get that through to work. And then the second page is going to be the stack segment because you're trying to call me. 368 00:45:15.900 --> 00:45:22.890 William Cheng: So therefore you need to push something onto the stack and I can you gotta get a second page fall and they're going to get a third page fall, you're going to get the fourth page ma, and then 369 00:45:23.250 --> 00:45:35.790 William Cheng: The, the hello program. What it does is that it called the make the system call right, sorry. It makes the open system call okay and then the call. Again, I guess, a call open twice and then it makes the racism call 370 00:45:36.840 --> 00:45:46.320 William Cheng: To I guess to implement the open system call. I mean, there are some point, you need to to to return the permission to say that. Yeah, you could get a paywall here you could not get a page on there. 371 00:45:46.830 --> 00:45:52.890 William Cheng: So I think what you try to implement handle pays for you also need to implement address permission and range from the permission. 372 00:45:54.450 --> 00:45:54.750 Hardik Mahipal Surana: Okay. 373 00:45:55.080 --> 00:45:59.220 William Cheng: Okay. And also, in order for you to support the 374 00:46:01.050 --> 00:46:07.650 William Cheng: The, the stack segment right the stack segment is implemented using the anonymous object. Right, so therefore you need to do all these kinds of stuff. 375 00:46:08.610 --> 00:46:19.110 William Cheng: Well guys, remember the anonymous object is the one that can create a page frame for the stack segment also for the heap segment the hello program doesn't call Malcolm free so therefore the hello pocket doesn't need the heap segment. 376 00:46:20.460 --> 00:46:24.000 William Cheng: Okay, but it still needs the anonymous object to support the 377 00:46:25.860 --> 00:46:27.150 William Cheng: Support that the stack segment. 378 00:46:27.960 --> 00:46:43.440 William Cheng: Okay, okay. So you need to be able to create an anonymous object, you know, increment the reference count document the reference cow, be able to find a page and be able to fill a page with zero and then be able to you know market page dirty or clean or things like that. 379 00:46:45.270 --> 00:46:45.570 Hardik Mahipal Surana: God 380 00:46:45.960 --> 00:46:50.820 William Cheng: OK, so after you do all that. And then finally, when you're in the racism called then you have to implement this right 381 00:46:52.620 --> 00:46:55.770 William Cheng: Raza these all the functions, right over here, this is yeah, there's all the functions. 382 00:46:57.420 --> 00:47:09.840 Hardik Mahipal Surana: Okay. Okay, good. And with respect to the page friend related functions that has to basically handle advocating a page for him, like from the free list and putting it in the in the active list and pending. 383 00:47:10.500 --> 00:47:17.160 William Cheng: Or you just all those code has been written for you already. Right. P frame Darcy is a large file. Lots of there's lots of code in there. 384 00:47:17.730 --> 00:47:27.540 William Cheng: You know only required to write these three functions, right, all the other functions are perfect. You know, so you just have to trust that they work right. All you need to do is to implement the main thing over here is P friend get 385 00:47:28.140 --> 00:47:28.800 Hardik Mahipal Surana: OK. OK. 386 00:47:29.190 --> 00:47:35.850 William Cheng: OK, so P for and get again look at V get p for and get is doing what we get does, but it just for page frame objects. 387 00:47:36.720 --> 00:47:38.970 William Cheng: Right, you get is the one that get a vino 388 00:47:39.000 --> 00:47:40.890 William Cheng: So Pete. Pete friend get is to get a PageRank. 389 00:47:41.700 --> 00:47:50.370 William Cheng: Okay, whereas what you need to understand is that exactly what it means to to to get. I get means to find it if it's there already use it if it's not there was in that case you create a new one. 390 00:47:52.890 --> 00:47:58.530 William Cheng: Okay so page frame. There's one more complication, right, I'm gonna you read a comment blog or right right above where 391 00:47:59.040 --> 00:48:08.850 William Cheng: If you find a page where maybe this patient is busy because it's being transferred in and out of the desk. Well, in that case, you have to wait until it's not busy. You're not allowed to touch it until it becomes not busy. 392 00:48:09.930 --> 00:48:10.290 Hardik Mahipal Surana: Yes. 393 00:48:10.680 --> 00:48:11.970 William Cheng: Okay, so in that case, you know, 394 00:48:12.330 --> 00:48:21.090 William Cheng: As soon as you see it's busy. You have to, you know, go sleep in a queue. And whenever you wake up. You say, Oh, is it still busy. If it's busy. Why then, again, I need to keep going to sleep over and over and over again. 395 00:48:21.300 --> 00:48:25.380 William Cheng: At some point you will become not busy or they can continue to do what you're supposed to do. 396 00:48:27.600 --> 00:48:28.260 Okay, okay. 397 00:48:30.180 --> 00:48:31.950 William Cheng: All right, and the paper and pen and I'm pen. 398 00:48:32.190 --> 00:48:43.260 William Cheng: I mean, I don't really know how important it is because, you know, we never wake up the page. I'll demon so so you know that the purpose of Pinot on piers to play hide and seek with the page it man. But if you never wake up the page on the man, maybe it doesn't really matter. 399 00:48:44.790 --> 00:48:45.690 Hardik Mahipal Surana: OK, I see. 400 00:48:46.320 --> 00:48:55.470 William Cheng: So, so, so, so, you know, to get the hello program to work. You never wake up. We got a piece of page ID, man. So maybe pin and pin. You know, if you don't implement and maybe there's no harm. 401 00:48:56.820 --> 00:48:59.610 William Cheng: I'm not sure, right, because again, I didn't write winnick so 402 00:49:01.290 --> 00:49:08.790 Hardik Mahipal Surana: I can. Okay, okay, okay. Oh, and also, Professor with respect to shadow objects, could you please again. Explain what are the resident means 403 00:49:10.650 --> 00:49:15.840 William Cheng: Oh, for the shadow object, the shadow object only has memory resident patriots. 404 00:49:16.200 --> 00:49:22.470 William Cheng: Right, because you perform copy. All right, already wants to perform copy on write, they become resident unless you swap them out. Right. 405 00:49:22.770 --> 00:49:27.300 William Cheng: But we mentioned that in the winnings operating system. There's no way for you to swap them out because what we would do is, I will pin it 406 00:49:27.690 --> 00:49:32.790 William Cheng: So this way you know the page. I'll demon will never find it. So, therefore, you know, in that case it could ever be swapped out 407 00:49:33.150 --> 00:49:48.090 William Cheng: There. So therefore, for shadow object all the patients must be memory resident while for the anonymous object and also for the been, you know, for, for the memo BJ that inside of vino they can be not memory resident right because those object knows how to create them. 408 00:49:48.720 --> 00:50:02.400 Hardik Mahipal Surana: So when you say memory resident, do you mean that it will always reside in physical memory. Normally when we close the process or when we shut down the operating system that's when we will write down write the changes back to this. If there are reference from a file object. 409 00:50:03.180 --> 00:50:06.450 William Cheng: No memory resident. That means that there's a page frame for it. 410 00:50:07.260 --> 00:50:12.090 William Cheng: Right, people from a look up you'll find it right if you know the you know the enemy LBJ and add the page nom. 411 00:50:12.300 --> 00:50:13.830 William Cheng: When you go to perform and look up you'll find it. 412 00:50:14.640 --> 00:50:18.690 William Cheng: Okay that memory non resident, meaning that when you try to find that it's not there. 413 00:50:19.080 --> 00:50:29.880 William Cheng: Then you can actually ask the MO BJ to create it for you right but but but again if the demo BJ is a shout out, shout out. It doesn't know how to create it. Right, so therefore you have that the shot. Roger only knows how to do copy on write 414 00:50:30.900 --> 00:50:37.410 William Cheng: OK, so the only one that can create it is the one that's it's either the anonymous object or the one that's inside the Beano 415 00:50:41.310 --> 00:50:41.670 Hardik Mahipal Surana: Okay. 416 00:50:42.960 --> 00:50:55.680 William Cheng: Right. So again, we're doing on demand paging when you map a file into your address space in the beginning, the vino object will have you will have zero you know resident pages because we're doing on demand agent. 417 00:50:57.690 --> 00:51:02.670 William Cheng: Right. Why don't you access it for the first time. And then what it would do that, it will bring only that page for this into memory. 418 00:51:04.800 --> 00:51:15.870 Hardik Mahipal Surana: Okay. So I think we have to understand better on what are the functions that the memory object does when it is a standard object. When is it is it is a file object. And when it and it is an anonymous object. 419 00:51:17.220 --> 00:51:22.320 William Cheng: The code. The code is using polymorphous them right so so one of these splinter can point to any of these things. 420 00:51:22.620 --> 00:51:29.670 William Cheng: And also when you call this function, you'll see that for the shadow for the shadow out there for the anomalous jag and also for the you know the 421 00:51:30.960 --> 00:51:44.970 William Cheng: The, you know, there's no BJ inside of a note all the function name are exactly the same except the first part over here is different. Right. They all have, you know, array of function pointer have any have create have Ralph have put have look up page fill page 30 page and clean page. 422 00:51:45.240 --> 00:51:50.160 William Cheng: So if you look at the one that's inside the vino all those function or written for you already. Good. 423 00:51:50.880 --> 00:52:09.810 William Cheng: Okay, so I think it's in the, you know, it's inside the, the, the, the, I think it's in Colonel slash FS right there's a there's a VN FM LBJ, you know, fall over here. That's where all these functions are implemented, you know, for the for the mmm LBJ that live inside the Beano 424 00:52:11.130 --> 00:52:19.350 William Cheng: Ok ok ok so you so you can look. Look at those code, try to look for hints to say so. See how we have to implement anonymous and you know shadow 425 00:52:19.800 --> 00:52:21.930 William Cheng: There. But again, remember that anonymous a shadow 426 00:52:22.200 --> 00:52:32.580 William Cheng: They are a little different. Right. Anonymous. It's about them object. So in a way, it's kind of like the one that the LBJ inside of you know but shadow object, you know, they're very different 427 00:52:34.380 --> 00:52:41.580 William Cheng: Okay, but they have to support exactly the same array of function pointer. So even though some of the function doesn't really make sense for for 428 00:52:42.180 --> 00:52:46.050 William Cheng: For for that object. They still have to have those functions, right. So, you will see that instead of Colonel 429 00:52:46.230 --> 00:52:52.680 William Cheng: There's a comment to say, you know, for this for the anonymous object and for the shadow RJ especially the function of the bottom over here, they say, Oh, these are pretty 430 00:52:53.220 --> 00:53:03.210 William Cheng: Pretty straightforward. Okay. And the reason for that is that because only the the mm will be Jane's out of vino he actually has to do something, but the other ones. They basically they have to have all these functions. 431 00:53:05.460 --> 00:53:06.060 Hardik Mahipal Surana: Okay, okay. 432 00:53:06.510 --> 00:53:09.570 William Cheng: So it's a little weird but this is, you know, pop polymorphous on works. 433 00:53:10.590 --> 00:53:10.950 Hardik Mahipal Surana: Yeah. 434 00:53:13.650 --> 00:53:15.180 Hardik Mahipal Surana: Okay, I think I have more clarity. 435 00:53:16.110 --> 00:53:27.720 William Cheng: Yeah, when you start, you know, try to write these function. And again, I cannot tell you what code right but you should feel free to ask. I mean, the worst. I can tell you this day, you know, maybe she asked her classmates, you know, they can tell you you know will want to do, but that I can't 436 00:53:28.380 --> 00:53:29.100 Hardik Mahipal Surana: Okay, okay. 437 00:53:29.400 --> 00:53:33.270 William Cheng: Yeah, feel free to ask questions. I'll try this. I'll give you more hints, as you know, as you asked questions. 438 00:53:33.630 --> 00:53:35.100 Hardik Mahipal Surana: Sure. Sure. Thank you so much. 439 00:53:35.340 --> 00:53:35.910 William Cheng: Okay. You're welcome. 440 00:53:53.340 --> 00:53:58.260 William Cheng: Anybody else has any more question. If not, I will, you know, stop the recording. 441 00:54:04.740 --> 00:54:06.810 William Cheng: Alright, I'll go ahead and stop the recording.