WEBVTT 1 00:00:02.939 --> 00:00:17.760 William Cheng: Welcome to Week six discussion section I'm recording this video a little earlier. So this way you can, you know, learn the material, you know, little earlier. So to get your current one started okay 2 00:00:21.900 --> 00:00:29.640 William Cheng: Alright, so we're going to sort of read some kernel source code last time was sort of, you know, look at K, may we didn't really go over the code. 3 00:00:30.240 --> 00:00:39.180 William Cheng: So I guess. Today, I'm just going to, you know, open this file, and then, you know, look at the coding came a look at coding boot drive and look at the code idle proc Ron 4 00:00:39.540 --> 00:00:54.090 William Cheng: And the other car over here, they're empty right so so the idea here is, is to sort of get an idea of, you know, what do you have to do to get past phase one. Okay, so phase one. Anyways, so we're going to talk about that. 5 00:00:55.980 --> 00:01:00.900 William Cheng: Alright, so I'm going to go switch to my virtual machine as here. 6 00:01:02.910 --> 00:01:12.240 William Cheng: Okay. So inside my virtual machine. So I'm in the Windows directory. So I need to look at a man. Right. So everything is in colonel colonel one into 7 00:01:12.780 --> 00:01:20.460 William Cheng: So there's a directory current over here for the colonel co user for the user code. So in colonel. So if I 8 00:01:21.210 --> 00:01:33.090 William Cheng: do an ls Colonel star star. See, I will look at lots of source code, right. So most of the, I think, for all Colonel assignment. So these are, these are some of the files. 9 00:01:33.900 --> 00:01:45.240 William Cheng: Will not know. So sorry. So the father, you need to implement are a subset of these files. Yeah. So, so let's take a look at the Colonel, the main function, right. So this is the main 10 00:01:46.290 --> 00:02:01.200 William Cheng: Directory. So instead of directory over here. There's a bunch of files over here. So we're going to look at Kmart deceit. I think all the other ones. You don't have to touch. There are implemented for you. So, so let's take a look at K me see. 11 00:02:03.300 --> 00:02:10.830 William Cheng: All right, so, so there's a bunch of include fought over here. I always get the question of, you know, can I add more inclusive out here. So only so 12 00:02:11.490 --> 00:02:18.210 William Cheng: If it's in a file that you need to submit which came in, is one of the one of the file, you have to submit that you can do anything to the file. 13 00:02:18.720 --> 00:02:22.440 William Cheng: Okay, do you want to add as many include out over here. The you want it's perfectly fine. 14 00:02:23.130 --> 00:02:31.830 William Cheng: So it's completely up to you. So, so here's the function came a ok so I'll be here again, you should read the comment blog. This is the first real see function ever call 15 00:02:32.070 --> 00:02:42.030 William Cheng: As I remember you know in Linux in, you know, in the blue process at some point we switch. You know, so, so I guess in the second part we present 16 00:02:42.570 --> 00:02:53.880 William Cheng: Career process zero we turn on our translation. So, and then we're going to call a function and then we go to the third part of the BU. That's what we execute the first see function. 17 00:02:54.330 --> 00:03:04.740 William Cheng: Guys over here for the Linux operating system. The idea is similar, even though at this point there's no process zero guys will get Phoenix is not Linux. This function is called came a so 18 00:03:05.340 --> 00:03:14.010 William Cheng: I guess the idea here is that, you know, if the main function is the first you know function, your user space program or the inside the Colonel. There's a function called gaming. Right, so that will kind of make sense. 19 00:03:14.430 --> 00:03:19.710 William Cheng: Alright, so there's a lot of stuff over here, you can see that it does this. And then that in there. This you know tons of in in in in it. 20 00:03:20.040 --> 00:03:25.830 William Cheng: So again, we don't have to worry about it, and in the end over here, what it does. Over here is that is set up the bootstrap contacts. 21 00:03:26.370 --> 00:03:38.280 William Cheng: Okay, so I think at the end of the last discussions actually mentioned over here it says what it does. Over here is that you know it called context setup is set up a context. So again, in this case, you know, the first argument over here. 22 00:03:39.480 --> 00:03:47.190 William Cheng: So you need to get used to looking at code. This way, right, if the first argument over here is an address of something, there's a good chance that this is actually a return variable. 23 00:03:47.820 --> 00:04:00.600 William Cheng: Okay, so if you pass that data structure over here, then the purpose of this function is to set up, you know, to set up to set up that set up this data structure. Okay, so, so let's take a look at the bootstrap contacts will be or what is the bootstrap contacts. 24 00:04:07.560 --> 00:04:11.910 William Cheng: There booster contacts over here. It's a global variable over here. So, whatever that is. 25 00:04:12.360 --> 00:04:23.310 William Cheng: It's a data surgical contacts or what is the context. So I guess the grip grip context underscore te and Colonel, if you want to look at the header file. They're all under Colonel include rise again star. 26 00:04:23.640 --> 00:04:36.840 William Cheng: Star dot h all the include that there, even though they are more so you will see that there's a file called proxy context hai. So, Colonel include proc context that ah that's go look for that file. 27 00:04:39.030 --> 00:04:46.110 William Cheng: Look at data structure context underscore te right so it's defined right here. Okay, so otherwise. Somebody asked me, you know, 28 00:04:46.920 --> 00:04:53.730 William Cheng: You know what, what is this high def right so again this is, you know, see type does is basically says that this data structure over here. 29 00:04:54.510 --> 00:05:03.660 William Cheng: You know, is is equivalent to context. It was in a way it's sort of given a nickname so contact our See now means that this entire data structure, right. So for this while we can just 30 00:05:04.050 --> 00:05:13.950 William Cheng: Contact I'll see that. So every time you see a gap. That's what it's doing. So some people call this like a macro sort of defined context it to be the other the other the 31 00:05:14.400 --> 00:05:21.720 William Cheng: You know, the, the several lines of SEQUEL. YEAH. Alright, so he's not contact our see there is you know your CPU register. 32 00:05:22.620 --> 00:05:30.090 William Cheng: Okay, so you can see that in this example. You know, I guess, in this context, they don't save all the CPU registers, guys. Oh, maybe this is different from Linux. 33 00:05:30.540 --> 00:05:39.690 William Cheng: But again, this is the winnings optimism. So what it will do is that it will store some of the information over here instead of contact. Right. So what's okay well your CPU go to sleep, or you cause switch to give out the CPU. 34 00:05:40.260 --> 00:05:49.440 William Cheng: You say the CPU stay inside the contact data structure. And then you take the the context that is generating the second argument and you load into the CPU. And so now you know that you when x 35 00:05:49.920 --> 00:05:59.520 William Cheng: This is what a context look like so, so, so, so the, the basic idea over here is that once you set up the contacts you can actually be able to to to switch to a different context. Yeah. 36 00:06:00.270 --> 00:06:08.040 William Cheng: Alright, so the cold over here. Right, so, so good. Will you read all these weeks go over here. Sometimes the name of the function is actually giving you a lot of hint. 37 00:06:08.490 --> 00:06:16.980 William Cheng: Okay, so, so, so take a look at the name of the function and try to make sense out of it. Yeah, this function is called contacts that up. Right. So again, what is contacts that app. So again, I'm going to do, grab 38 00:06:17.640 --> 00:06:26.070 William Cheng: contacts that are Colonel include star star dot h right it's in the context that age. So, Colonel include proc contact age. 39 00:06:27.060 --> 00:06:32.460 William Cheng: So we're sort of tells you what context, it is right so initialize the given context. 40 00:06:32.940 --> 00:06:46.620 William Cheng: So here's the given hundred AXA is the first argument says that when it begin executing it will execute function are glad and are two okay so frank over here is the second argument. The second argument is going to be the first procedure for a threat. 41 00:06:47.190 --> 00:06:54.480 William Cheng: Right, so here it says initializing the given context, such that when it begins execute. So, so what kind of a contact and start executing right 42 00:06:54.810 --> 00:07:02.130 William Cheng: Okay, so certainly it's not, you know, our contacts, because you know contacts with doing a hallway interrupt so so so you sort of think about is that this is talking about a threat contacts. 43 00:07:03.300 --> 00:07:11.490 William Cheng: Okay so initialize the giver threat contacts, right. So, so even though we we saw in the code that we that we just just showing you 44 00:07:11.700 --> 00:07:22.950 William Cheng: It's starting to push up contest. So is boost up contact a threat contacts. Right. So again, technically, it's really not. But it's kinda like a threat contact. So what is kind of like a threat contacts is any kind of content that you can execute C code. 45 00:07:24.060 --> 00:07:30.570 William Cheng: Okay, so, so, so, so again, you know, we don't really call it a threat contest, because there's really no thread that's running because at that time in K may 46 00:07:31.080 --> 00:07:39.180 William Cheng: Have you know there's no process zero. There's no threat zero. There's no process one. There's no fly. So therefore, therefore it's not it's not in a threat contacts. 47 00:07:39.840 --> 00:07:42.360 William Cheng: OK. So again, what is this like contacts. Right. It's an abstraction. 48 00:07:43.350 --> 00:07:51.900 William Cheng: Okay, we're dealing with objections over here. So, so if you're not running a threat, you know, even though you're executing see Co. What kind of contacts, you're in one you know that then you can call it anything you want. 49 00:07:52.560 --> 00:07:57.480 William Cheng: Okay, because we're not in a sec, I wouldn't call a boost our content you can call it the came in contact. We can call it the 50 00:07:57.990 --> 00:08:05.550 William Cheng: I don't know, whatever contacts you that you want to call it there. Okay, there are so, so again, you know, this is how you supposed to think about, you know, 51 00:08:05.970 --> 00:08:09.720 William Cheng: How to Write Colonel so initially given context, such that when it began to execute 52 00:08:10.050 --> 00:08:18.210 William Cheng: Execute the first procedure and the first procedure is different from piece was first procedure piece that first procedure has only one argument. So, this one has to argument, right. 53 00:08:18.540 --> 00:08:26.640 William Cheng: Okay, why does that two arguments. I had no idea. I didn't write this code. So somehow, you know, the Brown University was decided was good idea to have to argument. 54 00:08:27.540 --> 00:08:35.040 William Cheng: You know, so, so, so if you want a little bit historical background, you know, a lot of the windows function. They have two arguments and maybe there's come from windows. I have no idea. Right. 55 00:08:35.340 --> 00:08:47.580 William Cheng: Right, so you are whining are two and then, you know, in order for you to to to to to go to a contest, you see. So again, the idea of yours, and he got executed threat threat need to stock. Right. So therefore, the next argument over here is case that 56 00:08:48.330 --> 00:08:55.470 William Cheng: OK. So again, again, you're supposed to use everything that you have learned in this class so far in order for you to end understand the colonel secret. 57 00:08:56.010 --> 00:09:07.440 William Cheng: Okay, so if you want to execute function in see whether you need a stacks over here is that this one is the Colonel stat. And then the next one over here is the stack size. And then the last one over here. That's the page table. 58 00:09:08.400 --> 00:09:18.450 William Cheng: Okay. So as it turns out that, you know, if you want to execute code you need a page able to perform a translation. Okay, so if you want to set up a context for you also need to provide a page table there. 59 00:09:19.590 --> 00:09:29.310 William Cheng: So that's, that's all we do says you know pee pee pee CTR is the page table that this context will use, right. So again, so. So let's take a little came in over here. So, what it will do is that 60 00:09:30.030 --> 00:09:39.120 William Cheng: This is the, this is the first procedure, the first procedures for cocoa bootstrap or you should be familiar with the functional shovel ready. It takes two arguments zero and zero right now is also zero. 61 00:09:39.630 --> 00:09:52.500 William Cheng: Be stuck over here is going to be the stack for for for this particular you know you'll see function. And then over here, here's the size of the stack. So, so this page size over here should match that the size of the stack. 62 00:09:53.070 --> 00:09:56.880 William Cheng: Okay, so otherwise if they don't match, you're going to be in trouble. Okay. The last argument over here. 63 00:09:57.300 --> 00:10:10.980 William Cheng: Is be P. Dr. So what is BPI over here. So BP do over here, they call a function called PT gas. Okay. The idea here is that when you see these things, you start looking at a graph for this function and and look at the code and see what it does. 64 00:10:11.820 --> 00:10:19.770 William Cheng: Okay. And I mentioned before, some of the some of the codes are very, very tricky, you know, don't try to understand it perfectly, just trying to understand enough so you can use it. 65 00:10:20.280 --> 00:10:31.200 William Cheng: Okay, is over here PT get is that Gallup a stable so good enough. Okay. You don't have to understand how it's getting that that is stable. So PDL over here says he will return a page table. So this case, you know, 66 00:10:31.680 --> 00:10:43.140 William Cheng: You can just do that now. All right. And also, in this case, you're trying to get a paper over here and then it says Kyocera over here is that if the you know the the the the stack for the Bootstrap is not equal to know 67 00:10:43.650 --> 00:10:53.040 William Cheng: So yeah care of certain say this must be true. So the stack over here. Can I be know otherwise gonna say ran out of memory while booting so therefore, in that case, you know, refused to. Yeah. 68 00:10:53.460 --> 00:10:58.380 William Cheng: Alright, so once you set up a contacts over here. So this argument of us going to be the context for 69 00:10:58.590 --> 00:11:03.780 William Cheng: Again, you know, you want to say threat, but now we know that we're not in a threat content so therefore it's really not a threat. 70 00:11:03.990 --> 00:11:10.350 William Cheng: That. So here we can also make a context active. So again, what does it mean to make a contact that if this is not a threat contacts. 71 00:11:10.980 --> 00:11:17.310 William Cheng: Rest of the day, you just want to run sequel. Here is a function that takes to argument. Basically, this is just you want to execute a function 72 00:11:17.910 --> 00:11:24.570 William Cheng: There. So in this case, we say context, make an actor. That means that we're going to start executing code in this function. Okay. 73 00:11:25.500 --> 00:11:31.740 William Cheng: All right. So anyways, so you push our function or where's the bootstrap functions, right here, right, as opposed to what he does your pristine source code. 74 00:11:32.190 --> 00:11:39.540 William Cheng: Here is not yet implemented, right. So again, you know, not to implement over here. It says, you know what assignment. It is what's the name of the function over here. 75 00:11:39.660 --> 00:11:51.480 William Cheng: So what you're supposed to do is to replace this line in line, right. So you can say you can commented out your C plus plus our see style. Anyway, and they and then they, you know, you're supposed to write your code. Okay. 76 00:11:52.830 --> 00:12:03.210 William Cheng: Alright, so, so the idea here is that you should never get to the next slide, because the next slide over here is panic. So if you plan it one day, your car crash. So therefore, we hear read the comment above it rise to 77 00:12:03.570 --> 00:12:07.140 William Cheng: To see what you're supposed to do over here, this function is called from came a 78 00:12:07.410 --> 00:12:17.160 William Cheng: Whereas over here it says it's a function call right even though we said we create a contact and we, you know, make the contacts that are active but overhear. It clearly says this function is called from Amy. 79 00:12:17.940 --> 00:12:28.560 William Cheng: Okay, so therefore the, you know, the way we call function. Maybe it's a little funny inside the Colonel. Okay. Or maybe, so it's only funny when we are not in a threat contacts, if we're in a certain context then can you then can make 80 00:12:29.160 --> 00:12:33.030 William Cheng: Regular function call, because you already have a stag and all that kind of stuff. Yeah. 81 00:12:33.870 --> 00:12:38.880 William Cheng: Alright so here it says it's not running a three years. So, therefore, what you should do over here is that you should create 82 00:12:39.150 --> 00:12:51.150 William Cheng: The, the idol proc which is part of the process with process ID number zero and also whenever you create a process. You got to create a thread. Okay. And then what you do is that you know process zero over here, you know, 83 00:12:52.200 --> 00:12:57.570 William Cheng: But basically the the Adobe. Here's the process zero the threading process zero is going to be like a real threat. 84 00:12:57.930 --> 00:13:06.390 William Cheng: Okay, so therefore, in this case, we need to, you know, again, make that contact active and by switching to the other, to, to, to the first procedure or process zero 85 00:13:07.080 --> 00:13:15.270 William Cheng: Okay, the first procedure or presser has been written for you. This is idle proc run because at the end over here is that if you see anything that's and with underscore run 86 00:13:15.840 --> 00:13:19.950 William Cheng: That means that it's the first procedure for a process right so this process, the idol process. 87 00:13:20.460 --> 00:13:27.600 William Cheng: So again, it takes to argument over here are one and two, and then what it will do is it will create the idol aside the inner product 88 00:13:28.470 --> 00:13:38.280 William Cheng: Guys, but again it proc create a we're going to look for it. Right. It's right here. It's not implemented, right. So over here, were you supposed to do, is that you're supposed to create a process. Number one, that's in 89 00:13:38.700 --> 00:13:48.270 William Cheng: The process. You're also supposed to create the you know the thread in it and then you return of the third as a you know you return the 90 00:13:48.840 --> 00:13:52.680 William Cheng: Appointed to the threat as the return code for for this particular function. 91 00:13:53.190 --> 00:14:03.090 William Cheng: Okay, so therefore, in the unit Prague over here when I return over here is going to return appointed to the NFL. That's all we hear the local variable again read the variable name very carefully. They all try to mean something. 92 00:14:03.960 --> 00:14:07.680 William Cheng: Okay. I mean, when you write your code. Some people use x, y AMP Z doesn't mean anything. 93 00:14:08.250 --> 00:14:13.890 William Cheng: But the winnings people you know they're they're actually trying to be very, very careful. They try to use meaningful argument, right. 94 00:14:14.160 --> 00:14:17.850 William Cheng: Or, you know, the things that are going on in our to, you know, they're supposed to mean anything now. 95 00:14:18.180 --> 00:14:28.200 William Cheng: And then anyway initialize everything right over here says if def vs TS DFS is your current or is it. Number two, so of course right now BFS not defined. So therefore, we're going to ignore all this 96 00:14:28.920 --> 00:14:39.960 William Cheng: Day and then enable interruption. So conceptually what we should think about is that right before enabling right you know is disable interval is disable you are not in a threat contacts. 97 00:14:40.590 --> 00:14:47.880 William Cheng: Okay, so as soon as you enable you know up over here, then the IP is equal to zero. When you, when I go to zero, that means that you're in a threat contacts. 98 00:14:49.020 --> 00:14:51.510 William Cheng: Right. So then what we'll do is, I'm going to make the inner 99 00:14:51.900 --> 00:14:56.370 William Cheng: runabout right so what does it mean to make an interest around about it means that you added to the wrong to you there. 100 00:14:56.580 --> 00:15:07.110 William Cheng: And then you call do way p it to wait for the child process to die right the first argument over here is minus one, that means that we don't really care, we shall process. Okay, just any trial process will do 101 00:15:07.320 --> 00:15:12.540 William Cheng: The second argument should always be zero. The third argument over here. So this one again to return variable. 102 00:15:12.840 --> 00:15:23.460 William Cheng: It says, store the return value into this thing called status here, right. So what a status status go up over here. It's a local variable is it initialize so when this function Return This Year we turn what 103 00:15:23.850 --> 00:15:29.070 William Cheng: Was it again this you know the do AP ID is like the way system call. So when you return your turn to values. 104 00:15:29.280 --> 00:15:41.580 William Cheng: One is the return value over here, which is the process ID of the HR process and then the, the argument over here it says when this function return status will store the return x value for the for the HR process. 105 00:15:43.110 --> 00:15:49.200 William Cheng: Okay, so, so this is telling you that when you implement this function, right, if we go look at way to API IDs is not yet implemented. 106 00:15:49.320 --> 00:15:57.690 William Cheng: So you're supposed to implement. So your implementation needs to make sure that when this function return all the right values will get a return. So, so in this case, you know, 107 00:15:58.140 --> 00:16:01.830 William Cheng: That the parent process is process zero. So which process. I should return 108 00:16:02.190 --> 00:16:12.720 William Cheng: What is she be the child class as a child, I says, the one with process ID number one. So when this function returns how better be equal to one. Okay. So over here, it says K a syrupy ID and he goes to China. 109 00:16:13.200 --> 00:16:21.420 William Cheng: Is what his PhD in net. So again, we don't know what it is. Right. It's a graph P ID and then Colonel include star, star, star age over here it says it's 110 00:16:22.620 --> 00:16:29.160 William Cheng: Equals two one. Okay, so, you know, so he says, it better be able to want otherwise an error message. So again, 111 00:16:29.490 --> 00:16:39.360 William Cheng: You use cursor, you know, try to try to make an assertion to say that you know when this function return this has to be true, that has to be true. That's true. So this way you can catch your buck as early as possible. 112 00:16:39.810 --> 00:16:46.260 William Cheng: Okay, because if the assertion is fair, right, if the assertion is fail your kernel will cause the panic and it would die right there. 113 00:16:47.040 --> 00:16:57.750 William Cheng: Okay, so again it's very, very important to to to crush your kernel. As soon as you see the first bug because he because he ledger Colonel continue to run. Now once you see the first part of the orbiter off. 114 00:16:58.170 --> 00:17:02.520 William Cheng: Right, because all the other all the other thing by executing correctly. So you're just wasting your time. 115 00:17:03.540 --> 00:17:11.100 William Cheng: Okay, so therefore, again, if you want to save your time, then you want to catch the first bug as early as possible. Right. So I strongly encourage people to use cancer as much as you can. 116 00:17:11.250 --> 00:17:23.730 William Cheng: So again, don't confuse this with Section eight of debating on the session of the grading on a is called a required kisser. This kind of care. So, you know, you can add you can add as many as you want, because they don't correspond to anything. Section eight of the reading. 117 00:17:25.020 --> 00:17:32.910 William Cheng: Okay, so if you add all these other kids are over here. You're not going to get credit for. But if you add the care sure that our mission, such as reading done and then you're going to get credit for it. 118 00:17:33.240 --> 00:17:37.320 William Cheng: And so again, there's a big difference between that and for this guy can add as many as you want. 119 00:17:38.130 --> 00:17:49.590 William Cheng: Right, and also over here. The next thing over here says MTP why MTV equal to zero. So, therefore, this is false Chateau de. We don't know what that is. I'm going to skip a DFS would there's nothing as five Fs that's 120 00:17:50.850 --> 00:18:03.750 William Cheng: You need just turn that on and Colonel three. So again, you know, it doesn't do anything. So what it will do is it will print a message use this function with DB G underscore print and this is the measure says we need curl a halter cleanly. 121 00:18:04.920 --> 00:18:13.890 William Cheng: Okay, so when I saw that, you know, you got to make sure that the colonel halts cleanly. That means that you need to execute to the slide. And this slide will print on the print on the console. 122 00:18:14.640 --> 00:18:26.460 William Cheng: So I think, I think this one prints on the console or print in a bunch of terminal. I can't remember. So someone on the screen, you gotta say we, you're going to see when it's hot or cleaning. Right. So this is the very, very important message as far as grading is concerned. 123 00:18:26.970 --> 00:18:34.290 William Cheng: Okay, so if you want to make sure you get credit every time when you turn off the Colonel, you have to see this long get printed, otherwise you're going to lose points. 124 00:18:35.070 --> 00:18:38.760 William Cheng: Okay, so therefore again will you start doing everything. This is where you need to pay attention to. 125 00:18:39.330 --> 00:18:49.410 William Cheng: Make sure that this happened. And then finally, finally, oh, here's a cohort shut down. Right. So. So once it putting that message over here. The next thing that we do is to shut down, you know, to shut down the machine. How does it shut down the machine. 126 00:18:50.460 --> 00:19:00.630 William Cheng: Yeah, so this function over here, execute assembly code as a as I'm over here. So this one is to machine instruction over here. The first one says, See, I see a lie. 127 00:19:00.930 --> 00:19:09.600 William Cheng: You can look at the Intel manual CLA is clear interrupt. So that means disable interrupt. Okay, the second one is the whole machine structure. And we sort of mentioned that in the 128 00:19:10.440 --> 00:19:14.730 William Cheng: In the lecture 10 rise over here. That's how you hold the CPU over here is use the whole machine so 129 00:19:15.180 --> 00:19:22.380 William Cheng: Again, you're not supposed to run, you know, assembly codes, all those articles are written for you already. So if you want to hold the CPU, you need to find inside the winning 130 00:19:22.770 --> 00:19:26.220 William Cheng: Source code which function to call. OK. So again, don't read it this way. 131 00:19:26.640 --> 00:19:40.110 William Cheng: So this particular way over here is how you shut down, shut down the machine. So you clear to interrupt. So now all the inner about the sable and then you hold the CPU. So when you hold the CPU and all the interrupt or disable. Is there any way that your CPU or wake up. 132 00:19:40.770 --> 00:19:51.270 William Cheng: The answer will be no i because I mentioned before, once you how the CPU. The only thing I can wake up the CPU is the intro. But if you disable interrupt why if you don't happen, they become pending and nobody will ever wake up the CPU. 133 00:19:51.600 --> 00:19:55.170 William Cheng: Okay, so this is how you turn off the machine by calling the harsh out down 134 00:19:55.710 --> 00:20:04.110 William Cheng: There. So, so, yeah, the only the only process. They're supposed to turn off the machine is going to be the idol process right either positive way for any deposits that 135 00:20:04.320 --> 00:20:11.400 William Cheng: When they process the died, then what he would do is that he will turn off machine then and what is the job of a process to job. The in the process. Wait for all the 136 00:20:11.730 --> 00:20:20.370 William Cheng: Other processes to die. So, therefore, you know, when the process die, they know that everything else is dead. So therefore, then you can even shut down the chain. Yeah. 137 00:20:21.720 --> 00:20:29.100 William Cheng: All right, so, so that's the first thing that we're going to you know that we have looked at. So now I'm going to go back and 138 00:20:30.300 --> 00:20:30.840 William Cheng: Look at 139 00:20:32.340 --> 00:20:36.390 William Cheng: Second, I'm going to switch to a different share again over here. 140 00:20:38.520 --> 00:20:45.930 William Cheng: Alright, so the next thing that we're going to look at over here that are going to look at some other code. Mainly, you know, favorite test about. I see. 141 00:20:46.410 --> 00:20:57.960 William Cheng: Because they have a test. I see is going to show you more of the sort of third co right we already see one thing circle. And that's the other, that's the the thread that's run inside the DTI to process. Yeah. 142 00:20:58.710 --> 00:21:03.030 William Cheng: So again, I'm going to sort of use the word thread and process interchangeably. 143 00:21:03.630 --> 00:21:08.220 William Cheng: Okay, because who was actually running right of course it's a thread that's running the process and the process actually run 144 00:21:08.730 --> 00:21:16.680 William Cheng: Okay, the process is just a data structure, right, the process is just to control the process control, blah. So the process doesn't really run. So when I say the process is running. I'm talking about 145 00:21:17.010 --> 00:21:22.470 William Cheng: I'm talking about the weenie external we were doing one thread per processor, what I say. The process is running. I'm talking about the threat. 146 00:21:24.060 --> 00:21:30.750 William Cheng: Okay. So, therefore, what we need to do that, we need to go over some of the threat code over here. So again, every third represent a process or if you think about it. 147 00:21:30.990 --> 00:21:34.830 William Cheng: You should think about which processor to represent and we're going to run the code for that process. Yeah. 148 00:21:35.370 --> 00:21:39.780 William Cheng: Alright, so we're going to take a look at a small number of test cases over here because he's our favorite 149 00:21:40.320 --> 00:21:46.740 William Cheng: Test RC they show you a lot of example, what is the right way to write the first procedure for for Colonel threat. 150 00:21:47.490 --> 00:21:56.520 William Cheng: Okay. So your job in current. One is to write all the supporting functions so that favorite thread test so so that favorite test out see will run perfectly okay. That would be a goal. 151 00:21:57.870 --> 00:22:02.250 William Cheng: Right. So again, when you read the code for your favorite test. I see you should keep all these things in mind. 152 00:22:02.850 --> 00:22:09.240 William Cheng: You know, so, so at any line your favorite test, you know, ask yourself, right, what do you look a like a especially when you set a breakpoint there. 153 00:22:09.540 --> 00:22:15.720 William Cheng: Okay, when you get a break point any other line code inside the Colonel, you should ask yourself, where are all the other threats. 154 00:22:16.260 --> 00:22:25.050 William Cheng: Okay, this guy's you were all the processes, because again, they're they're interchangeable there and you know if if a thread is alive. That means that you know 155 00:22:25.620 --> 00:22:30.480 William Cheng: So, so if you set a breakpoint one of the lines over here, right, then you know who's getting the break, fine. 156 00:22:30.900 --> 00:22:37.800 William Cheng: What the flare that's getting the breakpoint is the current threat right because the current slide is the only one that runs out of CPU, because in weenies only have one CPU. 157 00:22:38.790 --> 00:22:48.030 William Cheng: Okay. So whenever you get a breakpoint PR and so it gets to a point where all the other thread right if the other side is dead. What, then, in this case it's you know it's zombies day 158 00:22:48.360 --> 00:22:51.300 William Cheng: All the other thread, they all must be sleeping. Some Q. They could be 159 00:22:51.810 --> 00:22:59.130 William Cheng: They could be in the meat execute it can be in the wrong queue, but they all are sitting in the queue somewhere. So you ask yourself, where are all your threats. 160 00:22:59.520 --> 00:23:05.820 William Cheng: Okay, you need to be able to answer that. If you can't, then you need to read the code a little more. I tried to sort of figure out where it sits there. 161 00:23:06.060 --> 00:23:13.740 William Cheng: And if it says nothing wrong to you what that means that it's going to be in a new tax, who is going to be an IQ is going to be in a some other q i mentioned before. 162 00:23:13.980 --> 00:23:18.210 William Cheng: In when it's kind of, there's no condition variable anymore. Any Q can be a condition variable to 163 00:23:19.140 --> 00:23:28.530 William Cheng: That. So, therefore, if it's sleeping is out to kill who's going to unblock it right. So again, what is blocking and blocking is to pick up that threat from the queue is sleeping on and then moving to thank you 164 00:23:29.310 --> 00:23:35.820 William Cheng: Okay, so this has to be done by another thread right because if you're sleeping. Somebody else need to move you, and somebody else needs to be running inside of CPU. 165 00:23:36.720 --> 00:23:42.060 William Cheng: Okay, so therefore, who's going to do it. Okay, and you need to look at it closer. Oh yeah, over here, this is where it's going to happen. 166 00:23:42.420 --> 00:23:53.370 William Cheng: Okay, you need to be able to identify who is going to wake you up there. And then when they're going to wake your heart going to wake wake you up, you know, which function or they're gonna call. So when you know I'm blocking which functions are they call to unblock you 167 00:23:54.570 --> 00:24:01.830 William Cheng: Or is it again, these are the things that you need to figure out there. All right. And then here again exactly where and how is a particular process to die so so 168 00:24:02.130 --> 00:24:09.990 William Cheng: So in the end, you know, in order for you to be able to shut down the machine and a hold of the Linux kernel clearly what that means that you know 169 00:24:10.290 --> 00:24:20.580 William Cheng: The the the idol process. The process. Nice. Nice. The end. In order for the idol process that we steer that means that in a process has to die in order for any process today. That means that all the other processes has to die. 170 00:24:21.510 --> 00:24:25.440 William Cheng: Okay. So, therefore, you have to ask the question, How did you, how did every, every process every side die. 171 00:24:26.160 --> 00:24:32.880 William Cheng: Okay, so I guess process dying and dying on the same thing right process can execute code. So the third is good. I see people. How does this red dot 172 00:24:33.420 --> 00:24:41.610 William Cheng: Right, it still has to is that what is called Pisa exit understand what a thread exit. Right. And the other way is that, you know, if the third call exit called to exit. 173 00:24:42.210 --> 00:24:53.340 William Cheng: Right. It's like making the exorcism Courtney users may. But again, we don't have user space. So to exit is the kernel version of the Mexico. So again, if you're a call exit. Well, then in that case the process you die, and especially dogs. 174 00:24:54.360 --> 00:25:02.610 William Cheng: Right, so you need to be able to identify the code is a this is where this red dyes. Okay, so either it's going to call K through exit or is gonna call to exit now. 175 00:25:04.380 --> 00:25:12.450 William Cheng: Alright, so let's take a look at the favorites that has over here. So let's think of the first test over here. So I'm going to switch to that display over here and I'm going to come back. 176 00:25:12.900 --> 00:25:26.550 William Cheng: Okay, so, so, so in this case you need to look at Colonel proc there's a favorite test. I see. Okay, so you go to the bottom over here. There's a function called favor threat test. Right, so, so, so, so, so 177 00:25:27.180 --> 00:25:35.520 William Cheng: So maybe a jump look 2000 years. So the assumption over here is that, you know, in order for you to the past phase one, you need to get what I mentioned before, the grid to work right. 178 00:25:35.730 --> 00:25:44.280 William Cheng: And then to get into phase two, you need to set this function to be the first procedure decide you need to call this function from in a program 179 00:25:44.760 --> 00:25:47.730 William Cheng: Right, because in phase one and it probably doesn't do anything. It just returned 180 00:25:48.390 --> 00:25:52.290 William Cheng: To go there, Colonel main Colonel that came in dicey right 181 00:25:52.590 --> 00:26:00.510 William Cheng: This is in a proper. So that's the first procedure for the new threat. So in this case, it doesn't do anything right. He says, not yet implemented and then it returns now. 182 00:26:00.690 --> 00:26:09.780 William Cheng: When it returns know then it process was self terminate. So if you can get this fall, we here. Make sure that you single step and then see where it goes after in a program 183 00:26:10.770 --> 00:26:23.430 William Cheng: Okay, so where would this dysfunction return to, you know, the if you're single step past the past the end of Na na program. Right. It's going to go to the start off I'm shooting for the sweat. 184 00:26:24.090 --> 00:26:29.940 William Cheng: Whereas it again read the code there a single step and define exactly what's supposed to happen. Okay, so this is how a threat self terminate. 185 00:26:30.240 --> 00:26:39.090 William Cheng: Yeah, and also when itself terminated better wake up the parents. The parents that because if it does an independent third whenever wake up, so therefore you need to make sure that that's happening. 186 00:26:41.040 --> 00:26:51.510 William Cheng: So, so, so, so once you pass a zero right then, you know, instead of now you implement it. All you have to do is to call this function again. The first argument zero and the second argument will be no and then you'll be running this code. 187 00:26:52.110 --> 00:27:01.980 William Cheng: Okay, you don't have to, you know, set up a context for it. All you have to do is to call this function. Okay. Alright, so here's my CFO to test gaseous for to test over here initially 188 00:27:02.580 --> 00:27:06.750 William Cheng: My recommendation over here is set equal to one, right. So again, when you try to execute this call over here. 189 00:27:06.990 --> 00:27:14.370 William Cheng: A CFO to to is equal to one, so therefore it's bigger than zero. So, therefore, that means that the first set of tests that we will pass. Are these these that it has over here. 190 00:27:15.300 --> 00:27:22.770 William Cheng: And there was that when they finished executed or this coalesce at our past, when you go to the next part over here says, you know, CSV or two tests, need to be greater than one. 191 00:27:23.070 --> 00:27:30.750 William Cheng: So if it turns out to be equal to one is going to skip all the other co and then what it will do is it will go to the end over here and he will return from, you know, from 192 00:27:31.200 --> 00:27:36.330 William Cheng: From favorites that test over here. So again, if you're if you're in a process called this function. 193 00:27:36.510 --> 00:27:49.320 William Cheng: Well, then this one is done, he will return and then and then again in it proc proc run will return with no and then what it would do is, is that it will it will self terminate, and he will wake up the idol process and the idol possible turn off the machine. 194 00:27:49.950 --> 00:27:59.760 William Cheng: Okay, so, so, so again, you'll face to start with CSP two testing 121 and then once you pass that test you use that to two and then you pass the test set. The three passes tests, etc. Yeah. 195 00:27:59.970 --> 00:28:11.790 William Cheng: So today we're going to sort of briefly take a look at some of the functions over here so you can actually see that how many sub tasks are there. There's one. There's two. There's three. There's four okay there for sub test. The first one over here. 196 00:28:12.240 --> 00:28:18.570 William Cheng: Is called way P ID anytime is the second one over here is called way P ID test, you know. So again, 197 00:28:18.810 --> 00:28:29.910 William Cheng: It doesn't mean anything to you right now. So you should try to sort of make sense out of it. And then, and that's why it's gotta be it's gotta be the case to exit test and then the next one of your mother many tests and then it will print done 198 00:28:31.050 --> 00:28:35.610 William Cheng: Okay, so again, this is how you create messages onto the screen using a DVD function. 199 00:28:36.030 --> 00:28:39.930 William Cheng: The first function. The first argument over here is going to be called DB underscore test. 200 00:28:40.260 --> 00:28:48.690 William Cheng: I don't know if you remember from last time. There's something called conforming DVD called confirming DVDs, you call the first argument over here has to be DVD underscore print 201 00:28:49.680 --> 00:28:56.520 William Cheng: OK. So again, you know, for the, you know, for in the instead of grading gamma one of the section is known as the Self checks in order to you for you to get 202 00:28:56.910 --> 00:29:05.730 William Cheng: The credit for self checks, you have to use the right format. Again he reviewed the last discussion section to to remind you what the right format is 203 00:29:06.450 --> 00:29:14.820 William Cheng: That. Alright, so, so again, let's take a look at some of the code over here. So let's go back to the slides right here, then 204 00:29:15.270 --> 00:29:21.960 William Cheng: Alright, so the first set of hands over here that says, wait, you know, any tests over here. So what it does is that it calls the function called stored proc 205 00:29:22.560 --> 00:29:29.220 William Cheng: Guys are getting used to want to start prod, as it turns out, you look for it twice in the same file. So, so if you go all the way to the top of 206 00:29:30.060 --> 00:29:37.980 William Cheng: Favorite has see over here, their stock price and now we're exploring what it does, right. So the first argument over here against the return value. 207 00:29:38.250 --> 00:29:45.840 William Cheng: So that we, you know, you should remember from chapter two when you call Peter create when people query is finished the first argument is also return value. 208 00:29:46.440 --> 00:29:51.330 William Cheng: Okay, so you shouldn't be surprised that when they're all they're all these function where the first argument is the return value. Yeah. 209 00:29:52.050 --> 00:29:56.280 William Cheng: Well, so here's the data set, you that you try to set up right so here we can start a program here. 210 00:29:56.790 --> 00:30:04.920 William Cheng: Here is the, oh, here's the second one is the name of the chart process. And then the next function over here is going to be the first procedure of the child process. 211 00:30:05.130 --> 00:30:09.780 William Cheng: And I'll be here is going to be our one. I still remember the first procedure takes two arguments are one or two. 212 00:30:10.320 --> 00:30:14.160 William Cheng: So I think in favorites that has all the art to they will always equal to know 213 00:30:14.970 --> 00:30:22.080 William Cheng: Okay. So, therefore, this one is specified are one and this are wanting good 23. Why is it 23 you need to figure out why is it 23 now. 214 00:30:22.620 --> 00:30:31.410 William Cheng: Alright, so let's take a look at this stuff over here. So, so again, what is, you know, what could. What could that mean to to start proc right so the idea here is that you need to start a process. 215 00:30:32.010 --> 00:30:40.290 William Cheng: Guys approximate process right threat thr stress as a threat as over here. We're going to start the process and then we're going to wait for any child process to die. 216 00:30:41.190 --> 00:30:49.500 William Cheng: Right. I mean, this will make sense, right, this has over here. We're going to start a process right instead of a process, it will be a threat. Right. And then, you know. When does that start running 217 00:30:50.430 --> 00:30:56.040 William Cheng: Then we don't know yet. Right. And then what a call way for any went away for any of my child child process to die. 218 00:30:56.730 --> 00:31:00.720 William Cheng: So let's take a look at the code. This is what it looks like. Your first star Prague over here. 219 00:31:01.020 --> 00:31:12.750 William Cheng: Here's the code for Star proc right so what they do is that it called procreate. And this is the function, you have to implement. So I always get email to say, What am I supposed to do is appropriate and I'm going to tell you, I cannot tell you what code right 220 00:31:14.100 --> 00:31:23.070 William Cheng: Okay, so that is what you're supposed to figure out, right, so you're creating a process. So again, what is the process, whereas these are questions you should ask, what is the process a process is just the data structure. 221 00:31:24.780 --> 00:31:33.930 William Cheng: Okay, so where's procreate progress set up that data structure so that data structure is pretty big. What do you have to set up right so people going to ask me, do I have to set this up. I can't tell you what code right 222 00:31:34.710 --> 00:31:41.040 William Cheng: Okay, so you can talk to your classmates say, do I need to set this up to a new setup. Is it okay to leave a feel on initialized. 223 00:31:41.400 --> 00:31:48.540 William Cheng: Okay, or you should always initialize to something so so so yeah the basic rule is that if you have the initial something to some value always set it to zero. 224 00:31:49.290 --> 00:31:55.410 William Cheng: What if it's not supposed to be zero. While hopefully going to catch your error. Pretty soon as they oh they shouldn't be zero, then you change into something else. 225 00:31:56.670 --> 00:32:00.270 William Cheng: Okay, so again, give it a try, and then see if it actually works out. 226 00:32:00.840 --> 00:32:05.700 William Cheng: Okay, so you need to, you know, look at proc read and find out what you have to do. There's a big data surgery to set out 227 00:32:05.910 --> 00:32:13.020 William Cheng: And in the end, what it will do is it will return a pointer to the process control blah right over here, this data storage over here. We're going to store. 228 00:32:13.350 --> 00:32:18.390 William Cheng: You know what the presenter toolbar over here as okay we need a data structure to to to remember 229 00:32:18.570 --> 00:32:27.690 William Cheng: What is the process of what is the threat right so the second argument over here is a PT Dottie over here so that one will point to a threat control block right over here. We're going to call case to create 230 00:32:28.260 --> 00:32:33.060 William Cheng: A career is going to create a threat. So the first argument over here is going to be which process does it belong 231 00:32:33.750 --> 00:32:42.030 William Cheng: Right. So here, PT dot p. Right. That makes sense. I just create a process. Now you can create a threat inside that process there. Here's the first procedure over here. 232 00:32:42.300 --> 00:32:45.300 William Cheng: Over here is the first procedure. So that's the third argument or stock price. 233 00:32:45.540 --> 00:32:51.780 William Cheng: Right. So again, we see before you know how you know this is going to be the first procedure of the of the child threat. So it's gonna be right here. 234 00:32:52.050 --> 00:32:56.610 William Cheng: There are one over here is going to be the fourth argument and our two is always know over here. 235 00:32:57.420 --> 00:33:00.270 William Cheng: Guys, again, you can you can look at the function prototype a case or create a 236 00:33:00.510 --> 00:33:04.380 William Cheng: Case where it creates one of the function, you have to write from scratch again, what are you supposed to do. 237 00:33:04.590 --> 00:33:12.360 William Cheng: You need to suppose the clear three. I don't know how to create that again look at the data structure for the second tool blog and see what you have to set right again review electro 238 00:33:12.960 --> 00:33:17.970 William Cheng: Electro in chapter one. Chapter two, and then started to try to try to connect all the dots that 239 00:33:18.690 --> 00:33:28.980 William Cheng: And then you're going to read this thing kept very carefully. It says cursor right so what these functions are finished call a over here, you know, in favor third test the assert the following has to be true. 240 00:33:29.550 --> 00:33:40.740 William Cheng: PT Dr. P over here has to be done now and PT key over here has been on now. So that makes sense when this one should return. I better have a valid process control blah, I better have a valid throw control block. 241 00:33:41.190 --> 00:33:52.560 William Cheng: There, otherwise over here. I'm going to print this error message. Okay, so there's all Keiser work right well you'll make sure that all these things are true, this is true we hear anyone I print an error message. Otherwise you will print this error message. 242 00:33:53.790 --> 00:33:58.800 William Cheng: That we can actually artificially the credit air and then see what this will do. Right. So this, again, is how you learn. 243 00:33:59.130 --> 00:34:05.160 William Cheng: You know what these things do that. And then what it does. Over here is that it's going to make the threat over here runabout 244 00:34:05.790 --> 00:34:15.120 William Cheng: OK. So again, this is a function that you have to write. Right. So again, read the comment over there to figure out what they have to do over here. But the idea here is that I just created a process, I guess, create a threat and the sweat is in the process. 245 00:34:15.360 --> 00:34:24.180 William Cheng: How do I know the spread is inside the process, right, because the first argument over here tell you what's the proper which processes belong. So therefore, when you finish setting up a data structure, you better make sure that's true. 246 00:34:25.050 --> 00:34:32.310 William Cheng: Okay, otherwise things, you know, things gonna fall apart. So, so, yeah. What do you need to do is you need to make sure that the current data structure is in a consistent state. 247 00:34:32.730 --> 00:34:38.400 William Cheng: Right. So again, part of the game over here, try to sort of figure out what is the consistent state, you know, for the process and for the threat. 248 00:34:38.910 --> 00:34:45.120 William Cheng: Now, all right. And then I'm going to make the square. Run the ball right the argument over here is going to be a threat control, blah. I'm going to add this threat to the wrong queue. 249 00:34:45.390 --> 00:34:57.660 William Cheng: And then over here I said a PPT is not equal to know here Pvt against this argument over here. So in the beginning, all the way I set up this data structure in a local variable here and then I'm going to set off the one that actually gets passed inside. Inside this function. 250 00:34:58.980 --> 00:35:09.180 William Cheng: Okay, so in this case the PPT is not equal to know over here. The first argument not equal to know that this is a return value. So, therefore I'm going to copy this entire data structure over here to amend copy from here to here. 251 00:35:09.750 --> 00:35:14.700 William Cheng: OK. So again, this is a meme copy the first argument is going to be the destination. The second argument is gonna be a source. 252 00:35:14.910 --> 00:35:23.520 William Cheng: And the destination is going to be this one. The source is going to be the address of the local variable and the local variable over here is the one that you set up. And then over here, I'm going to copy all these things over there. 253 00:35:24.540 --> 00:35:33.450 William Cheng: Okay, so remember what you are not supposed to do over here is a pointer point to a variable inside the stack. If you do that, when the function returns. This will turn into garbage. 254 00:35:35.100 --> 00:35:43.110 William Cheng: Okay, so then over here, this is actually very, very important right over here. You, you set up all this is a local variable as soon as your function return this turn into garbage. 255 00:35:43.770 --> 00:35:50.670 William Cheng: Okay, so if you want to keep that information you need to copy it outside of the function or in this example over here. Right. You know, you can see that 256 00:35:51.390 --> 00:35:57.540 William Cheng: You know, the parent process. The other, the other the color function over here, which is the favorite test. 257 00:35:57.930 --> 00:36:06.180 William Cheng: They have a local grab. Oh, oh, I guess, in this case, maybe some global variable you pass the address for it to actually to receive a copy of the local variable right here. 258 00:36:06.780 --> 00:36:15.090 William Cheng: Okay, so therefore this function right before you return it takes local variable copies of the first argument. So now you know this information over here with survive for a much longer time. 259 00:36:16.110 --> 00:36:24.990 William Cheng: Right. Because remember, the local variable over here to your lifetime is the is the function as soon as the function returns they turn to garbage. Okay. Very important message here that 260 00:36:26.070 --> 00:36:34.050 William Cheng: All right, you know, to read all the strings. I'll be here. You know, there are hints for you. You know, if the implementation is correct. This the stream will make perfect sense. Yeah. 261 00:36:35.010 --> 00:36:45.210 William Cheng: Alright, so, so, you know, the argument of us the API API, the test. So this is the first procedure. So now let's take a look at that first procedure right here's the first procedure over here. 262 00:36:45.510 --> 00:36:58.260 William Cheng: Do way P. It tests all it does. Over here is the call to exit with art one over here. Okay, so, so, so, so, so, so this is the first procedure of a child threat right. All it does is to do what a car accident. 263 00:36:59.430 --> 00:37:11.190 William Cheng: Okay, so it's kind of weird that this function over the years is no as well API details. So this one, I tried to to to to check whether your implementation of way to API is correct or not. 264 00:37:12.420 --> 00:37:25.770 William Cheng: Okay, so how do you test that right over here. I'm going to, I'm going to have the child self terminate when they talk. They soft terminated, since we're doing single process for a single thread per process. The process also dead when the process that you should wake out the parent right 265 00:37:27.540 --> 00:37:35.610 William Cheng: OK, so the parent is calling to do AP ID. So what this function return over here. The to exit via the argument over here. So what is the argument for 266 00:37:36.510 --> 00:37:46.650 William Cheng: Why it's going to be the return, Mexico, right. So, so if this argument over here is 23 when this thread when this process die, what should be the return Mexico for this process. 267 00:37:47.130 --> 00:37:56.730 William Cheng: What a baby 23 right so so when the parent receive the process. Exit code over here. They barely see 23 otherwise, you're a bug in your code. Okay, what about the threat Mexico. 268 00:37:58.080 --> 00:38:06.180 William Cheng: Well, the third Mexico is only useful when you are doing multi threading, but since MTP go to zero the Mexico, nobody cares. 269 00:38:06.960 --> 00:38:13.470 William Cheng: Okay, so again, that's the difference between the Mexico and the process. Thanks for the call. The process is very important because the parent process cares 270 00:38:14.100 --> 00:38:21.750 William Cheng: The Mexico, nobody cares. Because there's no other thread inside your process so that we know case, it doesn't matter. Okay. All right. Very important to understand 271 00:38:22.590 --> 00:38:30.330 William Cheng: Okay, so over here so often is that this one just called to exit over here. And the idea here is that you better wake up the parent, you know, 272 00:38:31.440 --> 00:38:31.740 William Cheng: Right here. 273 00:38:33.390 --> 00:38:39.720 William Cheng: Alright, so the parent over. Yo, what else does it do over here. So they also cause a way for any Where's wait for any 274 00:38:45.300 --> 00:38:49.860 William Cheng: Oh yeah, so the call right here. So what it is. Oh, you're a startup process over here. 275 00:38:50.130 --> 00:38:57.030 William Cheng: Then a call boyfriend. So what has worked for me, do I. So let's take a look at what happens over here, right. So again, we just, we just specify a start product. 276 00:38:57.330 --> 00:39:01.440 William Cheng: At the end of star power. We are the child to the monkey is Chelsea running 277 00:39:01.920 --> 00:39:06.240 William Cheng: Well, no, because the parent is still running right so the parents who are running set it up as a child who is not running 278 00:39:06.420 --> 00:39:16.230 William Cheng: But Chelsea is ready to run because sitting inside Iran. Q. It's still sleeping. But now it's waiting for the CPU guys and all the past is going to call way for any what is way for any right way for me is right here. 279 00:39:17.160 --> 00:39:25.440 William Cheng: Okay, so we're for any we're going to call do AP ID. Right. What does it do IP it we're going to wait for the child process to die. So in this case, what are we supposed to do. 280 00:39:25.830 --> 00:39:33.090 William Cheng: Right. So again, the way you wait for something to dissect you add yourself to a queue and then you call so I switched to give up the CPU. 281 00:39:34.830 --> 00:39:41.910 William Cheng: Okay, so that's how you go for something, you add yourself to a queue. Right. So in this case, which you do you do do do do do sleep in. 282 00:39:42.780 --> 00:39:50.580 William Cheng: OK. So again, scan the other. The, the current one FAQ, the kind of want FAQ will tell you which you do to to sleep in. 283 00:39:51.090 --> 00:39:59.490 William Cheng: So I think maybe even in the code for do API to get read the comment blog and it tells you what to do the API, be the comment is that you really long. 284 00:40:00.030 --> 00:40:10.020 William Cheng: Okay, I think there's like 2027 lines over here because this function is complicated. The first argument can be minus one can be, you know, some other values over here. So, so again, you're supposed to implement this function. 285 00:40:10.230 --> 00:40:13.860 William Cheng: This is one of the more complicated function. You have to do it. You have to implement incarnate one 286 00:40:15.000 --> 00:40:21.330 William Cheng: Okay, so yeah. When the parent when the parent process over here called to AP ID. It's like the waist is probably going to wait for the chapter diet. 287 00:40:21.690 --> 00:40:29.430 William Cheng: That. So, therefore, you know, as you enter this function over here, you need to see if there's any so so you check the first argument to see what you have to do. 288 00:40:30.090 --> 00:40:38.070 William Cheng: Okay. So in some cases if the first argument is minus one. In that case, you wait for any child process to die. So you need to check if any child pluses dead. 289 00:40:38.610 --> 00:40:40.710 William Cheng: Right, if any, shall process is dead, then you don't block. 290 00:40:41.160 --> 00:40:53.580 William Cheng: Okay, if it turns out that no child processes that you have to give up the CPU. How do you give up a CPU you add yourself to a queue right again read a comment if I know which is you're supposed to sleep in and then you call switch to give out the CPU. 291 00:40:54.600 --> 00:40:59.880 William Cheng: Okay, so you know example over here the chocolate over here, right, the transfer over here is the API detest 292 00:41:00.090 --> 00:41:05.760 William Cheng: The Chancellor is not running yet rather Chelsea has been created is putting out around kill it hasn't even run for the first time. 293 00:41:05.940 --> 00:41:17.940 William Cheng: So now when the parent called to AP ID at this point is your, you know, we create a one child will create one child process. I mean, I keep like to say chocolate forgets their password and same thing in the week's assignment. 294 00:41:18.690 --> 00:41:27.720 William Cheng: That. So therefore, we create a child processes chakras. It has a sweat over here. It hasn't really run. Yeah. So when you go to play P ID, should any of the child process of be dead. 295 00:41:28.140 --> 00:41:35.220 William Cheng: Well, of course not, because they hadn't even start running yet. Okay, so therefore we have to give out of CPU when we give out the CPU, who is supposed to run 296 00:41:36.840 --> 00:41:42.570 William Cheng: While so in this case the chocolate over here is added to the run through so therefore you're giving your you're giving the CPU to the child threat. 297 00:41:43.980 --> 00:41:48.630 William Cheng: What are your other thread running out of CPU. So maybe you're going to end up giving the CPU to somebody else. That's okay. 298 00:41:49.170 --> 00:41:56.130 William Cheng: Okay. But eventually, everybody will give out the CPU. So eventually, sooner or later, your chapter will run right so in this case we won't happen. 299 00:41:56.640 --> 00:42:06.930 William Cheng: So in this case, what is the parents who are doing the Panthers actually do in the middle of AP ID so address ad itself to a q over here and then the fall asleep by calling switch 300 00:42:07.740 --> 00:42:10.140 William Cheng: Okay, so therefore the parent is in a blocking state. 301 00:42:10.590 --> 00:42:19.320 William Cheng: Okay, now when the child throughout over here called to exit right whatever it is that it was self terminate. And then it will look for the parent to see if the parent needs to be woken up 302 00:42:19.650 --> 00:42:31.350 William Cheng: It is, it is possible. The parent is not ready to wait for the child to die, the parents actually doing something else. So therefore we should do over here is that in the do exit code over here, you should check if the parent is sleeping at the right place. 303 00:42:32.370 --> 00:42:36.540 William Cheng: Okay, if the parent is sleeping at the place where it's supposed to be sleeping. Well, in that case, you wake it up. 304 00:42:37.890 --> 00:42:42.840 William Cheng: Again, we just saw your parents say, You know, I'm going to go take a nap. You know, I'm going to go to my office and take a nap, you know, 305 00:42:43.800 --> 00:42:46.680 William Cheng: When you're done with your homework, you know, come wake me up in the office. 306 00:42:47.160 --> 00:42:52.500 William Cheng: Okay, so when you go to the office and you don't see your parents do you need to wake up your parents. Well, no, because they're not in the office. 307 00:42:52.950 --> 00:43:00.120 William Cheng: So if they're in the office, whether you the ego wake them up. Okay, so here's the same thing. The parents supposed to do to be waiting 308 00:43:00.690 --> 00:43:09.960 William Cheng: And a designated place. So what you do is that he's like to exit. You go to the designated place to wake up your parents. The parents know you wake it up. If it's not there. There's nothing you can do. 309 00:43:10.590 --> 00:43:20.850 William Cheng: Okay, that will be okay because your parents supposed to know what your parents doing okay if the parent is there, how do you wake it up right you remove her from the queue that they're sleeping. Are you moving into around you. 310 00:43:22.500 --> 00:43:36.870 William Cheng: Okay, and then your childhood over here is going to self terminate when itself terminate. You need to wake up. Right. So in this case, you would die eventually at the end when your child is there, what does it have to do it better give up the CPU to another so otherwise. Notice I guess run 311 00:43:37.920 --> 00:43:42.840 William Cheng: Well, so again if the parents. Right. It's not sending the wrong key when given the CPU. That's how the parents that will run again. 312 00:43:44.010 --> 00:43:51.150 William Cheng: OK. So again, this is really weird way. Right. The parent gets the path I get the CPU to the software and then in the end the chocolate has been given CPU back to the parent 313 00:43:51.960 --> 00:44:03.330 William Cheng: Okay, so that, again, the parent of the child, where they are actually working together and favorites that has his test. Testing you to make sure that your implementation is is guaranteeing that this will happen right 314 00:44:04.530 --> 00:44:13.980 William Cheng: So when the parent eventually return from to IP it over here. What is going to be the pod to pod over here, better be the, the, the, the process ID of the child. 315 00:44:14.580 --> 00:44:25.710 William Cheng: Okay. And over here, the return value over here. What's going to be the return value is going to be the return, Mexico, SO WE HERE WHERE YOU DO, CALL TO ANSWER AND DO IT SAYS IS 23 so in this case RV over here. Better be 23 316 00:44:26.220 --> 00:44:40.770 William Cheng: Okay, otherwise the bunk inside your kernel well alright so I'll be here this test over here. What does it do over here it says it makes sure that p it over here is not is not equal to minus each. How is that good or negative number. So again, negative number. Typically, nice and error. 317 00:44:41.970 --> 00:44:51.120 William Cheng: Okay, so. So in this case, you know, you should return or the process idea of a child, but this code doesn't really check it. Is it okay not to check it. Wow, okay. I don't want to assume that favorite 318 00:44:51.690 --> 00:44:57.690 William Cheng: Test is perfect. Okay, so this case it doesn't want to check. So therefore, it's okay. Right. We need to read a cup now. 319 00:44:58.110 --> 00:45:09.870 William Cheng: If it turns out that PR do. So here's an API does not equal to each how, what would you do, right. So in this case, you know, P. It is like what each each are it will print out which child is that so again rediscover your template. It says dB. 320 00:45:10.260 --> 00:45:25.500 William Cheng: DB G tests over here. There. So what do we do, is that it will print out us as child parenthesis percent d, which means that it's going to be the process ID. So the process ID is equal to seven. So this was a child I was a CH CH e LD seven 321 00:45:25.800 --> 00:45:35.040 William Cheng: Accident over here. Current Coca Cola and D, and then it will print out the return ethical value, so it better be what to 23 for our example. 322 00:45:36.390 --> 00:45:43.770 William Cheng: Okay, so I don't really know what the top passes ideas. But again, the idea here is that when everything works perfectly this lie to make sense. So what does this. I'm trying to tell you 323 00:45:44.430 --> 00:45:48.360 William Cheng: Okay, you said all we hear this function is called way for any child to die. 324 00:45:48.600 --> 00:45:59.910 William Cheng: So when the child dies, you will be successful. So in this case, it will return the value does not equal to minus each child and this guy, this this message over here will tell you we child is that he will also tell you what is the exit code for that child. 325 00:46:01.230 --> 00:46:19.230 William Cheng: OK. So again, the message will look at this child, you know, a process ID exodus colon 23 or whatever the number is. OK. So when the greater. Great job, you know, colonel colonel one, the greater would check all these line to make sure all the return error code are correct. 326 00:46:20.970 --> 00:46:24.570 William Cheng: Okay. So, if these numbers are wrong, you're going to end up losing a lot of points. 327 00:46:25.230 --> 00:46:34.470 William Cheng: There. I mean, some people, you know, some people actually don't read the printer. The printer on over the years as a child. And then, you know, some some some random number. So they're not yours. It's minus 328 00:46:35.220 --> 00:46:46.920 William Cheng: A negative big number. How can that be correct. Okay. So again, read the print out. If the printer doesn't make sense. You know, there's a bug is a bug in your code. Okay, or you should ask me questions, hey, you know, this is supposed to be like this. Right. 329 00:46:48.360 --> 00:46:54.360 William Cheng: And when this one should return you will also return the P idea of the child. So again, the way for API do over here as a way for any over here. 330 00:46:54.960 --> 00:47:03.360 William Cheng: So this one returned to pee ID, but in the previous case over here. It's not checking the return code again you're allowed to do that. OK. So again, that will be the end of the first test. 331 00:47:04.410 --> 00:47:08.250 William Cheng: Okay, and then it will go through the second sub tasks over here. The second sub tasks over here it says 332 00:47:08.490 --> 00:47:24.570 William Cheng: This one is called the way P ID test that. And then it started a process over here. And this process is called the way big test and then it says do way P ID over here 2323 over here. So this guy is a way for a child process called 2323 333 00:47:25.110 --> 00:47:39.090 William Cheng: There. And then over here is going to be the root of the return of Mexico. And then if the pod over here is not equal to minus each are for us. Okay. We, the, the comment blocking do AP ID to see under what condition is to return minus each 334 00:47:40.440 --> 00:47:55.650 William Cheng: There's, I think you should return minus each, how will you say to do a PhD and this process has no child processes that that this was no child processes that so so if a process. There's no trial process where you said to calculate the idea is to return the error code. 335 00:47:57.030 --> 00:48:04.680 William Cheng: Guys, and this guy. He will return to Erica with each other, say I'd know child processes. Why do you bother to call to AP ID. Right. So in this case, what I call do at it. 336 00:48:04.860 --> 00:48:19.260 William Cheng: Is that I want to work for a child process was process ID equals 223 23 when you say again return error code is there is no child process with the process ID 2323 now. So therefore, in this case, you know, if you return a value that's not equal to the to each out 337 00:48:20.400 --> 00:48:28.980 William Cheng: Okay so knuckles over here, you know, then it's an air conditioning. Right. So again, you will print the error message over here using the same function call is that DVD DVD jazz. 338 00:48:29.250 --> 00:48:34.530 William Cheng: A lot of weight on non existent P ID. So in this case, this is actually an error message. 339 00:48:35.520 --> 00:48:40.080 William Cheng: There. So how do you know that this is an error message. While the previous case over here, this is not error message. 340 00:48:40.740 --> 00:48:44.490 William Cheng: OK. So again, you have to read the code over here to understand what it, what it does. 341 00:48:44.790 --> 00:48:51.930 William Cheng: Okay, so, so when the greater, greater assignment, if you if you are error message that get printed out to the screen. The waiter what the touch points. 342 00:48:52.140 --> 00:49:02.940 William Cheng: And if you have require messages over here that's supposed to print on the screen with the right value. And if you don't have that line, print it and or if the you know the the content of your is incorrect, the greater will also have to deduct points. 343 00:49:04.140 --> 00:49:08.340 William Cheng: OK. So again, feel free to discuss where you print are supposed to be, because that's not cheating. 344 00:49:09.870 --> 00:49:19.110 William Cheng: Okay, the only the only way you can that that's considered cheating is that if you exchange coat or pseudo code. If you're going to discuss what the print are supposed to look like. That's totally allowed 345 00:49:19.560 --> 00:49:27.510 William Cheng: Okay, so feel free to ask your classmate what they what they will where they see if you asked me, you know, depending on you know how you ask the question, and some questions. Can I answer. 346 00:49:27.960 --> 00:49:35.820 William Cheng: OK, I will tell you that. Yeah. Well, you should discuss with your classmate, I can I answer that, that question for you some question I can answer than a nutcase. I'll tell you. Yeah. 347 00:49:36.600 --> 00:49:49.050 William Cheng: All right. And then what do we do over here is it cause the function called way for crock and to wait for the child process to die, whereas over here we are we're probably hear a good way API details we saw the code already, right. So we have this kind of redundant. 348 00:49:50.640 --> 00:49:58.050 William Cheng: Okay, so we're probably over here, what is right for Prague over here. So we're, what we're doing is that it will work again you will wait for particular process to die. 349 00:49:58.740 --> 00:50:00.630 William Cheng: Okay, so we'll wait for product PT 350 00:50:01.080 --> 00:50:12.030 William Cheng: You know dot p over here. So again, this will give you the. This will give you the process control block, right, the process of dialogue right here which is PT copy over here. I want to wait for this process to die. 351 00:50:12.300 --> 00:50:19.380 William Cheng: OK. So again, this is a different function then wait for any before this one is wait for a specific process. And here's the process control, blah. 352 00:50:19.680 --> 00:50:28.230 William Cheng: Okay, so instead of President Obama, there's a name of the process, which is a p underscore calm over here. Why does the copy underscore 353 00:50:28.770 --> 00:50:37.560 William Cheng: Underscore calm. I have no idea why. But again, this is the how the weeks. Does that this is the name of the process over here. So I'm going to copy this information into this local variable over here. 354 00:50:38.640 --> 00:50:39.750 William Cheng: Okay, so why does a copy it. 355 00:50:43.290 --> 00:50:54.450 William Cheng: Right. The idea of years. I want to wait for process to die with the process die and then inside the way system called again. It's not a waste of time on this, it will be the new API to be here. I'm going to destroy the process control, blah. 356 00:50:55.020 --> 00:50:58.890 William Cheng: Right. Once I destroy the cup has control but I shouldn't really use it right so therefore this case. 357 00:50:59.130 --> 00:51:07.290 William Cheng: Before I use it. I need to copy this went to a local variable and not can use a local variable right this case name of the process. I'm going to copy that from here into the local rep over here. 358 00:51:07.680 --> 00:51:15.720 William Cheng: And then whenever you use ran copy over here, you got to make sure that, you know, just in case the argument over here is too long. You need to put it back to zero at the end of this buffer, then 359 00:51:16.320 --> 00:51:24.720 William Cheng: All right, and then I call to AP ID to wait for this particular process to die. So again, the first argument is not minus one, that means I want to wait for that process to die. 360 00:51:24.900 --> 00:51:36.690 William Cheng: We saw before. If we give it 2323 and there's no child process. In that case, this function to return right away with that says no trial no such file process if it turns out that this is actually a trial process that still running. 361 00:51:37.230 --> 00:51:42.360 William Cheng: Whereas, in this case, you have to give up the CPU. Again, you need to go to your designated place to go to sleep and then you 362 00:51:42.870 --> 00:51:52.680 William Cheng: can switch to give up CPU now. So again, the argument over here, this is the one that you need to return receive a return, Mexico, when this function returns. That means that the child processes that 363 00:51:53.040 --> 00:52:00.000 William Cheng: Okay. So, therefore, this guy is what do you print. Right. So yeah, read other the screen over here. It says, you know, here is the process name over here. 364 00:52:00.270 --> 00:52:07.350 William Cheng: Guys are dependent once they have the processes. And here's the process identifier and then he will say this one, x is dead. And here's the return Mexico. 365 00:52:08.010 --> 00:52:16.260 William Cheng: Oh, guys. But again, the greater will look for these error messages and make sure that the return Mexico is correct, right, again, feel free to discuss that in the cost of global okay 366 00:52:18.390 --> 00:52:29.970 William Cheng: Oh I the first step test over here. Again, we're going to start the process over here. So this one is called the case that exit. So it is going to go. The first procedures going to call case the exit test. So this function just like the first procedure of 367 00:52:30.360 --> 00:52:35.130 William Cheng: You know, if you're in a process. Okay. All it does is returned all so in this case. 368 00:52:35.700 --> 00:52:40.050 William Cheng: What it will do is that it will again wait for this child process to die. So just want to make sure that will you 369 00:52:40.350 --> 00:52:52.890 William Cheng: Will you actually have a function where the first procedure to that doesn't do anything. In the end, the parent will get woken up and then again the parent will print the error message and said I, you know, you know what, what, what is the what is the ethical for the time 370 00:52:53.940 --> 00:52:54.210 William Cheng: Yeah. 371 00:52:56.670 --> 00:53:05.160 William Cheng: So so so let's continue. So the first step test over here. So again, I mean, so, so no he should he should be able to start reading, reading this code over here, right. 372 00:53:05.430 --> 00:53:13.020 William Cheng: First one over here, print a message onto the screen on to the console. And then for either zero or less than 10 so that means that for equal to 0123456789 373 00:53:13.410 --> 00:53:25.260 William Cheng: We're going to start a process. So this is almost like our example in chapter two. Right, we call pizza create. So now, you know, instead of the pizza. We're going to call star Pro, we're going to create 10 child processes. Every child processes are threatening at 374 00:53:25.740 --> 00:53:32.310 William Cheng: All these processes. They have the same name. They'll call many tests and then their first procedure, they're all the same, right. So I'm going to create 10 375 00:53:32.640 --> 00:53:40.350 William Cheng: A child processes all their first procedure exactly the same. And then the argument over here is going to go on 1012345679 376 00:53:41.310 --> 00:53:53.130 William Cheng: Okay, so we saw the two ways we API details over here, when they, when they call to exit, they're going to use this argument over here. So in this case, when a child process die their return Mexico should be what should be 0123456789 377 00:53:54.210 --> 00:54:00.750 William Cheng: Okay. And then we had a cold way for all over here to wait for all the child process to die. And here's the code for way for all 378 00:54:01.230 --> 00:54:10.200 William Cheng: Okay, so we're over here basically stay in the loop keep calling way for any and we saw a couple wait for any before it wait for one child processes die. It doesn't really matter which one it is. 379 00:54:10.470 --> 00:54:18.870 William Cheng: And then it will take the return code over here, which is the process ID of the dead child compare against each other out. Okay. If it does, if it's not equal to each other. It will call this again. 380 00:54:19.530 --> 00:54:24.120 William Cheng: Okay, so in this case we're for all right here. How many times should I should have called way for any 381 00:54:24.540 --> 00:54:35.220 William Cheng: While since we have Ted and child potential policies if you wait for 10 times right every time we will print the m the message out to say, you know, we child processes die and eventually want to call it the 11th time 382 00:54:35.490 --> 00:54:42.600 William Cheng: Then you know this current processes will have no trial process or this guy should return right away and then this case the parent process shouldn't fall asleep. 383 00:54:43.020 --> 00:54:52.830 William Cheng: Right, because all the child classes. These are dead. So they have in this game. We were returning each other and he would jump out of the Internet and wait for all over here will return. And then what it will do is that it will print see one is done. 384 00:54:55.050 --> 00:55:04.320 William Cheng: Alright, so again, over here, it sort of remind you, you know what to do and what the way PT test does over here. So the call to exit. Right. The argument over here is going to be 01237 385 00:55:04.620 --> 00:55:09.690 William Cheng: A nice are one over years and goes all these numbers. So this one, you got to make sure that it sets the 386 00:55:10.170 --> 00:55:22.950 William Cheng: In the process control blah, there's a researcher Texaco and he knew seven correctly and he's that do AP ID that's where you fetch the return, Mexico, and then you need to return it. You know, as a third argument and then do a PhD, man. 387 00:55:25.530 --> 00:55:33.510 William Cheng: Alright, so again, here's this way for any if this is a way for all and then wait for any over here again we saw this code already right it called 388 00:55:33.810 --> 00:55:47.790 William Cheng: Way for any child processes today. The first arguments minus one. This means wait for any and then if it turns out that pod over here is equal to minus child that is it's not a good shot and he will say we child processes dead right and then it will return this passes it over here. Yeah. 389 00:55:50.130 --> 00:55:59.460 William Cheng: Alright. So again, that's all I want to show for today. So, we will not put all the code in, you know, the that's inside favorite test or even saw contest, you know, these slides. 390 00:55:59.940 --> 00:56:05.910 William Cheng: The idea over here is I show you how to read the first set of the first set of tests and there are four sub test there. 391 00:56:06.450 --> 00:56:12.780 William Cheng: Okay, that's how you read it and you can see that in the beginning, you don't know what everything means. But when we get to the for some tests, you know, 392 00:56:13.170 --> 00:56:19.080 William Cheng: The things she's just not making sense. Okay, so now you should be able to read the rest of the favorites are tests. 393 00:56:19.890 --> 00:56:26.790 William Cheng: OK. So again, if you don't understand something, send me email and then you know that you know if you want a hug. What a printer supposed to be. 394 00:56:27.420 --> 00:56:33.120 William Cheng: You know, ask your classmates, because if you asked me, chances are, I'm going to say, hey, you know, this one will be greater. You need to do the right thing. 395 00:56:33.360 --> 00:56:37.770 William Cheng: You need to figure out with your classmates. Okay, so feel free to discuss that in your class man again. 396 00:56:38.040 --> 00:56:49.170 William Cheng: Don't post code. Don't post a pseudo code. And if you want to show people your GDP, you know, screenshot of it over here. That's a really bad idea. Don't show people what Judy, Judy screenshot, because then you're going to end up showing your uncle. 397 00:56:50.310 --> 00:56:55.500 William Cheng: Alright, so again, be very, very careful with the NCO you don't want to. You don't want to end up cheating that alright 398 00:56:56.130 --> 00:57:09.240 William Cheng: So, we will not cover all the test calling the live discussion section right so the light discussion section in the team or leader. If you have a specific testing you wanted to, to talk about. Right. So again, the favorites arthritis. There are nine different sub tasks. Okay, so if you have 399 00:57:10.470 --> 00:57:16.590 William Cheng: One function. You don't know what the function is doing. Sorry. Again, if you ask them to do to explain everything that he is going to refuse to do that. 400 00:57:17.220 --> 00:57:24.930 William Cheng: Okay. But if you ask for a particular function to say I'm not really sure what this function is doing, you know, acid to to explain it that you know if it's small enough to to explain it. 401 00:57:25.500 --> 00:57:33.300 William Cheng: They're sending email as early as possible. So the teacher can prepare for it and also the TA TA won't do it. I will tell you they have not supposed to 402 00:57:33.540 --> 00:57:42.060 William Cheng: Have to tell you what the function is doing discuss with the class, we will group or send a message to, to, to me, is that right, so I can take a look there. 403 00:57:42.990 --> 00:57:46.170 William Cheng: But so remember your exercise is to read all these codes. 404 00:57:46.680 --> 00:57:57.960 William Cheng: Okay, one important thing you have to learn to how to we others people's curl are winning source code has some comment. It doesn't have comments as much as you want, because, you know, something that, why do you want the comes down to exactly what code right 405 00:57:58.530 --> 00:57:59.700 William Cheng: Okay, that's not gonna happen. 406 00:58:00.300 --> 00:58:10.710 William Cheng: Okay, so you got to learn how to read, you know, all these codes, some of them basically their hands, something that we explain what the function supposed to do and then you're supposed to implement it according to the spec of the functions. 407 00:58:11.280 --> 00:58:14.700 William Cheng: Now, alright. So you were supposed to as a reader call understand them. 408 00:58:14.880 --> 00:58:23.640 William Cheng: And they use that to figure out what you need to do. I mean, these are really good practice right because when you go work in industry, what do you think they're going to ask you to do. They're going to not going to tell you exactly what code right 409 00:58:24.360 --> 00:58:32.370 William Cheng: Okay, they're going to tell you is that guy here is you know some of your software architect to come up with a design over here. And then there's a lot of code that that your customers work with 410 00:58:32.580 --> 00:58:39.150 William Cheng: And then your, your job is to write your code by reading all this documentation by reading all these other people's code and make sure that your co works. 411 00:58:39.840 --> 00:58:53.520 William Cheng: Okay, it's exactly the same, like our current assignment. That's why our corrosive is so good. Okay. Because they're getting you ready for the real world. So therefore you should take it that is your right here now and then, you know, try to try to be as real as possible. Now, 412 00:58:54.840 --> 00:58:58.380 William Cheng: Alright, so again we will not interpret interpret all the code for you. Just like the real world. 413 00:58:58.920 --> 00:59:07.800 William Cheng: So again, or remind you that, you know, in the favor threat tears over here that will be the entry point inside the favorite test I see right functions, all the way at the bottom over here. 414 00:59:08.460 --> 00:59:15.810 William Cheng: You know, every line of code inside you know the cause over here as yourself, where all the threads. If they're sleeping which Q Are they sleeping in. 415 00:59:16.920 --> 00:59:22.740 William Cheng: There so so so so so in when the wind is Colonel, there's something called a list and there's something called a cute. 416 00:59:23.880 --> 00:59:27.090 William Cheng: They're so Q is so cute as a data structure that has listened it 417 00:59:28.260 --> 00:59:30.510 William Cheng: Okay, so go find out where all your cues are 418 00:59:32.370 --> 00:59:39.630 William Cheng: OK, so I guess they also you know so and it was something like qu e underscore tea or something like that and maybe there's a k 419 00:59:39.840 --> 00:59:45.720 William Cheng: K queue or something like that. I don't remember exactly what they are. But again, look for them, you know, you gotta, you gotta get used to running the grip command. 420 00:59:46.170 --> 00:59:53.340 William Cheng: Okay, you know, for those who like id, id will have a search, you know, string search, something like that. So some people actually install, you know, 421 00:59:53.850 --> 01:00:05.220 William Cheng: The, the, what is a web source go into, you know, Visual Studio or into Xcode or something like that. So even though they will not be able to compile it and run it. But again, it's sort of, it's a convenient way for you to actually do string search 422 01:00:05.760 --> 01:00:16.320 William Cheng: Guys, they'll get if you if you want to do that, you know, that's fine. Yeah. Alright. For threat is not in the queue. You know who is going to unblock and when and where, you know, you got to identify the code to all that kind of stuff. Yeah. 423 01:00:17.670 --> 01:00:22.230 William Cheng: Oh I so I am done with the discussion section over here. So again, you should start 424 01:00:23.490 --> 01:00:38.190 William Cheng: Some people started their assignment really late right she started Yokota Colonel while as soon as soon as possible. Anytime you have question. You know, you know, I send me email. I MEAN, YOU SHOULD TAKE ADVANTAGE YOU KNOW OF THE THE OFFICE. Our that nobody actually come to my office are 425 01:00:39.270 --> 01:00:43.230 William Cheng: Okay, so, so if you have any questions for me. You should come to office are asked me questions there. 426 01:00:44.250 --> 01:00:57.000 William Cheng: OK. So again, if there are multiple people come into the office. Are they in that case you are not allowed to show me your code. So some people feel like that's not very useful. But again, you should you should learn how to actually talk about the kernel source code. Okay. All right.