WEBVTT 1 00:00:02.340 --> 00:00:05.069 William Cheng: Welcome to lecture nine US 2 00:00:06.240 --> 00:00:12.120 William Cheng: Warm up to his do today. If you have come from previous semester, don't look at them. Don't copy them best to get rid of it. 3 00:00:12.509 --> 00:00:18.990 William Cheng: Grading guys. The only rule grey. We had all agreed on a 32 bill bunch of 16.04 system, the grading guys part of the spec. 4 00:00:19.500 --> 00:00:30.780 William Cheng: If you make a submission. Make sure you read and understand a ticket in the email. Now you should print the ticket and save a copy of that and make sure you follow, follow the verify your submission instruction. 5 00:00:31.740 --> 00:00:39.150 William Cheng: So again, does include running everything through the grading guidelines and check you know your Readme file. Okay. If you have any questions, feel free to send it to me. 6 00:00:41.100 --> 00:00:50.010 William Cheng: So we're gonna we're starting Colonel one, you know, studying on Wednesday, I guess, Colonel one again, there's only two weeks to do it. 7 00:00:51.030 --> 00:00:59.340 William Cheng: If you have co from previous semester, you know, please don't look at them. Don't copy it and don't run it. I remember I talked about all these things, you're not supposed to do with the previous semester. 8 00:00:59.700 --> 00:01:03.090 William Cheng: Colonel Simon. Also, make sure your teammates doesn't have a copy of it. 9 00:01:03.960 --> 00:01:12.240 William Cheng: Grading guys the lower grade, even though the grading Colonel waiting Ghana is very different from the warm ups stone. So don't assume they're the same, you know, read through it. 10 00:01:12.720 --> 00:01:19.590 William Cheng: And if you have question, you know, send me email. Make sure you read the spec and understand all the requirements that 11 00:01:20.160 --> 00:01:32.370 William Cheng: Please only only run winnings on Ubuntu 16.04 don't waste your time try to run any other system because they don't work in another system. Okay, please follow the instructions in the 12 00:01:33.390 --> 00:01:39.330 William Cheng: In the the colonel assignment web page and you know to 13 00:01:40.500 --> 00:01:46.230 William Cheng: Encounter anything strange, let me know. And also there's an instruction for you to send me your team information. 14 00:01:47.070 --> 00:01:52.740 William Cheng: So the team formation deadline is this Wednesday night. So it's one day after warm up to is do 15 00:01:53.460 --> 00:02:00.420 William Cheng: So if you don't get a confirmation from me that you have a team okay if you don't get a confirmation email you don't have a team. 16 00:02:01.170 --> 00:02:10.590 William Cheng: Or so that means that you miss you miss something. You know, so this is all gonna follow the instruction there. I mean, so here's the best way to do it. Okay. 17 00:02:11.190 --> 00:02:16.860 William Cheng: The requirement over here is that when you send an email to me to tell me who your teammates are everybody has to agree. 18 00:02:17.370 --> 00:02:29.070 William Cheng: Okay, you can't just send me email to say these are my teammates. It doesn't work that way. Right, so, send me email you're required to copy all your all your teammates and please only include us email. Okay. Because I don't know about any other email. 19 00:02:30.060 --> 00:02:40.440 William Cheng: Okay, so, so, so, so will you send me an email CC all your teammates and then what your team is supposed to do, is that everybody should she should she should do. Reply All and say I confirm 20 00:02:41.130 --> 00:02:47.340 William Cheng: Okay, so this way. I know everyone in your team, they all agreed to be on the same team are you that you didn't just make up your team. 21 00:02:47.730 --> 00:02:56.610 William Cheng: And BBB because that's really not allowed. Right. So everybody has come from. So when I see that everybody is not come from. I'm going to send the, you know, to everyone in your team to say now your team's convert 22 00:02:57.390 --> 00:03:03.840 William Cheng: Okay, so if you miss any staff in the end the you're not good enough to do it. Okay. 23 00:03:04.950 --> 00:03:16.710 William Cheng: So, you know, on Thursday morning. Why, because the deadline is Wednesday. Wednesday on Thursday morning. Anyone who does not belong to a colonel team must work on the colonel assignment alone. Okay. 24 00:03:18.180 --> 00:03:20.940 William Cheng: And what will happen is that, you know, 25 00:03:21.720 --> 00:03:32.610 William Cheng: If there are more than enough for people left who wants to be in a team, but they don't belong to any team, then why because I'm going to form random teams for all those people and all those people by themselves. 26 00:03:33.270 --> 00:03:42.750 William Cheng: Okay, so, so, not the people who already has the team because people always misunderstood that. Oh, I can just be added to an existing thing. It doesn't work that way. Read, you know, read a web page, very, very carefully to understand 27 00:03:43.560 --> 00:03:54.150 William Cheng: Okay, if you're left over, without a team. I'm gonna pair you up together with those, those people also don't have a team. Okay. So, in that case, you going to work with complete strangers. And this is extremely scary. 28 00:03:55.410 --> 00:04:05.460 William Cheng: Alright, so again. So at that point, I'm going to, I'm going to recommend you over and over again don't form a team with people you never work with. Okay. In the end, you, you still want to be, you know, being a team that 29 00:04:06.240 --> 00:04:10.770 William Cheng: Being a team with people you never work with then in the end when there's anything happen you know 30 00:04:12.240 --> 00:04:21.840 William Cheng: Please don't ask me to resolve your problems. Okay, so, so everybody follow the rule. And, you know, again, my recommendation is to work on the colonel Simon by yourself. 31 00:04:22.680 --> 00:04:29.610 William Cheng: If you don't have a team. Okay. Because in that case you will minimize your stress. Some people think if I put it on a random team, you know, I'm 32 00:04:30.480 --> 00:04:41.460 William Cheng: Gonna get some points. Maybe you want. Okay, so, so, and also guarantee you're going to end up with a lot of stress. Okay, so, so therefore it's better not to have stress, even though you don't have enough points. Okay. 33 00:04:42.240 --> 00:04:49.050 William Cheng: All right, let's trade off. Right. So today's lecture will get you going on. Colonel lines and some of the stuff we're going to cover is related to Colonel one 34 00:04:49.380 --> 00:04:54.480 William Cheng: We talk talk more about Colonel assignment and Colonel one this Friday during the discussion section. 35 00:04:55.050 --> 00:05:08.430 William Cheng: Kind of wines about the life cycles of prophecy and threats. So even though the assignment is called products. So it's like processes of threads. So if you don't know how process is supposed to work. You know, Colonel assignment. There's actually a good place to actually this 36 00:05:10.530 --> 00:05:16.020 William Cheng: Is actually a good place where you to read the code to find out, you know, what is the Colonel thread look lie. You know what a kernel process look like 37 00:05:16.350 --> 00:05:24.720 William Cheng: And that's part of your kernel source code. There's a file called favorite test I see Professor Ted favor a long time ago, you know, wrote these test code. 38 00:05:25.350 --> 00:05:31.590 William Cheng: So by reading those co very, very carefully at the beginning when you started read those codes, you have, you will have no idea what those codes are doing 39 00:05:32.700 --> 00:05:39.180 William Cheng: Okay, and that's okay, right, because, because what happened is I, you know, within a week or two, you know, you should be able to understand every line of those codes. 40 00:05:39.630 --> 00:05:47.430 William Cheng: Okay, so once you understand. You know what that's called are supposed to be doing, then you can write your code to make sure that those code works the way they're supposed to work. 41 00:05:48.030 --> 00:05:59.070 William Cheng: Okay, right. So please understand that this fall over here that file. If you submit that we have to delete it, because we have to use the pristine version of that file. So the greater might use as far as, you know, as, as is in the precinct source. 42 00:06:00.390 --> 00:06:07.500 William Cheng: Source code. So it's best that you don't modify that pop up because otherwise you know your code. If you call only work with your version of favorite 43 00:06:08.100 --> 00:06:14.820 William Cheng: A favorite test I see even get zero points. Okay. Because your code has to work with the ones even said Christine source code now. 44 00:06:15.420 --> 00:06:19.410 William Cheng: You need to write Colonel process. That's right. Creation termination co 45 00:06:19.770 --> 00:06:29.220 William Cheng: So that details there Tesco to work perfectly right. So in a way, the test code is your specification to say that whatever your implementation is this code has to where it's almost like this test. I see. Right. 46 00:06:29.850 --> 00:06:38.850 William Cheng: Just like, one more, one right. You need to implement my fault, my fault to list see of the requirement is a list that I see has worked perfectly. Guys, so it's kind of the same idea. 47 00:06:39.540 --> 00:06:49.200 William Cheng: All right. You also need to figure out what the correct printer supposed to be. So again, reading your, you need to reach a Kobe very carefully and try to sort of figure out what is the co trying to do. 48 00:06:49.620 --> 00:06:59.160 William Cheng: Okay, so in the end if you have your print out is completely doesn't make sense. You know, it's yours respond or some responsibility to look at the print I've said this printer doesn't make sense at all. 49 00:06:59.880 --> 00:07:11.190 William Cheng: Okay, and then you should, you know, send me an email, you know, posting the class Google go and try to sort of figure out what is wrong. There are so in the end it's very important to understand every line of code in favorite test RC. Yeah. 50 00:07:12.540 --> 00:07:21.420 William Cheng: I you should read the Phoenix documentation, you know. So inside the spec. There is a PDF file that's a phoenix documentation so that one come from Brown University. 51 00:07:21.990 --> 00:07:29.820 William Cheng: The spec is our Colonel spec. Just look that one up one spot warm up to spec and also the colonel come with the FAQ. That's very, very long. 52 00:07:30.840 --> 00:07:36.210 William Cheng: Okay, so. So again, you know, without the colonel FAQ. The Colonel assignments, pretty much impossible to do 53 00:07:36.570 --> 00:07:45.690 William Cheng: Okay. So, therefore, you have to read the colonel FAQ by yourself, even though, in the beginning, it doesn't make sense. Okay. But then, you know, the more you start doing it, the more things will make sense that 54 00:07:46.620 --> 00:07:51.090 William Cheng: All right, so by next lecture, which is this Thursday I will cover everything that you need to 55 00:07:51.510 --> 00:07:57.450 William Cheng: Know you that you need to know to complete Colonel one. Okay, so that's one of the reason. Last week I have to add an extra lecture. 56 00:07:57.810 --> 00:08:02.550 William Cheng: So, this way, this Thursday, you will have everything that you need to know to finish kind of one that 57 00:08:03.300 --> 00:08:07.290 William Cheng: You should start reading the kernel source code and you know it's very difficult to read. 58 00:08:07.890 --> 00:08:15.000 William Cheng: Okay, but that's part of your exercise is to read the kernel source code, but don't don't read everything because that will take forever. Right. So. So you sort of need to sort of figure out 59 00:08:15.600 --> 00:08:22.110 William Cheng: How to pick and choose. And then feel free to send me email have a discussion in the classroom. Yeah. And don't worry about the code that you don't understand 60 00:08:22.650 --> 00:08:32.280 William Cheng: Okay and focus on what you need to do. Now, you also need to know how to use the grip command I mentioned that in the previous discussion section. So again, you need to, sort of, you know, if you wonder 61 00:08:32.670 --> 00:08:37.950 William Cheng: You know who who is calling a function, you need to look for that function in all the kernel source code. 62 00:08:38.220 --> 00:08:46.710 William Cheng: Right, so this way you say, oh, that function, you know that the that functions as you calling this function. So, therefore, if I look at some documentation, you know, maybe that will help me to understand what's going on. 63 00:08:47.880 --> 00:08:52.080 William Cheng: Alright, so, so again, you know, when we get to the colonel assignment. There's really no spoon feeding. 64 00:08:52.290 --> 00:09:03.510 William Cheng: You know, you sort of have to figure a lot of stuff on yourself. You have to thing and you have to have discussion or you have to ask me questions right if you don't ask me questions. I don't know what kind of questions you have. Okay, so you have to ask me questions. Yeah. 65 00:09:04.710 --> 00:09:09.600 William Cheng: Alright, so make sure that you know who want to see some point oh four offer you an upgrade always refused the upgrade. 66 00:09:09.870 --> 00:09:14.100 William Cheng: Okay, because otherwise, if you, if you want to get upgraded. You won't be able to run your Colonel Simon 67 00:09:14.490 --> 00:09:26.010 William Cheng: So in that case, you have to install another virtual machine. Okay. So yeah, my recommendation is to keep a clean virtual machine just to run your kernel assignment. Okay, or just run for to assignment right don't install any extra packages. Right. 68 00:09:26.940 --> 00:09:34.950 William Cheng: In the configuration of the Colonel, there's a there's a flag called MTP dot zero okay so MTP stands for multiple threads per process. 69 00:09:35.400 --> 00:09:43.560 William Cheng: Okay, you just set it to zero because we're all our programming assignments. Right. We only implement single thread per process. We don't have multiple threads per process. 70 00:09:44.190 --> 00:09:50.130 William Cheng: Alright, so keep this way, go to zero. Some people like to say that you go to one. So if you said it the way you want to ask me a question about multi threading. 71 00:09:50.670 --> 00:09:59.700 William Cheng: Multi threading. Is that a kernel or multiple threads instead of Colonel process. I will not be able to answer your question, because I want to focus my answers on, you know, empty P equals zero. 72 00:10:00.780 --> 00:10:07.890 William Cheng: All right, if you want to play around with things because you have extra time. That's fine. Okay. But again, I would not answer questions about empty people, the one. All right. 73 00:10:08.700 --> 00:10:17.460 William Cheng: You also need to learn how to use Unix, Linux, you got to get familiar with the Unix, Linux command, because our kernels Sam is to build a system that looks like Linux. So if you don't know the UNIX 74 00:10:18.180 --> 00:10:30.600 William Cheng: Or Linux about how can you test your kernel. Okay, so, so you have to you know you you have you have learned this command and also you have to use DDB because without GDP. The Colonel is pretty much impossible to debug now. 75 00:10:32.220 --> 00:10:40.500 William Cheng: Alright, so you don't have to know what every piece of code is doing. You need to learn assume that you need to assume that you know all the code that you that you didn't understand they all work perfectly. 76 00:10:41.100 --> 00:10:47.850 William Cheng: Okay, so, so, so, so that that you do. So you have to learn that, because otherwise you would never finished your current assignment. Okay. 77 00:10:48.390 --> 00:10:55.860 William Cheng: Use grab to get an idea how functions are used. If you're working with a team, your team should meet often. So what is often 78 00:10:56.460 --> 00:11:01.080 William Cheng: There's over here it says once a day is prefer right summer schedule is very, very tight. 79 00:11:01.770 --> 00:11:06.960 William Cheng: Okay, if you have four people, everyone will kind of different things in India we come together, nothing works. 80 00:11:07.650 --> 00:11:09.780 William Cheng: That's really not. The other thing I'll go way to go. 81 00:11:10.230 --> 00:11:15.270 William Cheng: Okay, so one thing that you can do that. You can, you know, sort of try to meet at the same place at the same time, of course, these days. 82 00:11:15.480 --> 00:11:23.910 William Cheng: We're talking about meeting online, right. So if you can set up zoom meeting or maybe there's some other tool for you to meet you know for for a long period of time, you should do that. 83 00:11:24.570 --> 00:11:32.550 William Cheng: Okay, you should have a lot of discussion and then write a fair amount of code. I mentioned before one kernel. One is only about 500 lines of code. 84 00:11:33.660 --> 00:11:39.810 William Cheng: Okay, so don't spend all your time just writing crazy codes for has make sure that every lines of code that you write are useful code. 85 00:11:40.290 --> 00:11:46.920 William Cheng: Okay and and and you know this Friday. Again, I'm going to try to explain to you about the rule grading to make sure that every line of code that you write 86 00:11:47.130 --> 00:11:57.150 William Cheng: Are useful co because if you leave junk inside the Colonel, we're going to end up deducting points from you. Okay, so make sure every line of code that you write you write it for purpose that 87 00:11:58.620 --> 00:12:09.810 William Cheng: My also he has become calmer, you need to swallow your pride, be honest with your teammates. Don't hide hide your weakness. The worst thing that you can do is to make promises that you cannot keep okay because that will stress everybody out 88 00:12:10.710 --> 00:12:16.350 William Cheng: Okay, so in the end you know your your entire team only make one submission and everybody should get exactly the same great 89 00:12:17.400 --> 00:12:24.210 William Cheng: Alright, so if you use, you know, if you try to punish your teammates are not contributing equally India everybody's gonna get everybody's going to get punished. 90 00:12:24.990 --> 00:12:32.220 William Cheng: You know, the best thing to do is to work as a team. Okay. I mean, once you form a team. There's really no point to, to, to not work, not to do. 91 00:12:32.700 --> 00:12:40.800 William Cheng: Our work as a team now. Alright, so, so, so tell tell each other, you know, you're probably experienced what your weaknesses are, what your weaknesses are. 92 00:12:41.280 --> 00:12:49.170 William Cheng: What if nobody is good at programming. Okay. If your entire team. Nobody's good at programming right in that case. Somebody must somebody must step up. 93 00:12:49.500 --> 00:12:58.530 William Cheng: Somebody must say that this is really important stuff. I want to get good at. So I'm going to spend all my time tried to go to Kronos I'm going to work. So in that case, that person will be the one to learn the most 94 00:12:59.190 --> 00:13:02.220 William Cheng: Okay, because the only way to learn about the operating system kernel is by doing it. 95 00:13:02.970 --> 00:13:08.820 William Cheng: Okay, well, we can talk about all the theory stuff, you know, leading classes, stuff like that, in the end, you know, will you experience it. 96 00:13:09.240 --> 00:13:18.210 William Cheng: That's that. That's how you really know. Okay, so if nobody is good at programming. Somebody has to step out somebody has spent all their time they Ni, you know, to try to get the 97 00:13:18.660 --> 00:13:24.120 William Cheng: Get the code to work and everybody needs to help this, you know, to help each other to make sure that you submit your work properly. 98 00:13:24.990 --> 00:13:30.540 William Cheng: Okay, so again, as I mentioned before, you know, submission is very important that really fast, very important. Yeah, you gotta, you gotta sort of 99 00:13:30.810 --> 00:13:39.300 William Cheng: divvy up the work. So some people is going to be in charge of submission. Some people are going to be in charge of your Readme file and do testing, all that kind of stuff. Yeah. Alright, so 100 00:13:40.500 --> 00:13:46.080 William Cheng: So, so, so, so your team is talking about yourself and find out what's the best way you know for you to work as a team. 101 00:13:48.360 --> 00:13:53.940 William Cheng: So a little bit about Colonel one recommended recommended timeline. So, you know, before this Thursday. 102 00:13:54.270 --> 00:13:57.300 William Cheng: You know, since you don't have everything you need another finish quite a while. You can actually just 103 00:13:57.630 --> 00:14:06.660 William Cheng: Do the documentation you should read the winnings documentation. Read the spec. Read the colonel FAQ explore the kernel source code without trying to understand everything. Okay. 104 00:14:07.350 --> 00:14:16.860 William Cheng: So, you know, try to and try some code to get the idol process to start right so today's lecture. I'm gonna sort of briefly talk about this idol processes. 105 00:14:17.370 --> 00:14:24.540 William Cheng: And by this weekend, you need to keep something called the drivers equal to zero because once you set drivers equal to zero is equal to one, you're gonna start getting interrupts 106 00:14:24.900 --> 00:14:28.740 William Cheng: Guys in the beginning, you want to have no interruption. So keep driving go to zero in conflict, I am K 107 00:14:29.340 --> 00:14:44.130 William Cheng: You should get the process. The process is the one with process ID or the wine. The idol process, the world with process is equal to zero. Okay, so the first process is process it zero. And then the next one is called any process. So, so, at the beginning, the enterprise. It doesn't do anything. 108 00:14:45.210 --> 00:14:54.000 William Cheng: Okay, so by this weekend. Will you should do is that you should try to write as much code as possible to get the end it process to start and quit. As soon as you run it yourself terminate. 109 00:14:54.990 --> 00:15:03.660 William Cheng: That. So that's what you need to do. So opposite when you self terminate it should wake up process zero because processor is waiting for process one to die process was a child process process. 110 00:15:04.260 --> 00:15:13.590 William Cheng: Process zero is going to wait for process one to die. As soon as process one die processor. I have nothing to do, because at this point. There'll be nothing inside the colonel process zero turn off the machine. 111 00:15:15.120 --> 00:15:18.240 William Cheng: Okay, so that's what you should shoot for by the end of this weekend. 112 00:15:18.690 --> 00:15:24.780 William Cheng: Okay, so if you can. I mean, this is pretty aggressive schedule. So if you can't meet the schedule. It's okay, don't worry, don't worry too much about it. 113 00:15:25.020 --> 00:15:34.530 William Cheng: Yeah, but, but, you know, you try to shoot for these go as much as possible. Now, and also you know when the process to die right before right before we turn off the machine. 114 00:15:35.070 --> 00:15:38.610 William Cheng: You're going to see a message to say that whether the colonel has how to cleanly or not. 115 00:15:39.450 --> 00:15:45.000 William Cheng: Okay, if he, you know, if you see the message to take the tone of how the cleanly. That means that you're ready to move forward. 116 00:15:45.510 --> 00:15:50.100 William Cheng: Okay, if you don't see that message, you know, maybe that means that you have bugs inside your kernel. 117 00:15:50.580 --> 00:15:53.040 William Cheng: Maybe it's a good idea to fix them first before you go to the next step. 118 00:15:53.400 --> 00:15:57.990 William Cheng: Yeah. Alright, the next step. I'm sort of going to say that, you know, by by by Thursday next week. 119 00:15:58.230 --> 00:16:05.520 William Cheng: You still keep drivers equal to zero and company Diane case or even though, if you read the spec dispatches at some point you're gonna say driver equals two, one believe that at the end. 120 00:16:06.300 --> 00:16:12.300 William Cheng: Okay, so, so it's important to get all these work with Dr. Or equal to zero, without to interrupt you, but you know I was going to make things more complicated now. 121 00:16:12.630 --> 00:16:21.630 William Cheng: Alright. So in this case, you're going to call favor throw Tessie and it progress. So, so the previous step to it, you know, the either the inner process doesn't do anything. And now we're going to have any process do one thing. 122 00:16:22.440 --> 00:16:34.830 William Cheng: Okay. The one thing that it will do is to test your kernel because because the deposits really doesn't have anything to do so. What it will do is it will call favor threat test to test your kernel and then again we the the the the the 123 00:16:35.220 --> 00:16:41.700 William Cheng: The spec. The spec says that there's a flag and company dime Keiko CS for to test the TCS want to test 124 00:16:42.180 --> 00:16:46.920 William Cheng: By default, I said at 10 it will it will it will run all the testing favorites that has you're not ready for that yet. 125 00:16:47.340 --> 00:16:56.760 William Cheng: Okay, so what you would do is that you're setting equals two, one and then try to pass one set of testing favorites that task and instead of to to pass two sets of Test, test three sets of the three is part three. So, 126 00:16:57.180 --> 00:17:04.410 William Cheng: Eventually this can go as high as eight. And so once you get to a you will pass. Most of the testing favorite test. 127 00:17:04.890 --> 00:17:09.000 William Cheng: Okay, so again every time you need to make sure that when you shut down the Colonel. The Colonel is going to how clearly 128 00:17:09.270 --> 00:17:16.050 William Cheng: If because if CFO to tell you over here equals to aid and Colonel can shut down. Clearly you're ready to go to the final phase. 129 00:17:16.560 --> 00:17:22.110 William Cheng: Then the final phase over here, you're gonna say drivers equal to one, because the last test in the favorite test will not work. 130 00:17:22.320 --> 00:17:28.500 William Cheng: Unless drivers equal to one. So that means that you're gonna have, you know, rock and also driver equal to one, that means that you're enabling device drivers. 131 00:17:29.220 --> 00:17:33.960 William Cheng: OK, so now you can actually get a display can get a console window you can type commands in there and like I messed up. 132 00:17:34.440 --> 00:17:45.060 William Cheng: So in this case insight in a proper on your unit process all it has to do is to start the colonel shell. The Colonel should look just like your bash shell, just like UTC show just like your command shout. 133 00:17:45.720 --> 00:17:51.180 William Cheng: Okay, except that there's only three commands that you can type what it's called help you. I don't want to echo the other one is called exit. 134 00:17:51.540 --> 00:18:02.460 William Cheng: Okay, so as soon as you said, Dr. Or equal to one, you know, inside in a prog rock, you need to start up a colonel shower. So again, read the FAQ to find out how to do that again only a few lines of code, and it should work right away. 135 00:18:02.970 --> 00:18:09.660 William Cheng: That. So once that's working, you need to add three k shall come out because the grading Garland says you need to run three sets of tests. 136 00:18:09.960 --> 00:18:18.540 William Cheng: OK. So the idea here is that you to create one K shell command for each set of has that you have to run. Okay. And then what you do is that you know inside the cage command. 137 00:18:19.050 --> 00:18:26.340 William Cheng: You know, when the user type those commands you need to create a child process inside the child policy, as you said, the first procedure to be those one of those three 138 00:18:27.540 --> 00:18:40.590 William Cheng: The three tests that you have to pass. Okay. And then you just test it and hopefully, everything's gonna be okay and then you, you know, verify you read me files. Okay. And then you pass all the waiting guidelines and then you're then you're ready to make a summation 139 00:18:42.270 --> 00:18:47.220 William Cheng: Alright, so again, you know, when we start doing this you know when you're confused, you know, feel free to send me an email. Okay. 140 00:18:47.940 --> 00:18:53.610 William Cheng: Alright, so we're going to go to chapter three. Chapter three. Last time we talked about static Lincoln and loading. 141 00:18:54.060 --> 00:18:59.550 William Cheng: We're skipping dynamic Lincoln and loading. I'm going to leave that for the last lecture because we don't really need it for anything. 142 00:19:00.150 --> 00:19:07.170 William Cheng: So we're going to go to the last part in chapter three and talk about booty that so and then we're going to go to chapter for that. 143 00:19:07.860 --> 00:19:13.230 William Cheng: So what is booting right so so the booting come from the expression of pull yourself up by your bootstraps. 144 00:19:13.680 --> 00:19:20.040 William Cheng: So it's kind of like if you want to sort of jumping right. So the way you job is that you pull, you know, you put your boots, really, really hard and you jump out 145 00:19:20.670 --> 00:19:28.740 William Cheng: So that's really not a good way to jump right, so, so, so, so what is referring to. It's a difficult situation. Okay, so in the Albany system, you know, what is the booty. 146 00:19:29.370 --> 00:19:35.160 William Cheng: booty over here is the process of loading the operating system is because in order for you to to run your operations. 147 00:19:35.640 --> 00:19:41.700 William Cheng: In order for you to run user space program, you have to run the operating system in order to run your operating system. How do you actually start the operating system. 148 00:19:42.270 --> 00:19:49.920 William Cheng: Right, if you start with the machine you flip on the power switch. How does it get into running the operating system. Okay, so that particular process called booty. 149 00:19:50.340 --> 00:19:56.610 William Cheng: Okay. Your turn on you flip on a switch and then at some point you're gonna start running offices and how do we get there. Yeah. 150 00:19:57.330 --> 00:20:03.120 William Cheng: Alright, so the solution OBS I'll get the idea of years that we have a monolithic current or is it on the desk over here. We're gonna have an operating system. 151 00:20:03.390 --> 00:20:12.630 William Cheng: Get the offices and typically is compressed so so so there's a kind of small, and what we need to do is that we need to sort of unfolded into memory or as a here's my memory right here. Okay. 152 00:20:12.780 --> 00:20:19.800 William Cheng: So what unfolds the operating system into memory, then it becomes sort of a rectangular shape right co segment data segment, all that kind of stuff, and then 153 00:20:20.160 --> 00:20:29.700 William Cheng: You know when you get loaded into memory. We're going to transfer control to it by pointing EI Pete, one of the instructions over here as soon as we finished doing that now we're executing operating system code. 154 00:20:30.930 --> 00:20:41.010 William Cheng: Okay, so the question is, how do we get there, right, who is actually copy or who's actually you know unfolding the opposite, and then copying to memory. How does it know where to copy into memory, right. So all these things are 155 00:20:41.610 --> 00:20:46.320 William Cheng: Sort of part of the booty process. OK. So the solution is over here is that, you know, you know, 156 00:20:46.710 --> 00:20:54.900 William Cheng: In order for us to copy the data from this into memory. We also need to run a piece of code, right. So we're going to call that piece of code over here. A tiny operating system right tiny 157 00:20:55.110 --> 00:20:59.910 William Cheng: Open system over here. There. So sending over here he is, where does tiny optimism Cobra. 158 00:21:00.540 --> 00:21:07.770 William Cheng: Well, originally this tiny operating system and also sitting on the desk over here. Right. Okay. So, so, at some point, you need to unfold the tiny audiences them into memory. 159 00:21:07.920 --> 00:21:13.620 William Cheng: And then you transfer control into it and now this tiny operating system can take the Japanese this mm folds into memory and then tries to do it. 160 00:21:14.040 --> 00:21:28.470 William Cheng: OK. So again, that's the same question. How do you get the tiny offices upon a distant memory. Maybe you have a tiny, tiny often uses them. So you can see that this is gonna get a little ridiculous maybe a computer science people like recursion there but recursion has to stop somewhere. 161 00:21:29.580 --> 00:21:33.570 William Cheng: Okay, so at some point we're gonna have a tiny, tiny offers. Then we're gonna have a tiny, tiny, tiny, tiny operating system. 162 00:21:34.170 --> 00:21:43.170 William Cheng: So at some point is going to end with something that's not software. Okay, so what is it something that's not software I could we can either end up as hardware or maybe we can end up to be a person 163 00:21:43.770 --> 00:21:45.750 William Cheng: Well guys, I India and it could be a person that's doing that right 164 00:21:46.290 --> 00:21:53.880 William Cheng: So so so these kind of operating system over here. They are typically known as the bootstrap loader, because we don't really call it tidy up disassemble called a boot loader. 165 00:21:54.360 --> 00:22:04.680 William Cheng: But which one is a blue shirt voter is the last one will be as a blue shirt loader that take the opposite seminar for them to memory or the one that takes the tiny option is to seminar for the environment that's that's also push upload it. 166 00:22:05.160 --> 00:22:11.970 William Cheng: Okay. So all these things. They're all bootstrap loader. So some people actually was it out or only the last one is Boucher loader or the other will have a different names. 167 00:22:12.690 --> 00:22:15.420 William Cheng: So in this, in this case, you know, in our class. We don't really care. 168 00:22:15.990 --> 00:22:24.570 William Cheng: Okay, so, so as long as it's something that takes one one kind of up in the system unfolding memory and then transfer control to it. And now you end up the organism, whether it's the tiny one or the real one. 169 00:22:24.780 --> 00:22:27.480 William Cheng: It doesn't really matter. Okay. Because in the real process. 170 00:22:27.750 --> 00:22:36.930 William Cheng: This needs to be done in multiple stages and every stage, we're going to use some sort of a bootstrap loader to low some sort of operating system load into memory transfer control to it. 171 00:22:37.140 --> 00:22:42.180 William Cheng: And then that Bouchard loader will love it now operating system into memory and and keep doing this over and over again. 172 00:22:43.320 --> 00:22:48.330 William Cheng: Okay, so we're gonna all call them push up loaders. Okay, even though you know some of them has very specific next. Yeah. 173 00:22:49.980 --> 00:22:58.620 William Cheng: Alright, so this is an older computer. So this is a computer made by Digital Equipment core called the PDP as a visual a one chord with the one that came up with the micro 174 00:23:00.000 --> 00:23:01.890 William Cheng: They are the one that came up with the 175 00:23:03.720 --> 00:23:05.910 William Cheng: Yeah, I think they're the one that came up with a mini computer 176 00:23:07.710 --> 00:23:16.350 William Cheng: Like this. They didn't want that to come after mainframe. So there's mainframe. And then I think there's mini computer anyway. So this is the one of them, they're, you know, they're kind of the size of a refrigerator. 177 00:23:16.980 --> 00:23:18.600 William Cheng: So the way that they built this is that 178 00:23:19.170 --> 00:23:24.630 William Cheng: They actually the human has to do it. Okay, so I've been as the operator of this machine when it's ready to put this machine. 179 00:23:24.870 --> 00:23:29.370 William Cheng: what he would do is that you will flip the switch and we will also nothing, nothing happened is that the machine. 180 00:23:29.610 --> 00:23:34.650 William Cheng: And then what do we do that they will use this toggle switches to enter some binary code into the machine. 181 00:23:34.830 --> 00:23:40.860 William Cheng: That. So these switches. So, for example, maybe this is the one this is zero be here. So every switches, set it to 01 182 00:23:41.070 --> 00:23:48.690 William Cheng: And then you press enter, then this pattern over here got this a binary pattern right you know zeros and ones over here. We'll go into memory inside this machine. 183 00:23:48.870 --> 00:23:52.950 William Cheng: And and in this case I guess there's three bites here, right. So you would write three bites of code over here. 184 00:23:53.400 --> 00:24:01.950 William Cheng: Okay into memory, right. And then what you do is that you you enter the second powder over here. You press enter again, you're going to enter another three bites and number three bites and another three bites. 185 00:24:02.220 --> 00:24:11.340 William Cheng: After you enter your entire boot program when you press the button on the on the machines to say go, and then what do we do, is that it was are executing code, you know, inside this memory over here. 186 00:24:12.360 --> 00:24:22.290 William Cheng: Okay, so of course you should be God. God today. You don't have to do that because this is really, really painful than what kind of code that they enter actually there's a cheat sheet over here to tell you exactly what code data. 187 00:24:22.740 --> 00:24:32.700 William Cheng: If you blow up their watch you look like this. Okay, so I'll be here this is the code that you have actually have to enter and then India you press go so what it will do is it will boot. This particular computer net 188 00:24:34.020 --> 00:24:44.490 William Cheng: Alright, so they are. They have these quote unquote, you know, has another machine callbacks 11 seven at. So this one you can sort of see that it's a size of a big refrigerator, then 189 00:24:45.240 --> 00:24:54.810 William Cheng: You know, the social in order for you to put this machine, you actually have to put another machine and another machine will put this machine. I said there's another machine called LSA 11 unless I love in 190 00:24:55.860 --> 00:25:01.290 William Cheng: The one you have the blue first and once this machine is Buddha. What it will do is that it will go to a paper tape. 191 00:25:02.250 --> 00:25:14.220 William Cheng: You go, you go to a device called a paper tape and then read the book program there and loaded into the memory of of X 11 seven backs lemon 780 and then tell the VAX 1170 to say go and execute that code. 192 00:25:15.300 --> 00:25:21.300 William Cheng: OK. So, again, in this case, you know, in order for you to put one machine, you have to put another machine. So again, the question is how to put another machine. 193 00:25:22.020 --> 00:25:28.830 William Cheng: So again, we still have to booting problem there so sad Laverne has something called the floppy disk. 194 00:25:29.190 --> 00:25:35.190 William Cheng: The for me, this is like us like a USB stick right but and, you know, a long time ago before USB stick. There's something called the floppy. This 195 00:25:35.700 --> 00:25:46.770 William Cheng: So it's a magnetic material, but it's the, it's called pop up because it's a soft material and then you can, you know, easily format that that the floppy days for programs on it. 196 00:25:47.250 --> 00:25:53.850 William Cheng: So there's a bunch of stuff on the floppy disk, right. So if you change the product on one thing, this case, you're going to give the different food instruction. 197 00:25:54.210 --> 00:26:04.620 William Cheng: For our side 11 guys are some of the stuff on the floppy disk or the device driver. Right. So here is a lover needs to talk to a bunch of devices including the paper tape and he will also treat the vaccine. 198 00:26:05.490 --> 00:26:13.290 William Cheng: As the device. So you can actually read the stuff on the paper tape and then write it to you all need device driver for it so device drivers over here that are sitting on the floppy drive 199 00:26:13.560 --> 00:26:20.580 William Cheng: That they also have a file system on it, right. So this way you can just throw a bunch of files, you'd be able to find a you can have to copy them, you know, stuff like that. 200 00:26:21.510 --> 00:26:34.140 William Cheng: So it says, Oh yeah, if there's any other kind of devices are the needs to sort of get them ready to run the real system. So again, there's a lot of initialization code on the floppy to make sure they're going 201 00:26:34.560 --> 00:26:40.710 William Cheng: That. So when you put the LSAT lover machine. What it will do is that there's a fixed hardware code that will read data from the floppy drive 202 00:26:40.950 --> 00:26:50.070 William Cheng: Loaded into LSA 11th memory and then transfer control to it and now they can start you know loading loading more data. And then, and they and they use that to poop X 11 seven at 203 00:26:50.970 --> 00:26:54.270 William Cheng: That all right so in the early UNIX system. 204 00:26:54.540 --> 00:27:06.150 William Cheng: So this is, you know, so this is one of the possible procedures over here and also you can use hardware to sort of decide, you know, you know, which which device. The blue from instead of booting from the floppy. You can also move on a hard drive. 205 00:27:06.600 --> 00:27:09.390 William Cheng: Typically on a hard drive. There are many petitions. 206 00:27:09.780 --> 00:27:18.060 William Cheng: You know, so, so I don't know if you actually you you try to format a hard drive. So when you try to format a hard drive, you will say, you know, how many partition, you want to create all that kind of stuff. 207 00:27:18.630 --> 00:27:25.140 William Cheng: So in this case, you know, you might have multiple operating systems sitting on the same harddrive and then you have to say, Who do we know which obviously is I'm I want to 208 00:27:25.920 --> 00:27:37.740 William Cheng: I want to do from I saw it again, there's a lot of choices over here. Okay. And every time one of these this partition. If you change a new device driver or have you fix the bugs that one of the device driver, the 209 00:27:38.160 --> 00:27:46.800 William Cheng: Driver. Or maybe there's some initialization kernel call any kind of other the modification that you may not going to end up with a new version of your operating system. 210 00:27:47.640 --> 00:27:53.370 William Cheng: Okay, so in the early days over here. It's actually very easy. It's a management, headache, you have to you have so many different version of the operating system. 211 00:27:53.610 --> 00:27:58.500 William Cheng: And then you need to you need to make sure that if you try to get a certain operating system to boot. 212 00:27:58.680 --> 00:28:05.580 William Cheng: You need to make sure that you have the perfect combination of all the stuff you need to very, very carefully put them onto the hard drive, putting that right right partition. 213 00:28:05.910 --> 00:28:10.200 William Cheng: So of course the question is that how do you actually put it inside right partition. If you're not running the operating system. 214 00:28:11.070 --> 00:28:17.970 William Cheng: Okay, so this is kind of like the early days of Linux. So like around 1990 I have the pleasure of playing we're playing around with the early version of Linux. 215 00:28:18.240 --> 00:28:25.500 William Cheng: Every time when I need to make a tiny change. I'm going to end up with a new version of Linux. And believe me, it was a very, it was a it was a very, very big headache. 216 00:28:25.920 --> 00:28:30.450 William Cheng: Every time I have to configure the system to make sure that they will actually be able to put Linux. Yeah. 217 00:28:31.110 --> 00:28:35.010 William Cheng: Alright, so again, every little things that you are gonna end up with a new operating system. 218 00:28:35.670 --> 00:28:41.010 William Cheng: Later on what they would do is that in order for you to configure everything very, very carefully. They said, Well, why don't we 219 00:28:41.880 --> 00:28:46.650 William Cheng: Why don't we, when we distribute the operating system, we're going to include all the possible drivers. 220 00:28:47.400 --> 00:28:54.930 William Cheng: Okay, so this way are up in the system is ready to running any piece of hardware. So when we install our window we start boosting our operating system that piece of hardware. 221 00:28:55.050 --> 00:29:00.930 William Cheng: We're going to invoke every device driver. Then we tell the device, you have to say, hey, find out whether you are installed on this mission or not. 222 00:29:01.680 --> 00:29:12.510 William Cheng: Okay, so this is called a sort of a probe function probe function for every device to prove themselves on the bus to see the exists, it exists. Well, then in that case you have to load that driver. 223 00:29:12.870 --> 00:29:22.740 William Cheng: Okay, if they don't exist whether you don't have the last driver so you load the driver to pro and then if it turns out that the device doesn't exist. And then you can actually remove that you remove that particular device. 224 00:29:23.700 --> 00:29:28.530 William Cheng: Okay, so this way. We don't have to carefully configure the opening, Sam. But the problem with this approach is that 225 00:29:29.100 --> 00:29:39.180 William Cheng: If you have 1000 device driver when you put your device you have 1000 prob operation. After you have to run. So in that case, when you try to put the operating system, you will take you a very, very long time that 226 00:29:39.840 --> 00:29:44.280 William Cheng: Later the later Unix. They basically the they use dynamic Lincoln and loading. 227 00:29:44.490 --> 00:29:51.300 William Cheng: So this way when you're running the operations. So you start running the operating system. First, you only loading the basic driver like that this driver that's something that you have 228 00:29:51.480 --> 00:30:01.770 William Cheng: The they have to have. And also, if you want to display a message on the console that you know you need to be the display driver. If you want to interact with the keyboard keyboard driver, but all the other drivers. You don't need 229 00:30:02.880 --> 00:30:14.370 William Cheng: Okay, so therefore all the other drivers are only required to load on demand. So you can do them dynamically, but since we just skip the dynamic Lincoln and loading. So we also going to not talk about that. Okay, so when we go to 230 00:30:15.000 --> 00:30:17.880 William Cheng: The semester. I'm going to sort of briefly talk about that me Lincoln. 231 00:30:18.480 --> 00:30:26.340 William Cheng: OK. So the idea here is that part of the colonel can be loaded into memory while the yo can be loaded into the openness is a while the operating system is running. 232 00:30:26.940 --> 00:30:33.390 William Cheng: Okay. For sixth edition units. We don't really, we don't really have the features like that. Okay. But again, we're not going to sort of talk about these kind of features. 233 00:30:35.250 --> 00:30:40.860 William Cheng: Alright, so that's for the mini computer and also for the sort of the early UNIX system so 234 00:30:42.060 --> 00:30:50.850 William Cheng: You know that. Then come the IBM PC. Right. I didn't. So I mean pieces actually very, very important, because why because it was meant to be an open architecture. 235 00:30:51.360 --> 00:31:00.930 William Cheng: Okay, for IBM PC, you should be able to run, you should be able to write any software for the IBM PC. What's more importantly is that you can you should be able to install any piece of hardware into the IBM PC. 236 00:31:01.290 --> 00:31:10.260 William Cheng: Then so Ivan is that at the bottom of the IBM PC over here. There's the motherboard on the motherboard. There's a CPU. There's also some code on the read only memory. 237 00:31:10.950 --> 00:31:20.010 William Cheng: There. So the read only memory is actually known as BIOS you probably heard about the iOS. The Basic Input and output system. So what is, what is the input opposites that 238 00:31:20.340 --> 00:31:25.290 William Cheng: While that's for, you know, talking to the device. There's a basic as they are the buyers who just wanted device driver. 239 00:31:25.650 --> 00:31:35.280 William Cheng: That also contains some buco that allow you to pull the operating system. Okay. But what's more important about the IBM PC is that there's a bunch of, you know, sort of a bunch of 240 00:31:36.480 --> 00:31:46.080 William Cheng: The there's a bus on the on the motherboard of the IBM PC and on the, you know, on the bus over here, you can actually plug in all kinds of boards. Right, so 241 00:31:46.650 --> 00:31:59.100 William Cheng: A couple of lectures ago we saw what a port look like the one has metal fingers making contact over here. So, IBM PC was made to be an open architecture that you can design your own board and you can plug it into the slot and now you can write program to actually use that 242 00:32:00.510 --> 00:32:05.790 William Cheng: Okay, so the question is that if you have a complex architecture like that. How do you make sure that you can actually put the entire operating system. 243 00:32:06.810 --> 00:32:15.150 William Cheng: Okay, so, so it means to be very general purpose. And as it turns out, in the end, IBM PC had a major impact because it was a major the so 244 00:32:16.500 --> 00:32:22.290 William Cheng: It was an open system, are they, you can write software for you can also install hardware inside the systems. 245 00:32:24.060 --> 00:32:31.260 William Cheng: So the way this is done is that, you know, as I mentioned before, you know, there's a Basic Input opposites them is city inside this read only memory or color raw 246 00:32:31.950 --> 00:32:39.450 William Cheng: Okay. So inside this this is this is the ROM is called as BIOS chip right bio chip because they don't hire BIOS is sitting on the chip over here. 247 00:32:39.690 --> 00:32:43.380 William Cheng: And he's had a BIOS, there's a bunch of stuff. There is something called the power on self test. 248 00:32:43.590 --> 00:32:49.290 William Cheng: For testing all the hardware, because if you don't test the hardware. And if you start running software. The software is going to be very unreliable. 249 00:32:49.470 --> 00:32:54.690 William Cheng: So, therefore, you got to make sure that you have, you know, all the hardware running. If we can have, you can start running software that 250 00:32:55.290 --> 00:33:03.030 William Cheng: They will also have the blue coat. Right. So this way you can load interest for control of the blue program okay and and and and 251 00:33:03.630 --> 00:33:09.330 William Cheng: Basically start running the operating system now. So yeah, the operating system over here is the IBM PC operating system that 252 00:33:09.900 --> 00:33:17.850 William Cheng: Will also provide drivers for all the devices all the basic devices that cover the IBM PC. Right. So what were those those other display. Those are the keyboard or 253 00:33:18.120 --> 00:33:23.520 William Cheng: I think in the beginning. I don't even know if they have a mouse over here is a picture as a mouse. There's actually don't have a mouse. 254 00:33:23.730 --> 00:33:30.810 William Cheng: Right, so they got they got to have drivers for the floppy drives are these two things are the floppy drive right here. They need to keyboard into display and also have hard drive. 255 00:33:31.170 --> 00:33:42.060 William Cheng: Okay, so those are the device driver that are inside BIOS now. So on the motherboard. There's also a tiny chip or the kind of job is called the CMOS the sea mas is it 256 00:33:43.020 --> 00:33:49.500 William Cheng: Contains configuration data. Okay, so what kind of configuration. Again, if you have played around with something like a 257 00:33:50.310 --> 00:33:57.000 William Cheng: Like a Windows machine or something like that, you can actually control when you try to put the machine. Where do you want to do. First you want to move from the CD. 258 00:33:57.420 --> 00:34:03.090 William Cheng: And a DVD device or you want to move on the hard hard drive, you want to move on network or you do on a proof on USB 259 00:34:03.420 --> 00:34:07.680 William Cheng: There's a bunch of configuration information about Which order do you wanna do you want to do them. 260 00:34:08.100 --> 00:34:18.270 William Cheng: So those things can be set up right so if you ever set set those things up before you know that after you said, I'm out. You can say save it. So where do you save it right because you can turn the power off and then the actual remember what the settings are 261 00:34:18.870 --> 00:34:28.140 William Cheng: So there's something called a non volatile memory. Okay, so non volatile memory or and the RAM over here, though. That's a kind of memory that will you turn all power is still remember what the settings are 262 00:34:29.340 --> 00:34:34.320 William Cheng: Okay. So in this case, you know, typically these non volatile memory is very, very small because they're kind of expensive. 263 00:34:34.860 --> 00:34:39.120 William Cheng: So on the IBM PC is no a CMOS. Okay, so what you do is that you, you know, 264 00:34:39.540 --> 00:34:49.620 William Cheng: You put configuration information into a CMOS. And now you can turn off the machine that's not what you boot where you are running your buco it will know where to actually get the boot loader from 265 00:34:50.370 --> 00:35:01.080 William Cheng: Okay, so we you specify the different order a booty your co you're actually telling the BU program to say, you know, know the bootstrap loader from this device first and then try food from that device and the device. 266 00:35:01.650 --> 00:35:06.030 William Cheng: OK, so the buyers chip and let's see much of that work together in order for you to do the operating system. Yeah. 267 00:35:07.980 --> 00:35:09.600 William Cheng: So what teams are the power of self test. 268 00:35:09.840 --> 00:35:20.370 William Cheng: So the parcel test. Make sure all your hardware is okay right so again we saw the picture IBM PC all the devices over there, they will test them all out, if some of the cruiser devices broken weather in that case you will refuse to put the system. 269 00:35:20.730 --> 00:35:28.950 William Cheng: Okay, so, so if you're able to do the system that will mean that all the horrors. Okay, they're wanting important thing that it does is that you will count memory locations. 270 00:35:29.880 --> 00:35:36.780 William Cheng: Okay, so memory is actually funny, you know, so, so like the hard drive, you kind of know whether your hard drive is working or not. 271 00:35:37.320 --> 00:35:40.110 William Cheng: But memory, there's really no way for you to tell where the memory is working or not. 272 00:35:40.470 --> 00:35:46.020 William Cheng: OK, so the only way you can actually test when the member is working or not it's by storing data into it and then read the back 273 00:35:46.260 --> 00:35:52.500 William Cheng: So for example, you will write a value of zero to one memory location. And then when you read it back if it zero always say it's okay. 274 00:35:52.920 --> 00:36:03.570 William Cheng: But, but then again, what about what about all ones, right. So in this case you will write zero FF into the same memory location and then you read a bad if you get the same pattern backbone for zero and also 255 275 00:36:03.990 --> 00:36:08.400 William Cheng: Well then you know that you know this particular memory location. You can store all zero. Yeah. And you can store all once 276 00:36:08.730 --> 00:36:14.820 William Cheng: Okay. Some people actually will try to be even more aggressive, they will try to read more patterns into it to make sure that the memory location, actually. Okay. 277 00:36:15.120 --> 00:36:19.980 William Cheng: Okay, because we're memory goes bad. If that's the memory actually goes into a really, really weird pattern. 278 00:36:20.490 --> 00:36:30.600 William Cheng: Guys anyways that's out of the scope of our class. So what's what's important about the policy has you a test memory and it also will try to figure out exactly how much memory. How much memory you have 279 00:36:31.110 --> 00:36:38.700 William Cheng: Okay, I don't know if you ever have an old you know machine that you think that it has eight gigabytes of memory. But when you try to put the machine. He says it only has one gigabyte. 280 00:36:39.720 --> 00:36:44.730 William Cheng: Okay, so how could I be right. So what happened is that, you know, the portal itself has they tried to test memory location. They found that oh 281 00:36:44.910 --> 00:36:53.250 William Cheng: I can only use the first one gigabyte. So what do we do that, it will tell the ordinances them on the operating system food to say you only have one gigabytes of memory and not eight gigabytes of memory. 282 00:36:54.180 --> 00:37:00.420 William Cheng: Okay. I mean, clearly, you know, if you're operating system cannot fit inside of one gigabytes of memory and well then in that case, you won't be able to put your operating system. Right. 283 00:37:00.510 --> 00:37:11.490 William Cheng: So therefore, counting the number of memory location that's available to operating system. That's a very important operation. And this is done all before you push off in system that. Alright, so once you pass this off on 284 00:37:12.690 --> 00:37:15.120 William Cheng: A per se, and then you verify you have enough memory. 285 00:37:15.360 --> 00:37:25.440 William Cheng: Then you need to find the boot device right then you go to the sea mas and then find out which device, you need to pull from. And then you go to that device, go to the first location to that device. And then, you know, 286 00:37:25.890 --> 00:37:31.830 William Cheng: And then over there. You going to locate your program that we're all okay you're traveling right depends on your terminology 287 00:37:33.690 --> 00:37:39.900 William Cheng: So, so for the good days, you know, for, for, for, you know, for IBM PC have a Windows machine. 288 00:37:40.680 --> 00:37:52.830 William Cheng: You know, the, the, the boot camp program is located in something called the Master Boot Record. Okay, the medical record is sitting at a specific location in all of these devices. So if you want to do for one of the devices over here. 289 00:37:53.340 --> 00:37:57.420 William Cheng: You know the you know the the the blue coat over here will look for the master boot record that 290 00:37:58.380 --> 00:38:04.020 William Cheng: A long time ago, the multiple records very small only has 512 bytes law. Okay, only half a kilobyte 291 00:38:04.530 --> 00:38:15.240 William Cheng: Okay, so. So in the case, you know, this is what it looks like the first 64 bytes over here is the partition table it described how is the hard drive partitions again every partition can have a separate operating system. 292 00:38:15.630 --> 00:38:18.540 William Cheng: Now, so also we had. It was a bad idea. The first partitions. 293 00:38:18.990 --> 00:38:27.150 William Cheng: The starting location is here how big it is, what kind of, oh, you know what kind of property. Does it have, you know, stuff like that. So there are four partition, you can have, you know, that 294 00:38:27.930 --> 00:38:40.170 William Cheng: You can have in a hard drive there and then comes the BU program at the end over here the last two byte inside is founded by. It's called the magic number the magic number tell you whether this harddrive has been formatted or not. 295 00:38:40.500 --> 00:38:46.890 William Cheng: Okay, if your hard drive hasn't been format it, then chances are this magic number will not match you know the pattern or you're looking for. 296 00:38:47.160 --> 00:38:55.080 William Cheng: Once you're finished formatting the harddrive then you will set this number to be something that's recognized the recognizable by the pool program to say that this data is good. 297 00:38:55.740 --> 00:39:02.880 William Cheng: Okay, so again once everything is good. That means that partition table is good. We can we know what can often just a minute here and also the rest of the other 298 00:39:03.450 --> 00:39:09.660 William Cheng: The other than the Mashable record is the BU program. Okay, so some people call this the boot loader. 299 00:39:10.350 --> 00:39:20.550 William Cheng: OK. So again, you know, this is really not that the final boot loader. This is just one of the boot loader. Now this one the maximum size 446 bytes. Now, so what, you know, so, so, so 300 00:39:21.090 --> 00:39:28.830 William Cheng: So, so what the BIOS program will do so the blindfold on the bootstrap they will take this full program over here. The first one, then verify the magic numbers. Okay. 301 00:39:29.010 --> 00:39:39.210 William Cheng: And then what it will do is that it will take this boot loader copy them into memory and then transfer control to appoint tip to one of the memory location over here. And then we're going to start executing the BU program. 302 00:39:39.960 --> 00:39:48.450 William Cheng: Okay. And of course, the rest of the operating system booth depends on what's inside the first book program, right, because once you know if this is a different pool program you're going to end up putting different operating systems. 303 00:39:49.350 --> 00:39:54.390 William Cheng: That are so full, you know, full, full, full for Microsoft right so often is that the boot program over here. 304 00:39:54.540 --> 00:40:02.460 William Cheng: What do you do that it will go to the partition table over here and find out which partition is the active partition. So one of the petition over here will have the AYP is set over here. 305 00:40:02.760 --> 00:40:11.580 William Cheng: Too. So that's the the accurate partition. So what the program will do is it will go to the active partition over here and then try to find the boot loader for the operating system on the 306 00:40:12.060 --> 00:40:17.460 William Cheng: For the actor partition and take that boot loader copied into memory or unfolding into memory and then transfer 307 00:40:17.790 --> 00:40:21.000 William Cheng: Control to it. So that will be known as the volume boot loader. 308 00:40:21.240 --> 00:40:30.540 William Cheng: That settings I partition over here. So when you, you know, take the volume will blow their load into memory and tries to control to her and then the volume boot loader or low, the real operating system, you know, 309 00:40:31.500 --> 00:40:34.170 William Cheng: into memory and then in the end you end up running the operating system. 310 00:40:34.410 --> 00:40:45.750 William Cheng: Okay, so in this case this obviously isn't could be dollars could be windows could be different versions of Windows could be Linux operating system, you know, these kinds of stuff. Yeah. So again, that could be my or some other you know strange kind of operating system. 311 00:40:47.100 --> 00:40:53.850 William Cheng: Alright, so that's the windows, bro. So for Linux booting over here. They are two kinds of Linux, but you know boot loader. 312 00:40:54.270 --> 00:40:59.580 William Cheng: What is called Lilo or like, oh, as it stands for the Linux loader. We don't use it anymore. I it's kind of old. 313 00:41:00.060 --> 00:41:09.810 William Cheng: The second one is the grub boot loader the grub stands for the grand unified boot manager. So this one is pretty fancy it actually understand various file systems. 314 00:41:10.590 --> 00:41:19.560 William Cheng: Okay, so this case the boot loader. Why should understand Windows file system that makes houses them all these kind of stuff and he can he can he can actually specify commands to say where you want to be from 315 00:41:19.980 --> 00:41:23.220 William Cheng: Okay, they will actually have a user interface that you can actually, you know, interact with it. 316 00:41:23.640 --> 00:41:29.820 William Cheng: So this guy is very, you know, sort of bravery events. So these days when you're running Linux, I guess, when you are putting Linux. 317 00:41:30.120 --> 00:41:36.780 William Cheng: Ubuntu 16.4 if you look at the group of information very carefully, you're going to see the word grub showed I showed on the screen. 318 00:41:37.290 --> 00:41:42.180 William Cheng: That alright so what it will do is that, you know, so if you're running grub over here, you need to specify 319 00:41:42.480 --> 00:41:50.790 William Cheng: And I think if you install Linux on a real piece of hardware. Well, he tried to boot grew up, he will actually give you sort of a few choices to boo from one is a default Linux. 320 00:41:51.150 --> 00:41:57.300 William Cheng: Operating system. You want to book. And also, every time we upgrade the operating system. What do what you said he was saved the previous version of the operating system. 321 00:41:57.510 --> 00:42:07.050 William Cheng: In case the new version has problems. So in that case, you can go to grow up and they select a previous version of Linux to run. So this way you know if the latest Linnaeus give you trouble, you can actually go back to the previous version. 322 00:42:07.770 --> 00:42:14.340 William Cheng: Okay, so it again. It's a very, very powerful. You know, above the book but boot loader. And that's what we're using Linux these days. Yeah. 323 00:42:14.820 --> 00:42:23.670 William Cheng: Alright, so in this case you will get a choice to poof, I want to open system over here and you need and what what what it will do is that, you know, in the configuration file you specify a Unix path. 324 00:42:24.180 --> 00:42:31.410 William Cheng: Okay, to actually go to a Unix box and then, you know, low the optimism, the load operating system city inside of our system that 325 00:42:32.070 --> 00:42:34.530 William Cheng: So again, though the rest of it over here will look like this. 326 00:42:34.980 --> 00:42:42.030 William Cheng: There are three different set of, well, you know, first, once you locate that particular Colonel image, right. So again, it's called a coronal image because it's like a 327 00:42:42.240 --> 00:42:49.410 William Cheng: Like a picture of the Colonel. So what you have to do is that typically it's compressed. So you uncompressed it and then you copy them into memory. 328 00:42:49.800 --> 00:42:59.040 William Cheng: Okay, so what you would do is that you you you need to set a memory by cleaning everything up initialize all kinds of stuff, setting up some kind of a stack for you to run over here. 329 00:42:59.610 --> 00:43:05.250 William Cheng: So, and get uncompressed the Colonel, why should uncompressed the Colonel. Now your kernel is in memory. So now you can transfer control to it. 330 00:43:06.480 --> 00:43:19.890 William Cheng: Okay, so, so, so this stage over here is complete done in assembly code. The next stage over here it is still done in assembly code over here. So, what it will do is that in order for you to run the you know the Linux operating system and the Linux operating system is written in C. 331 00:43:21.030 --> 00:43:27.480 William Cheng: OK. So again, the, the world. So think about it is that you know if the stuff that you read the assembly code that will usually part of the hardware abstraction layer. 332 00:43:27.870 --> 00:43:35.640 William Cheng: Will you start running the robin says, and they're all written in C. Okay, so before we get into running sequel. What do you have to have. Well, you have to have virtual memory. 333 00:43:36.360 --> 00:43:47.970 William Cheng: Okay, so at the time when you run this code over here. You don't have any virtual memory. So in the second stage of booting over here, what he will do is that it was set up the initial page table because they are ready to run the ready to use virtual memory. 334 00:43:48.450 --> 00:43:52.050 William Cheng: Okay, so at that point. What it will do is that, I will turn on address translation. 335 00:43:52.800 --> 00:44:01.050 William Cheng: That there's a bit inside CPU to say that whether you are using virtual address or physical address. Okay. In the beginning part where you put over here. You're using physical address 336 00:44:01.260 --> 00:44:10.740 William Cheng: Or you can sort of think about is that your virtual address equal to your physical address. Okay. In the second stage of Linux booting over here we're going to turn on that bid inside the CPU you from this point are 337 00:44:11.340 --> 00:44:17.730 William Cheng: You know, you know, the, the, the, the ordinances Mo, whatever the code that you run can only use virtual dress. 338 00:44:18.360 --> 00:44:24.450 William Cheng: Okay, so in that case, we're going to use accurate translation every advertising goes to what we saw that before, there's going to be something called the page table. 339 00:44:24.660 --> 00:44:30.720 William Cheng: The page table is a data structure inside the operating system that's used by the hardware to perform address translation. 340 00:44:31.350 --> 00:44:39.810 William Cheng: Okay, what do we do, they will take the virtual address over here, they are operating system will use and he will translate into hardware and go to the bus and then you know get data from from memory. 341 00:44:40.590 --> 00:44:54.660 William Cheng: That. So once you turn on address translation. There's no way to go back. This is the wrong way switch. Okay, so, so, so, so during the middle step will be able to turn on either translation and from this point all even your kernel cannot use physical address 342 00:44:55.890 --> 00:44:59.970 William Cheng: Okay, if you give, you know, if you don't do physical address to the Colonel, because I have no idea what to do with this. 343 00:45:00.840 --> 00:45:05.160 William Cheng: Okay, because even Carnell with economies actually go call they have to use virtual address 344 00:45:06.030 --> 00:45:12.630 William Cheng: Or as against very important to understand over here, you know, once you turn on the other translation. The Colonel is always using virtual address 345 00:45:12.990 --> 00:45:24.270 William Cheng: There. And then what it'll do is it'll create something called process zero processor over here is created in a funny way, right, because typically we think about what you create a process you fork a phone, you know, you create a process from the parent 346 00:45:24.540 --> 00:45:31.650 William Cheng: But what about the first process. The preferred brothers process zero with a P. I. P zero. This process is creating a funny way, it's created using assembly code. 347 00:45:32.640 --> 00:45:41.880 William Cheng: Okay. So, therefore, this process is not created in a normal way now so process zero knows how to handle the initial aspect of you know how to use the page table over here. 348 00:45:42.480 --> 00:45:49.800 William Cheng: You know, the, all that kind of stuff there. And then what do we do, is that it will get ready to run sequel. So the third step over here is going to be running sequel. 349 00:45:50.250 --> 00:45:55.950 William Cheng: Okay, so what it would do is anyway initialize the rest of the colonel create the in the process in the normal way. 350 00:45:56.910 --> 00:46:03.990 William Cheng: Okay. So, so what does it mean crazy the normal, right. So for user processes where you create a child process. What do you do you fork off apparent process. 351 00:46:04.770 --> 00:46:14.310 William Cheng: Okay. So inside the current off, but please understand that for is a system called a system called is only used for the user space program. So inside the Colonel, there's going to be the kernel version of the fork system call 352 00:46:14.790 --> 00:46:19.650 William Cheng: Okay, so basically instead of Colonel, there's something similar, where you can actually do is to create a child process. 353 00:46:20.010 --> 00:46:27.210 William Cheng: Okay, so in this case we're going to create child process. Number one, over here, which is which is a process of zero in a regular way. 354 00:46:27.600 --> 00:46:36.720 William Cheng: Okay, so this one we're going to create the intake process and process. Number one over here which data. We're going to be the ancestor for all the other user all the other user processes. 355 00:46:37.770 --> 00:46:44.280 William Cheng: Guys. Okay, there's a process hierarchy where to start with zero here zero is going to create one and one is going to create everything else. 356 00:46:45.450 --> 00:46:50.550 William Cheng: Okay, and then what are those after you create everything else over here. What do you do, right. Why would you do that you with all them to die. 357 00:46:51.600 --> 00:47:02.190 William Cheng: OK. So again, just like our main thread. And I want to write you create all these days. What do you do you wait for them to die. So what he would do is that it has nothing to do it, but he will invoke the scheduler by giving the CPU to one of these other threats. 358 00:47:03.960 --> 00:47:13.170 William Cheng: Right, so your current assignments. Start with. Step three. Above over here, even though this is for Linux and our current something is we need, we need to not exactly the same as Linux. 359 00:47:13.860 --> 00:47:17.070 William Cheng: That I just want to briefly point out the difference over here. 360 00:47:17.520 --> 00:47:23.670 William Cheng: You know, Colonel Simon, you know, at the time that I will you start your start inside of function called bootstrap in bootstrap 361 00:47:23.880 --> 00:47:33.930 William Cheng: Bootstrap is routing see okay at that time. There's no process. Right. It's going to be your job to create process zero again, creating positive zero is a funny way because because you don't create it in the normal way. 362 00:47:34.890 --> 00:47:38.310 William Cheng: Okay, so we'll do, we'll do is that somehow you need to get processed zero to get going first. 363 00:47:38.490 --> 00:47:47.040 William Cheng: Once your process zero then the rest of his normal right and processor is going to create process one and process wise the in a process. It's going to be the ancestor over the user process or something like that. 364 00:47:47.220 --> 00:47:50.190 William Cheng: And then the process one over here is going to invoke the scheduler, all that kind of stuff. 365 00:47:51.270 --> 00:47:56.490 William Cheng: Okay, so basically it's kind of the same idea, except that you know process zero is created. Once it running sequel. 366 00:47:56.760 --> 00:48:01.320 William Cheng: Okay, so for your kernels. I mean, she'd be happy to hear that. You don't have to write a single line of assembly code. 367 00:48:01.740 --> 00:48:11.850 William Cheng: Okay, even though you have to call function where the entire function is implementing assembly code rather you need to know. You need to understand what those functions are doing okay. But otherwise, you don't have any assembly code. Right. Okay. 368 00:48:13.620 --> 00:48:23.880 William Cheng: All right, so I guess let's see what else we have do. Okay. The last two slides over here I put grey X over here. So you're not responsible for them. 369 00:48:24.360 --> 00:48:30.540 William Cheng: The BIOS on the motherboard. They are pretty old. So they don't really, you know, on the IBM PC. They don't change very often. 370 00:48:30.930 --> 00:48:39.930 William Cheng: There's one time I tried to change. I tried to upgrade my BIOS because my file was over 10 years old, as soon as I, you know, plug in a new BIOS the machine die. So I have to buy a new machine anyways. 371 00:48:40.470 --> 00:48:52.260 William Cheng: So pretty much, you know, people don't we have to to to to upgrade the BIOS yeah but you know BIOS routine assembly code. So it's not really flexible. So the current way of doing BIOS is that, you know, 372 00:48:53.040 --> 00:49:03.270 William Cheng: Program doesn't like to the rest of the call. So the current trend is to write them in a high level language and compile the high level language into something called a byte code right so 373 00:49:03.690 --> 00:49:14.310 William Cheng: Those of you who are familiar with Java in the beginning when Java was first invented Java get compiled into biker and they use the ICO interpreter to interpret that to the java byte code and then you have running system. 374 00:49:14.910 --> 00:49:21.000 William Cheng: Okay, so they're doing the same thing over here, there are two different different group over here. One is called open firmware. 375 00:49:21.390 --> 00:49:29.730 William Cheng: So they are designed by Sun and sun now belongs to work on the other one is the one that he probably going to be using these days. So they're developed by Intel 376 00:49:30.120 --> 00:49:36.990 William Cheng: They so instead of using a BIOS they call something called fit right so i think Mac is using here. If I have Windows 10 is also using yep I 377 00:49:37.230 --> 00:49:46.800 William Cheng: So you know case again you write your BIOS in a high level language you get combined tobacco. So in this case, inside the BIOS chip. All you need is a bio. All you need is 378 00:49:47.610 --> 00:49:50.790 William Cheng: Is if I call interpreter. Okay, so this way you can actually run any code. 379 00:49:51.480 --> 00:49:58.890 William Cheng: Okay, and also the other way to do it is that you just have some kind of boost our older that will load the ICO interpreter into memory and now you can run any backup. 380 00:49:59.280 --> 00:50:07.860 William Cheng: Okay, so that seems to be the current trend that's okay, you're not responsible for. I'm just going to mention that, you know, so the BIOS has been also being, you know, else like the happy evolving. 381 00:50:09.240 --> 00:50:18.210 William Cheng: Alright, so we're done with chapter three. So next thing we're going to go to chapter four. So this is a good point to break. I will see you soon.