WEBVTT 1 00:00:14.219 --> 00:00:19.290 William Cheng: Good morning. This is the live lecture nine. Anybody has any question. 2 00:01:00.840 --> 00:01:03.420 William Cheng: Hello, anyone has any question. 3 00:01:20.340 --> 00:01:21.960 Lalit Gupta: So I have a small question. 4 00:01:22.320 --> 00:01:23.730 William Cheng: Sure, so 5 00:01:23.760 --> 00:01:27.810 Lalit Gupta: In I think in the slide 62 or around somewhere. 6 00:01:28.350 --> 00:01:31.230 Lalit Gupta: Okay, yeah, you talk about like the 7 00:01:33.300 --> 00:01:44.040 Lalit Gupta: Developer. Then you go to the developer directory. We do LS minus, then we can look at using the major device number and minor device number we can 8 00:01:45.870 --> 00:01:57.180 Lalit Gupta: Tell what kind of device you connect to and which device you're going to do, but when I do in my computer. This Alice minus l when we I go to this Dave directory 9 00:01:57.900 --> 00:02:00.960 Lalit Gupta: I can see this major and minor device number 10 00:02:01.260 --> 00:02:02.190 William Cheng: You can see it. 11 00:02:02.610 --> 00:02:04.950 William Cheng: Yeah okay so 12 00:02:06.360 --> 00:02:12.060 William Cheng: I think you should, you know, send me a screenshot or something like that via email later. Okay. 13 00:02:43.980 --> 00:02:50.400 Lalit Gupta: Also is also should we also get this major and minor number four in the Mac OS. 14 00:02:52.500 --> 00:02:58.770 William Cheng: Mac OS. Yeah, you should you should do this in Ubuntu, right, because we're doing everything you want to. Okay. 15 00:03:05.400 --> 00:03:09.030 William Cheng: Yeah, I think all the Unix and Linux system. They both work like this. 16 00:03:16.530 --> 00:03:16.980 William Cheng: Yes. 17 00:03:19.260 --> 00:03:26.550 Chao Xiang: Question in the memory cheering at the page free night like 18 00:03:28.320 --> 00:03:28.830 Chao Xiang: Like 19 00:03:29.940 --> 00:03:32.460 Chao Xiang: Every you said in 20 00:03:32.940 --> 00:03:37.470 Chao Xiang: Page 3949 49 okay 21 00:03:42.510 --> 00:03:42.990 William Cheng: This one. 22 00:03:43.650 --> 00:03:47.010 Chao Xiang: Oh yes, like you said, while 23 00:03:48.540 --> 00:03:54.540 Chao Xiang: child. A child and the parents do the writing on the page. They will have a 24 00:03:55.650 --> 00:03:57.870 Chao Xiang: Private a copy as the page, right. 25 00:03:59.790 --> 00:04:03.390 William Cheng: So are we talking about copy own right here. 26 00:04:04.650 --> 00:04:07.320 William Cheng: Okay, so that's for for copy on right yeah okay 27 00:04:10.260 --> 00:04:22.230 Chao Xiang: Yeah, this is where the each get one copy for themselves. So there will be three physical pages. While both child and parents do the writing. 28 00:04:22.680 --> 00:04:35.010 William Cheng: Right. So the example that I gave, is that on this, on this page initially x equal to zero. Right. OK. So now, if we're doing copy on right so what happened is that when you, when the, when the parent says x equals to five. Okay. 29 00:04:35.820 --> 00:04:43.140 William Cheng: Something is going to happen inside the kernel. And then the colonel is going to ask the buddy system for a new page. So we're going to get a new page over here in this page is blank. 30 00:04:43.380 --> 00:04:54.870 William Cheng: And we're going to copy this one over here. And now when we get a copy X over here also equals zero and we change this pointer to point right here and now we're going to do x equal to five by changing this one equal to five. 31 00:04:55.620 --> 00:05:04.080 William Cheng: Okay, and then when the child processes x equal to seven. Right. Again, something happens, is going to be. Is that a colonel, they're going to ask the buddy system for another blank page. 32 00:05:04.320 --> 00:05:13.680 William Cheng: And it's going to copy all these things over. So on this page x is also going to be equal to zero. And then the whole process get to do x equal to seven. And now this will be changing go to seven. 33 00:05:14.160 --> 00:05:24.330 William Cheng: So now this page now has two copies or so. So you're right in the end it's going to have three copies in this copy x equal to seven. In this copy x equal to zero and this copy x equal to five. 34 00:05:26.010 --> 00:05:30.420 Chao Xiang: Also, nobody will change the original physical page right 35 00:05:30.750 --> 00:05:35.070 William Cheng: Exactly. Yeah, because the original page is for sharing. It's for reading 36 00:05:36.840 --> 00:05:38.280 Chao Xiang: Okay, great. Thank you. 37 00:05:38.700 --> 00:05:43.080 William Cheng: Okay so chapter seven. We're going to see a little more detail how this is done. 38 00:06:05.730 --> 00:06:12.330 William Cheng: Also in kernel three, you have, you have to implement this. Yeah, so, so you get a good, good. You get a, get really good at this. 39 00:06:35.160 --> 00:06:37.350 William Cheng: Anyone else has a question. 40 00:06:40.020 --> 00:06:44.520 Lalit Gupta: Oh, actually, I was seeing this thing. Alice minus, there were two numbers. 41 00:06:45.390 --> 00:06:49.050 William Cheng: The first number is the major device number and the second one is the minor device number 42 00:06:49.950 --> 00:06:52.260 Lalit Gupta: And for some of them. There is only one number 43 00:06:54.480 --> 00:07:04.890 William Cheng: Uh, yeah, I don't know why there's only one number. Maybe one number, meaning that there's a, you know, the device controller can only handle one device. So in that case, it's, you know, okay. 44 00:07:05.940 --> 00:07:12.330 William Cheng: I'm not sure. Usually I guess when I usually look at, I see two numbers. Maybe there's some weird devices. Yeah. 45 00:07:14.640 --> 00:07:25.380 William Cheng: Yeah. And also, you know, I guess, the kind of UNIX system that we typically talk about sixth edition you and X, maybe the modern system may be a little different. Right. But the basic idea is still the same. 46 00:07:27.600 --> 00:07:34.860 Lalit Gupta: And and and how, how, what is the range of these number, like how big and how many, how many bytes to take 47 00:07:35.370 --> 00:07:38.550 William Cheng: On how many, how many, how many bytes. 48 00:07:38.940 --> 00:07:39.420 Lalit Gupta: Yeah, like 49 00:07:39.540 --> 00:07:45.330 William Cheng: A major. Yeah, so the major device number is a 16 bit number and the minor device number is a 16 bit number 50 00:07:47.310 --> 00:07:51.930 William Cheng: But usually they're pretty small array index. So there's. Yes, yes. 51 00:08:23.460 --> 00:08:26.040 Andrew Strimaitis: I have a quick question about warm up to 52 00:08:26.490 --> 00:08:27.090 William Cheng: Okay, sure. 53 00:08:27.360 --> 00:08:34.530 Andrew Strimaitis: Um, and this is might be specific for me. I'm just trying to figure out if what I have is actually currently Busy waiting or not. 54 00:08:34.860 --> 00:08:35.640 Andrew Strimaitis: Okay, um, 55 00:08:35.760 --> 00:08:46.470 Andrew Strimaitis: I I've been trying to type in the commands like top and and in GDP to see if it's actually using too much CPU percentage. I guess I just see it fluctuate where 56 00:08:47.010 --> 00:08:56.700 Andrew Strimaitis: It's some moments that point three and then some moments that hits like point seven and like down a point three again like I'm just not sure if what I'm doing is acceptable or not. 57 00:08:57.600 --> 00:09:09.330 William Cheng: So, so if you sort of used the, the method described in chapter two, then you should be okay, right, because what happened is I you know your your thread should be sleeping all the time. 58 00:09:10.560 --> 00:09:14.580 Andrew Strimaitis: Are you talking about the the outline, you put in the discussion slides like for each 59 00:09:14.880 --> 00:09:26.730 William Cheng: Thread uh yeah that part. And also if you're using, you know, if you're waiting for a new tax you call Peter me tax law if you're waiting for a condition to become sure you call Peter condition way if you're doing all those waiting 60 00:09:27.630 --> 00:09:31.740 William Cheng: You know, if your thread is sleeping all the time, then it's not doing busy lady. 61 00:09:33.000 --> 00:09:40.860 William Cheng: Right so busy waiting, meaning that you are waiting for a condition to become true, but you don't give up the CPU. Right, so, so, so, so if you don't call piece of condition where 62 00:09:41.040 --> 00:09:46.920 William Cheng: You keep, you know, lock me attacks and check the value that unlocks monetize keep doing that. Well, then, then you're hogging the CPU. 63 00:09:48.450 --> 00:09:55.080 William Cheng: So so so the important thing is that for the, you know, for the packets and for the tokens to add 64 00:09:55.830 --> 00:10:06.450 William Cheng: You don't need to copy the initial way because they don't have to wait for any condition. Right. Okay. And then for the servers threat if Q1 is empty, you have to give out the CPU by calling piece or a condition way. 65 00:10:07.410 --> 00:10:16.800 William Cheng: And if you are not doing that. You just, you just keep checking whether the queue up. What's up, if you just stay in an infinite loop. Keep checking if Q2 is empty or an hour, then you're doing busy lady. 66 00:10:19.260 --> 00:10:23.040 Andrew Strimaitis: So what do you said if you check the queue. One is empty. 67 00:10:23.340 --> 00:10:33.960 William Cheng: Yeah, I made a mistake. I mean, I mean to to buy because for the server threat they need to wait for the queue to become now not empty, then they can go take a packet and then remove a computer, right. 68 00:10:34.950 --> 00:10:42.000 William Cheng: So, so the way that you should wait for q to the because become not empty, is to bike is to copy recognition way. 69 00:10:44.820 --> 00:10:52.380 William Cheng: Right because another way to do is that you lock me tags Q2 is empty lot me attacks loudmouth tags Q2 is empty, like me, that's that's Busy waiting 70 00:10:55.740 --> 00:11:12.120 Andrew Strimaitis: Because I, I know that your slides you have a general way of describing the server, but then you added more detail where you included like the lines and blue and the lines and blue was a while loop, but within the while loop was the condition. Wait, call 71 00:11:12.150 --> 00:11:12.480 Andrew Strimaitis: Back. 72 00:11:12.690 --> 00:11:21.810 William Cheng: So so so the important thing is that if Q2 is empty, you must call pizza condition way to give up to to go to sleep, right, that would then you're not doing Busy waiting 73 00:11:25.440 --> 00:11:25.860 Andrew Strimaitis: Okay. 74 00:11:27.600 --> 00:11:32.730 William Cheng: Right, because if a kid to is empty. There's the, you have to wait for a package to arrive. Right, so therefore you should, we should go to sleep. 75 00:11:36.390 --> 00:11:38.280 Andrew Strimaitis: Okay, um, 76 00:11:38.820 --> 00:11:52.140 William Cheng: And typically sort of people. People have bugs, towards the end of the program when, you know, I guess. Yeah, if you just stay in a tight loop keep waiting for a variable to become true or false, or something like that. And that's Busy waiting 77 00:12:04.260 --> 00:12:05.280 William Cheng: Does that make sense. 78 00:12:06.570 --> 00:12:08.670 Andrew Strimaitis: Yes, I'm just wondering 79 00:12:10.110 --> 00:12:16.800 Andrew Strimaitis: How like the greatest checking to see if it's are they just going to run top as well to see your CPU fluctuation or 80 00:12:17.730 --> 00:12:21.660 William Cheng: So, so the top just give you a, you know, so 81 00:12:22.770 --> 00:12:25.320 William Cheng: The top doesn't really tell you whether you're doing Busy waiting or not. Right. 82 00:12:26.160 --> 00:12:32.910 William Cheng: But if you are you know if your product is not supposed to be doing anything. And you're eating up all the CPU. 83 00:12:33.390 --> 00:12:38.760 William Cheng: Then there's a good chance that you are doing Busy waiting. Okay, so, so I'm talking about like 84 00:12:40.500 --> 00:12:53.640 William Cheng: Yeah, anyway, so. So if, for example, if your program runs worthy and somehow it just freezes and doesn't really do anything. And if we're on top, we see that you're eating up all the CPU, then chances are you're doing Busy waiting 85 00:12:54.540 --> 00:12:59.310 William Cheng: Okay, right. So, in that case, you know, maybe, maybe we'll look at the code to see if we actually do in Busy waiting 86 00:13:02.400 --> 00:13:07.860 William Cheng: But if you, you know, if you use piece recognition way then then then you're going to be okay. 87 00:13:09.090 --> 00:13:11.040 Andrew Strimaitis: Okay. All right. Thank you. 88 00:13:18.840 --> 00:13:29.310 William Cheng: It's more about you know you understanding your code to to say that you know what you try to wait for something. Did you give out the CPU, right. If the answer is yes, then, then, then, then, then you're not doing Busy waiting 89 00:13:54.240 --> 00:13:55.320 William Cheng: Anyone else 90 00:14:06.240 --> 00:14:13.110 William Cheng: Okay, if nobody else has any questions, I'm gonna stop the recording and then you guys can, you know, talk to each other or whatever. Yeah.