WEBVTT 1 00:00:21.150 --> 00:00:22.140 William Cheng: Hello everyone. 2 00:00:23.160 --> 00:00:31.440 William Cheng: Can I guess this is the live lecture on Tuesday, May 26 so 3 00:00:32.730 --> 00:00:48.330 William Cheng: As we mentioned before, we're doing this we have flipped classroom. So I hope that everybody has watched the lecture video. So if you have any question feel free to unmute your microphone and then you can ask the question here. 4 00:00:56.250 --> 00:01:02.250 Wookyum Kim: Oh Hi Professor is there like any order. Well, I mean, Chris shiny. 5 00:01:03.630 --> 00:01:05.430 William Cheng: Is there any order for what 6 00:01:06.780 --> 00:01:12.990 Wookyum Kim: I mean for questioning. Is there any order of the shares or can you just talk about it. 7 00:01:14.460 --> 00:01:19.890 William Cheng: Um, there's no order. So yeah, so anybody who has a question can ask the question. 8 00:01:29.160 --> 00:01:29.850 William Cheng: So, go ahead. 9 00:01:31.350 --> 00:01:35.430 Wookyum Kim: Yeah, four slides number 16 10 00:01:36.030 --> 00:01:39.060 William Cheng: Okay, hold on, let me go to the first slide number 16 11 00:01:39.450 --> 00:01:41.250 Wookyum Kim: Slide number 16 yo 12 00:01:41.790 --> 00:01:44.280 William Cheng: Okay, let me let me go there. 13 00:01:46.350 --> 00:01:48.150 Wookyum Kim: So it's about the computer running 14 00:01:48.270 --> 00:01:49.710 Organizations. 15 00:01:51.270 --> 00:01:51.750 William Cheng: Okay. 16 00:01:52.110 --> 00:02:00.300 Wookyum Kim: Yeah, I was wondering, is that a zero through a certain one in X 86 processor 17 00:02:02.220 --> 00:02:12.690 Wookyum Kim: I'm wondering if these are all the memory in the CPU or is it the kind of memory. Is it just a refers the memory in the 18 00:02:13.740 --> 00:02:15.570 Wookyum Kim: I mean address of the memory. 19 00:02:16.920 --> 00:02:21.780 William Cheng: Okay, let me go there. So you can see the computer screen, right. 20 00:02:21.990 --> 00:02:22.710 Wookyum Kim: Yeah yeah 21 00:02:22.950 --> 00:02:24.390 William Cheng: Okay, so 22 00:02:27.510 --> 00:02:35.340 William Cheng: Right here. Right. So these slides over here. So the. So on the left hand side, everything is inside the CPU. Okay. So, he said. 23 00:02:36.210 --> 00:02:36.780 Wookyum Kim: Yeah, okay. 24 00:02:38.010 --> 00:02:47.040 William Cheng: So instead of CPU. They are these special fast memory that has names, so they are called registers and they have special purpose. Oh. 25 00:02:47.070 --> 00:02:47.640 Wookyum Kim: What about the 26 00:02:49.320 --> 00:02:52.770 William Cheng: Ones. Yeah. So these are the signals on the bus. 27 00:02:53.190 --> 00:02:59.430 William Cheng: Yeah, okay. So, so I don't know if you have see a computer chip computer chip has a bunch of pins coming out. 28 00:03:00.030 --> 00:03:16.470 William Cheng: Those pins has names. So the names, you know, for the signals are called a 03 through 831 so so these computers are sitting on boards. So the boards connect them to the bus. So this way when the CPU wants to put an address on the bus everybody on the bus can see it. 29 00:03:17.550 --> 00:03:27.840 Wookyum Kim: Oh, OK. So it's just a sickness, but it just refers that I mean it just referred referring the address of that memory. 30 00:03:28.770 --> 00:03:30.270 William Cheng: It's the address on the bus. 31 00:03:30.990 --> 00:03:35.370 William Cheng: On the bus. The bus is shared by everybody who is connected to the bus. 32 00:03:36.060 --> 00:03:43.500 William Cheng: So if you put an address on the bus. Everybody can see that, oh, you, you have this address on the bus and then for the memory and the device controller. 33 00:03:43.740 --> 00:03:54.660 William Cheng: What they do is that every one of those devices and the memory. They are mapped to a different set of addresses so they will look at the address onto the bus and say, oh, should I respond, or should I ignore this. 34 00:03:54.990 --> 00:03:57.900 Wookyum Kim: Oh, okay. Thank you. 35 00:03:58.200 --> 00:04:02.520 Wookyum Kim: Okay, yeah, or so in the slides number 20 36 00:04:04.290 --> 00:04:06.060 Wookyum Kim: Oh yeah, it's about DDP 37 00:04:06.390 --> 00:04:11.040 Wookyum Kim: I'm, I'm wondering what's the difference between the ESP and UDP here. 38 00:04:11.340 --> 00:04:20.040 William Cheng: Rice. Yes, yes. P point to the top of the stack. Yes. This way if you want to make another function call. You know where to build the next friend. 39 00:04:20.640 --> 00:04:27.120 William Cheng: Okay, that he BP is pointing in the middle of the stack over here, so they can access everything inside the stack rank. 40 00:04:29.040 --> 00:04:30.540 Wookyum Kim: Oh, 41 00:04:31.140 --> 00:04:41.730 William Cheng: Okay, so later on in chapter three, we're going to see exactly where it's pointing to. And, and we're sort of, you know, going to show you the code that how does the VP is used to access function argument, a local variable. 42 00:04:42.330 --> 00:04:42.900 Wookyum Kim: Okay. 43 00:04:43.110 --> 00:04:54.840 William Cheng: Okay, as it turns out that if you have EDP if you use ESP is going to be very, very difficult to access function argument, a local variable. But if you use another pointer, you know. So again, long time ago. 44 00:04:55.320 --> 00:05:07.500 William Cheng: Compiler people operating system people, how are people that got together the figure, all these things out and then they decided that you need to register one point to the top of the stack and the other one point to the middle of the stack frame. 45 00:05:08.460 --> 00:05:10.320 Wookyum Kim: I see. Okay, thank you. 46 00:05:10.620 --> 00:05:15.630 Wookyum Kim: Okay, yeah. And can I go over. I mean, can I go for go 47 00:05:16.080 --> 00:05:17.070 William Cheng: Yeah, if there's nobody 48 00:05:17.640 --> 00:05:26.070 William Cheng: In a hurry to ask question you can continue to ask question until you're done then kind of that I can go to another person. So I'm pretty sure you are not the only person has these kind of questions. 49 00:05:26.550 --> 00:05:33.840 Wookyum Kim: Okay, yeah, they're good then slide 27 about the software interruptions and interrupt. 50 00:05:34.440 --> 00:05:34.860 Okay. 51 00:05:36.510 --> 00:05:50.430 Wookyum Kim: Yeah, so it's i mean i i don't know why there's a I mean I cannot really tell the difference between the tribe and so Twitter interrupt. Is it that kind of a trap or 52 00:05:52.020 --> 00:05:59.430 William Cheng: Um, I mean this is part of the CPU design. You know, when people design the CPU, they sort of figured out that, you know, you know, over the years. 53 00:05:59.910 --> 00:06:06.330 William Cheng: That decided to have a software interrupt is a good idea. Okay. Sometimes you need them for you know debugging and, you know, things like that. 54 00:06:07.020 --> 00:06:17.730 William Cheng: So for Intel Intel, you know, again, different CPU, they have different kinds of design some CPU has a special instruction for trap for Intel CPU. They use the software interrupt for trap. 55 00:06:19.980 --> 00:06:25.860 William Cheng: Is the software interrupt over here. There are 256 different ones. So they say, oh, that's just take one of them as trap. 56 00:06:26.220 --> 00:06:28.260 William Cheng: So in zero x two, he means trap. 57 00:06:29.820 --> 00:06:41.460 Wookyum Kim: Or so is for the CPU. I mean, it's the, I mean the software interrupt this terminology is for the CPU right it's not 58 00:06:41.760 --> 00:06:50.040 William Cheng: That these are this machine instructions. Right. So just like any machine instruction that can be executed, you know, that can be executed inside the CPU. 59 00:06:50.940 --> 00:06:57.210 Wookyum Kim: Oh, so okay so okay to implement the trend machine instruct me instructions. Okay. 60 00:06:57.450 --> 00:07:03.240 William Cheng: Yeah, so there's one special software interrupting software into of instruction that's interpreted as a trap. 61 00:07:04.170 --> 00:07:06.240 Wookyum Kim: Oh, OK. 62 00:07:07.530 --> 00:07:09.270 Wookyum Kim: OK. And in this 63 00:07:09.990 --> 00:07:14.430 William Cheng: Chapter three, we're going to see a lot more machine instructions, what they look like on Intel unite etc. 64 00:07:15.450 --> 00:07:18.930 Wookyum Kim: Okay, so. Okay, I got it. Yeah. 65 00:07:20.640 --> 00:07:21.270 Wookyum Kim: And then 66 00:07:21.300 --> 00:07:24.420 William Cheng: Slide 4040 okay 67 00:07:30.600 --> 00:07:30.930 William Cheng: All right. 68 00:07:31.200 --> 00:07:39.540 Wookyum Kim: Yes. So from here, I'm really confused with the the process. So, in the previous lectures. 69 00:07:41.610 --> 00:07:45.210 Wookyum Kim: We. I mean, I learned this, the process is just a 70 00:07:47.010 --> 00:07:48.120 Wookyum Kim: Memory right 71 00:07:48.600 --> 00:07:54.150 Wookyum Kim: I mean, remember I said yes. Yes, so. So last time we will use the word process is an abstraction of memory. 72 00:07:54.480 --> 00:07:55.800 Wookyum Kim: Yeah yeah yeah instructions. 73 00:07:56.760 --> 00:08:01.950 William Cheng: So so so that's just one aspect of a process. Okay, so processes are running program. 74 00:08:03.060 --> 00:08:03.690 Wookyum Kim: Okay. 75 00:08:03.810 --> 00:08:09.480 William Cheng: It's one of the most important thing that we're going to talk about is how to, you know, how, how does the operating system run a program 76 00:08:10.440 --> 00:08:22.140 Wookyum Kim: Okay, but I'm done, why do, why is that abstraction. I, why do we express the process as a abstraction of the memory. 77 00:08:24.090 --> 00:08:32.010 William Cheng: So the way we started on in the first lecture is to say that while you know we needed abstraction for memory because we need to use memory, right. 78 00:08:32.610 --> 00:08:39.300 William Cheng: So how do we use memory, what, what we have the idea of an address space. If you haven't, if you have an address space, you can use memory. 79 00:08:40.350 --> 00:08:44.850 William Cheng: Okay, so the question is where is the address based will address space as part of a process. 80 00:08:49.560 --> 00:08:51.870 Wookyum Kim: So from I am from now on, then then 81 00:08:52.110 --> 00:08:55.740 Wookyum Kim: If we use the word process, then it's 82 00:08:57.000 --> 00:09:01.890 Wookyum Kim: The rear. I mean, the system process rather than the instructions of the memory or 83 00:09:02.730 --> 00:09:11.730 William Cheng: Yeah, so, so, so, so the abstraction of memory is part of the reason we need to process. Right. We also need process to do all kinds of stuff. 84 00:09:13.020 --> 00:09:13.470 Wookyum Kim: Okay. 85 00:09:13.710 --> 00:09:25.320 William Cheng: Okay, so, so to run your program. We need a process. Otherwise, there's no way to run your program. So we mentioned, like what is the fundamental abstractions. We're running a program. We need to process, we need to CPU, we need 86 00:09:27.630 --> 00:09:32.490 William Cheng: The, the execution context, right. So all these things together, we can run a program 87 00:09:34.770 --> 00:09:41.010 William Cheng: Okay. So part of the reason we need a process is to use memory, but that's a reason to use a process. 88 00:09:42.750 --> 00:09:54.420 William Cheng: Right, so, so again, long time ago, the opportunities and people, the compiler people and the hardware people they got together to try to sort of figure out how to do this and then come up with the idea of a process. 89 00:09:54.810 --> 00:09:59.490 William Cheng: And then we would need to be able to create process and do all kinds of stuff with the process. 90 00:10:00.570 --> 00:10:01.290 Wookyum Kim: Oh, 91 00:10:02.280 --> 00:10:06.570 William Cheng: So at this point is kind of abstract, right, because we don't really know exactly what it is. 92 00:10:06.870 --> 00:10:07.800 Wookyum Kim: Yeah, yeah. The 93 00:10:07.890 --> 00:10:13.020 William Cheng: Point of this class is that by the end of the semester, you will know you know you'll know everything about a process. 94 00:10:13.380 --> 00:10:15.330 Wookyum Kim: Okay, thank you. Yeah. 95 00:10:15.360 --> 00:10:21.270 William Cheng: Yeah. So also, you know what, when you are typing, you know, typing your commands in a you know terminal. 96 00:10:22.110 --> 00:10:26.610 William Cheng: You know you're dealing with the process, right, because everything that you sort of interact with inside a computer. 97 00:10:27.600 --> 00:10:41.130 William Cheng: It's a process. So you have a login show or your command shell. That's a process. Will you try to type ls right LS is going to be the name of the program that you run and that's another process. So we have process your process here, their process everywhere. 98 00:10:41.520 --> 00:10:46.440 Wookyum Kim: Okay. Okay, thank you. And my last question soon destroyed. 99 00:10:46.500 --> 00:10:49.320 William Cheng: 4444 last slide. Okay. 100 00:10:49.470 --> 00:10:56.160 Wookyum Kim: Yeah, yeah. So in here, I mean in the diagrams. There is a return code right 101 00:10:56.400 --> 00:11:02.190 Wookyum Kim: So I'm wondering is that I'm done before process dies, then 102 00:11:03.210 --> 00:11:04.350 Wookyum Kim: Return code is on 103 00:11:04.560 --> 00:11:05.610 Wookyum Kim: Is just a blank. 104 00:11:06.000 --> 00:11:06.330 Or 105 00:11:07.560 --> 00:11:07.980 Wookyum Kim: Sir, 106 00:11:08.250 --> 00:11:10.140 Wookyum Kim: It's invalid isn't involved. 107 00:11:10.230 --> 00:11:21.360 William Cheng: So you can't you can't so so depend on how you initialize data structure right if you get the data structure like this initialize this to 99 okay so 99 is not the return code, you can initialize the anything you want, as long as you don't use it. 108 00:11:22.860 --> 00:11:26.100 William Cheng: Though you can initialize the whatever you want, but when your program dies. 109 00:11:26.280 --> 00:11:36.960 William Cheng: Then you need to remember how does the program returned from the main function and that will be a return call and from that point. Oh, you, you, you, you're not allowed to touch it, right, because that will be the actual return code for the program. 110 00:11:37.530 --> 00:11:41.700 William Cheng: I see. But before the program dies. It can be anything you don't want to initialize it that's fine too. 111 00:11:42.690 --> 00:11:50.640 Wookyum Kim: But you said process is kind. I mean this. Can you, can I think like a process is kind of contacts of the 112 00:11:51.660 --> 00:11:53.280 Wookyum Kim: Some the 113 00:11:54.510 --> 00:11:57.540 Wookyum Kim: Function. I mean, the function is executed. 114 00:11:57.990 --> 00:12:02.610 William Cheng: Well, so the process is an abstraction right it's abstractions running program. 115 00:12:03.030 --> 00:12:17.100 William Cheng: Yeah, so, so, so what in computer science when we try to implement an abstraction, we use data structure we use algorithm we use all kinds of stuff. Okay, so this data structure is a data structure inside a kernel that represent a process. 116 00:12:18.390 --> 00:12:28.320 William Cheng: Okay, and different operating system. They can implement a process differently, but for, you know, for for this class, you know, we sort of have a you know this that this Unix, Linux, that process control blog. 117 00:12:29.010 --> 00:12:32.730 William Cheng: That remember things like the process ID, the return code and all these kinds of stuff. 118 00:12:33.240 --> 00:12:47.760 William Cheng: Okay, whereas okay again at this point is sort of introductory materials and things out at a very, very high level is very abstract and then you know in colonel in the Yukon Osama you get to implement a process. So then you will learn what a process is 119 00:12:49.140 --> 00:13:00.240 William Cheng: Once you start implementing it. It will be up become more clear. You know what what what what you're doing with the process. What kind of process do how do you go from one process to another process. Why does process die. How do you create them all that kind of stuff. 120 00:13:00.810 --> 00:13:02.820 Wookyum Kim: Okay, thank you very much. Okay. 121 00:13:02.850 --> 00:13:03.240 William Cheng: You're welcome. 122 00:13:03.780 --> 00:13:04.110 Yeah. 123 00:13:06.510 --> 00:13:12.060 William Cheng: Yeah, anybody who wants to ask a question, feel free to unmute your microphone and you know as asked question. 124 00:13:15.690 --> 00:13:16.230 William Cheng: Hello. Hi. 125 00:13:17.700 --> 00:13:19.320 Jiaming Xu: I have a question. 126 00:13:19.380 --> 00:13:23.370 William Cheng: Page 30 6030 what 127 00:13:26.790 --> 00:13:28.260 William Cheng: I'm sorry, is 36 128 00:13:31.260 --> 00:13:35.190 William Cheng: Page 1616. Okay, so let me go there. 129 00:13:45.600 --> 00:13:57.840 Jiaming Xu: My question is, if the CPU bound to relay the rate of value of y actually use a city, you want to do the addition and it will read the value why and see from the memory. 130 00:13:58.380 --> 00:14:14.220 Jiaming Xu: So it can simply put the address of why in the eight zero to a 31 and two the rate I read, I wanted to drive it through about a. How does the memory response to this just come up 131 00:14:14.760 --> 00:14:22.440 William Cheng: Right, so all these memory and devices they're sitting on the bus, they look at the addresses and try to sort of figure out, does this address belongs to me. 132 00:14:23.370 --> 00:14:30.450 William Cheng: Okay, so what do you will do that you need to put an address onto the bus. So, this particular address over here, you know, so, so, so, by the way. 133 00:14:30.960 --> 00:14:38.400 William Cheng: This is, you know, this example. This is just an example. Okay. Because if you have, you know, eight gigabytes of memory. You need 30 134 00:14:39.060 --> 00:14:43.680 William Cheng: If you have eight gigabytes of memory. You need 33 bits. Okay, so it doesn't really work out. 135 00:14:44.460 --> 00:14:56.790 William Cheng: Okay, so in the real hardware over here it's a little more complicated, right. So over here we just have to use a simple model over here to show you that using the address when you put an address onto the bus. It only address one of these devices or the memory. 136 00:14:57.990 --> 00:15:03.510 William Cheng: Okay, so one of them will look at this address, say, Oh, this one is for me. So therefore, they will look at the rest of the address and decide what to do. 137 00:15:05.100 --> 00:15:15.210 William Cheng: I mean, again, you have 16 gigabytes of memory that you need 34 bits of address we can use 32 bits of advice to address you know 3034 bits of your 16 gigabytes of memory. 138 00:15:16.770 --> 00:15:20.430 Jiaming Xu: What could the value of y in the bath. 139 00:15:21.810 --> 00:15:30.960 William Cheng: Yeah. So what happened is that, you know, the, the, you know, when we write code like this, x equal to y plus z, right, if this is psycho. We have the virtual address of y and z. 140 00:15:31.410 --> 00:15:36.480 William Cheng: Okay, in order for you to put an address onto the bus, you need to put the physical address onto the bus. 141 00:15:37.050 --> 00:15:44.370 William Cheng: So inside the CPU. There's a mechanism that we use is called address translation. We're going to translate a virtual address to a physical address 142 00:15:44.580 --> 00:15:50.370 William Cheng: And we're going to sort of talk about how to do that in chapter seven is a. So you have to wait all the way to Chapter seven to see how that that is done. 143 00:15:50.670 --> 00:16:00.630 William Cheng: Okay, so right now we just sort of introduced the concept that there's virtual address. There's physical address the virtual address will convert into a physical address and then you put the physical address onto the bus. 144 00:16:03.540 --> 00:16:03.930 Jiaming Xu: Question. 145 00:16:05.160 --> 00:16:05.400 William Cheng: Okay. 146 00:16:08.460 --> 00:16:11.340 Hardik Mahipal Surana: Good morning, Professor, I had a question in regards to the 147 00:16:13.230 --> 00:16:15.570 Hardik Mahipal Surana: Function, the API for creating a process. 148 00:16:16.410 --> 00:16:17.820 William Cheng: Do you have a slide number for them. 149 00:16:18.900 --> 00:16:24.600 Hardik Mahipal Surana: I think it's towards the end, I think probably slide number 40 150 00:16:25.860 --> 00:16:26.190 William Cheng: Okay. 151 00:16:26.490 --> 00:16:34.170 Hardik Mahipal Surana: Yeah. So my question is actually that in in a program if you have, let's say, two consecutive four calls 152 00:16:35.250 --> 00:16:39.900 William Cheng: Okay, so your plan plus as one of the Creator child processes. Yes, that 153 00:16:40.470 --> 00:16:49.710 Hardik Mahipal Surana: So if you have to focus system cause one after the other. So how do these prophecies get created because I think once you create the first for 154 00:16:50.160 --> 00:16:59.160 Hardik Mahipal Surana: Once you are at the first book called you create a child process and then the board, the parent and child will continue execution from the next line right so 155 00:16:59.190 --> 00:17:04.320 Hardik Mahipal Surana: Right, the child in turn also be creating another child process in it because of the second phone call. 156 00:17:05.310 --> 00:17:11.220 William Cheng: Yes. Yeah, so, so if. OK. So again, if it's very, very important right here. If you write your code like this. 157 00:17:11.940 --> 00:17:20.100 William Cheng: Okay, then that's what's going to happen both the parent and the child, they're going to for call additional, you know, a processes, but you probably shouldn't write code like that. 158 00:17:20.850 --> 00:17:28.200 William Cheng: Okay, so. So the way we're going to sort of talk about is that we're going to sort of give you the system called interfaces for you to talk to as the operating system to do something for you. 159 00:17:28.500 --> 00:17:35.310 William Cheng: But if you use it incorrectly. Well, then the opposite will not be able to help you, the operating system is there just to follow instructions. 160 00:17:36.270 --> 00:17:42.480 William Cheng: Okay, so it's both the parent of the child process both of them called fork again. Well, now you're going to end up with, you know, for processes. 161 00:17:43.440 --> 00:17:52.320 William Cheng: So if that's what you want and your record like that. So at the beginning of the next lecture, we're going to see what is the usual proper way to to to to call fork. 162 00:17:53.700 --> 00:17:55.170 William Cheng: Okay, and 163 00:17:55.200 --> 00:18:10.470 Hardik Mahipal Surana: Another question. So once we create a child process is what would be the way for communication between the parent and the child. And also, is it possible for one process to communicate with a different process which is not expected 164 00:18:11.190 --> 00:18:23.250 William Cheng: Yeah, so in this class. So since this is an introductory up in the system class. Most of the time we're going to talk about sixth edition Unix in sixth edition Unix the parent and the child process, they don't talk to each other. 165 00:18:24.360 --> 00:18:34.140 William Cheng: Okay. Okay, so, so I guess in this class. What sort of briefly talked a little bit about how the process can talk to each other, you know, using some other mechanism. Okay. 166 00:18:34.890 --> 00:18:38.370 William Cheng: Wait, wait, sorry, I need to take it back. Actually, we're going to in chapter three. 167 00:18:39.210 --> 00:18:44.910 William Cheng: Chapter three, or in chapter one in chapter one, I guess in the later part of the session, we're going to sort of talk about one mechanism. 168 00:18:45.120 --> 00:18:53.850 William Cheng: For the parents have the chance to communicate and the way they can communicate with each other is going through the file systems. Okay, so that's one way for the parent child to talk to each other. 169 00:18:55.020 --> 00:18:55.290 William Cheng: Okay. 170 00:18:55.440 --> 00:19:00.480 Hardik Mahipal Surana: And is it possible for one process to talk to a completely different one, which is not it's better 171 00:19:00.660 --> 00:19:08.610 William Cheng: Yeah, so, so, so the way you should think about is, is that if you want to be able to talk to another process you first you have to name that process. 172 00:19:09.150 --> 00:19:15.390 William Cheng: Okay, so if you have so so so in that case, again, the apprentices need to get involved in order for you to help you to make a connection. 173 00:19:15.960 --> 00:19:24.900 William Cheng: To that process. So you need to be able to tell the organisms and say, Hey, you know, I want to talk to that process. Here is the name or the process or maybe the process identifier for that process. 174 00:19:25.140 --> 00:19:29.700 William Cheng: And then you need to, sort of, you know, figure out whether that process is willing to talk to you or not. 175 00:19:30.480 --> 00:19:39.930 William Cheng: So. So in general, this can get really complicated, right. So, typically sort of way we'll sort of think about is that, oh, well, maybe use networking right he's networking then then then then this might work. 176 00:19:41.070 --> 00:19:45.150 William Cheng: Okay. But again, this is that will not be the focus of this class. Okay. 177 00:19:45.720 --> 00:19:50.670 Hardik Mahipal Surana: And when we use for and create a new process, is that considered as 178 00:19:51.780 --> 00:19:56.250 Hardik Mahipal Surana: So since we're copying the I just based on everything. Does it have its own 179 00:19:57.300 --> 00:20:02.730 Hardik Mahipal Surana: Does it have its own as I'm sure that has its own process. And can you know continue with what it's supposed to do. 180 00:20:03.450 --> 00:20:12.630 William Cheng: Yeah, so the idea here is that you, you make a copy of the parent and then now the child has its own address space right so now the parent will continue to run to modify its own address space. 181 00:20:12.870 --> 00:20:22.560 William Cheng: The child will continue to run and modify its own address space. So, pretty soon they will be different. Okay, so these are two completely separate processes, they can, they will run independently. Okay, and 182 00:20:22.680 --> 00:20:34.320 Hardik Mahipal Surana: If you look at the processor abstraction of threads over here. Once we do a full can create a process do we say that now both the parent and the child around with one thread in them by default. 183 00:20:36.660 --> 00:20:46.470 William Cheng: It depends on the operating system design. We haven't really talked about multi threading yet, right. So, so at this point. So you can sort of think about every process, how it has only one threat. 184 00:20:47.040 --> 00:20:51.090 William Cheng: Okay, so in that case, one of the you know the the thread inside your process. 185 00:20:51.810 --> 00:20:59.100 William Cheng: Make the fourth system call you're going to make a copy of yourself inside a copy. There's also in the trial process has has also only one threat. 186 00:20:59.490 --> 00:21:05.400 William Cheng: Okay, and that's right. It's doing exactly the same thing as the the thread in the parent is doing. And that's in the middle of the fork. 187 00:21:05.700 --> 00:21:13.500 William Cheng: Right. So in this case, both of them is going to return from fork, they will go in and go back into the, the, the program, they will return from pork and then we'll start executing, you know, 188 00:21:14.730 --> 00:21:17.250 William Cheng: Starting from the instruction after the fork. 189 00:21:17.940 --> 00:21:18.570 Hardik Mahipal Surana: Okay, good. 190 00:21:20.100 --> 00:21:31.890 Hardik Mahipal Surana: And just one last question. So I think towards the end in the process control blocks and the last slide 44 you explained that each operating system has its own design for this link list right 191 00:21:34.050 --> 00:21:37.320 William Cheng: They have their own design of the process control block. Okay. 192 00:21:37.350 --> 00:21:50.670 Hardik Mahipal Surana: So basically, whenever we create new processes from the current process or there are independent programs that are running in memory. So all of these are all of the p PCBs connected in some form. 193 00:21:51.900 --> 00:22:01.650 William Cheng: That depends on the design. Right. You know, so, so maybe there's, you know, one design, you know, they are you know all the processes. I put inside of hash table. 194 00:22:02.310 --> 00:22:05.730 William Cheng: Maybe another design all the processes. I put inside a tree. 195 00:22:06.330 --> 00:22:15.060 William Cheng: Maybe there are some fancy trees out there. So, so in case you need to keep track of thousands and thousands of processes. Maybe you need some kind of, you know, fancy data structure to keep track of them. 196 00:22:15.630 --> 00:22:21.000 William Cheng: So every operating system can decide how they want to organize all these process control blocks. Okay. 197 00:22:21.240 --> 00:22:33.270 Hardik Mahipal Surana: So with respect to interrupt when when the hardware comes back to the West with the interrupt and the audience needs to wake up a colonel trade for the process that triggered the call. So in that case, 198 00:22:34.080 --> 00:22:46.110 Hardik Mahipal Surana: Again, as part of what you said, will the way the OS because of which try to figure out which there it is and wake it up. Does that also depend upon the design of how the PCBs store for it. 199 00:22:46.890 --> 00:22:49.320 William Cheng: Yes. Yeah, yeah. So all these so so 200 00:22:50.790 --> 00:23:04.290 William Cheng: That's why we need to sort of focus on Sixth Edition Unix because sixth edition eunice's the very simple operating system so we can sort of talk about the design there and then later on if you can take advance operating system class to see what our people are doing today. 201 00:23:05.730 --> 00:23:10.650 William Cheng: Okay. Okay, so, so that, so also our Colonel assignment is kind of like sixth edition Unix 202 00:23:11.340 --> 00:23:23.820 William Cheng: So pretty much, you know, all the data that structure that you going to see are just linked lists these sort of look very similar to my folder to list. So you have a list of lists and the you keep track of stuff that way. Right. So it's a very, very simple organization. 203 00:23:24.990 --> 00:23:37.350 William Cheng: Okay. OK, so for for simple organization that means that your system is not very scalable. If you want to only run you know 20 processes. That's no problem. But if you want to run 2000 processes. Well, then it's going to get really slow. 204 00:23:39.150 --> 00:23:39.420 William Cheng: Okay. 205 00:23:41.370 --> 00:23:42.390 Hardik Mahipal Surana: Got it. Okay, thank you so much. 206 00:23:42.810 --> 00:23:43.380 William Cheng: Okay. You're welcome. 207 00:23:48.690 --> 00:23:54.390 William Cheng: Okay, if anyone else has a question, feel free to unmute your microphone. And then, you know, ask questions here. 208 00:23:56.310 --> 00:23:57.450 Chandrasekar Balachandran: Professor, can you hear me. 209 00:23:57.720 --> 00:24:01.350 Chandrasekar Balachandran: Yes, so I had a query with regards to 210 00:24:02.640 --> 00:24:04.770 Chandrasekar Balachandran: The process methods that we had on slide number 211 00:24:04.770 --> 00:24:07.020 3939 212 00:24:08.040 --> 00:24:20.190 Chandrasekar Balachandran: digest this fork exit wait and exec. Does that mean that this course doesn't focus on the new tax and all the other methods of of thread synchronization and process communication between the threads or 213 00:24:20.490 --> 00:24:28.920 William Cheng: So this is for processes. Right. So the first one to talk about processes. Chapter two is Chapter two, we talk about threat. 214 00:24:30.150 --> 00:24:33.420 William Cheng: Okay, so we're going to devote the entire chapter on talking about threat. 215 00:24:34.410 --> 00:24:44.130 Chandrasekar Balachandran: Right so so to my understanding, right now the fork operation is still going to create a child thread from the content process. Correct. 216 00:24:44.580 --> 00:24:56.940 William Cheng: Well, so right now we're only talking about processes. Right. So. So in this case, yeah. So when you create a child process. If you think about threads, while the child process also has threats. Right. Okay. So, but, but we sold it. We're going to sort of talk about that in chapter two. 217 00:24:57.900 --> 00:25:01.920 Chandrasekar Balachandran: I see. Okay, so this is just for concept that we're creating it right now. 218 00:25:02.280 --> 00:25:14.190 William Cheng: Right so so right now we're talking about for how to create a process at the beginning of the next lecture, we're going to talk about how does the process die, and how does one process wait for another process to die and then how does the ha 219 00:25:14.640 --> 00:25:24.870 William Cheng: Ha, how do you execute another program within your own process. Okay. And then we finish with that we're going to talk a little bit about the file systems and then we're going to go to chapter two and talk about threats. 220 00:25:25.350 --> 00:25:25.620 William Cheng: Guys. 221 00:25:25.650 --> 00:25:27.480 William Cheng: So that the new tax. That's what we're going to cover 222 00:25:27.930 --> 00:25:38.340 Chandrasekar Balachandran: I see. And also, and just as a related question. So you mentioned on the files file sharing. So that means that we don't do message passing with between processes in this particular class. 223 00:25:40.080 --> 00:25:48.060 William Cheng: Yeah message passing is advanced topic we're going to sort of briefly talk a little bit about message passing towards the end of the semester. 224 00:25:49.080 --> 00:25:49.920 Chandrasekar Balachandran: I see. Okay. 225 00:25:49.950 --> 00:25:52.560 William Cheng: So most of the time. Yeah. Most of the time we just used about this. 226 00:25:53.040 --> 00:25:55.350 Chandrasekar Balachandran: Okay, so also another question on slide number 227 00:25:55.350 --> 00:25:57.810 William Cheng: 2828 okay 228 00:25:58.230 --> 00:26:00.210 Chandrasekar Balachandran: Yeah, I had trouble understanding 229 00:26:02.910 --> 00:26:09.150 Chandrasekar Balachandran: Signal handlers and could you probably elaborate more on so I understand handle probably means something like a context. 230 00:26:10.830 --> 00:26:16.440 William Cheng: Oh no handler, just a function. Okay, so what happened is that, you know, so let's say that I am you know my 231 00:26:17.610 --> 00:26:25.110 William Cheng: My I don't want my program to die when the user press Control see there's what I would do is I will specify a function. This function is called a single handler. 232 00:26:25.560 --> 00:26:34.410 William Cheng: Okay, it's going to be in my program. And then what I will do that will tell the operating system to say if the users per call press Control see call this function. Okay. And don't kill my program. 233 00:26:35.550 --> 00:26:42.030 William Cheng: Okay, so what happened is that what the user press Control. See, you know, the operating system, we're going to see control sees being pressed because it's a hardware signal. Right. 234 00:26:42.300 --> 00:26:47.220 William Cheng: In that case, what it will do is that it will make it up call, and then call this function and then he will not kill your program. 235 00:26:48.720 --> 00:26:58.170 Chandrasekar Balachandran: So just to ask if I were to implement this right now in our warm up on assignment. How would I be able to go and then prevent the operating system from stopping my process. 236 00:26:59.130 --> 00:27:05.880 William Cheng: It is a function, you can cause cause signal. So there's a function called signal. The other way I guess today. 237 00:27:06.360 --> 00:27:19.230 William Cheng: People call this function called six set. Okay, so if you call the function of six set. So you can look at the men page six that and also we're going to cover that in chapter two. Okay, chapter two, when we talk about threads and things like that. We also going to talk about signal handling. 238 00:27:20.400 --> 00:27:21.210 Chandrasekar Balachandran: I see. Okay. 239 00:27:21.420 --> 00:27:28.050 William Cheng: Yeah, so you can actually just look at a chapter the chapter to lecture slides on the second set of slides has a lot of stuff about signals. 240 00:27:28.350 --> 00:27:29.100 Chandrasekar Balachandran: Okay, cool. 241 00:27:30.300 --> 00:27:38.160 Chandrasekar Balachandran: Alright. And the last question that I had is, with regards to the follow up with the question that was answered earlier. So you said you mentioned that 242 00:27:39.030 --> 00:27:57.300 Chandrasekar Balachandran: When a process is creating another process from itself, such as a thread if for example you press Control C and you sent an interrupt. Does that mean that the earth is going to send the intro to the parent or does that mean to do is we're going to send the interrupt about the process. 243 00:27:58.320 --> 00:28:07.920 William Cheng: Right, so, so if you think about the control C right so controversies a little tricky, right, because they're hard to interrupt. They are generated completely asynchronously with respect to your program. 244 00:28:08.280 --> 00:28:16.410 William Cheng: Okay. So, therefore, if you have parent child. They're both running when you press Control see at the time who is running. Okay, so it's very, very difficult to tell 245 00:28:17.010 --> 00:28:26.400 William Cheng: Okay. So, therefore, the way that people. Does that operating system is to be able to determine when you press Control see which process gets the control see only one process will get it. 246 00:28:27.600 --> 00:28:36.090 Chandrasekar Balachandran: So for example, if I was running something in the terminal. So I'm assuming that a terminals context place is defined for that particular control. See, because I can have multiple terminals running 247 00:28:36.450 --> 00:28:49.800 Chandrasekar Balachandran: Different processes and I can press Control seeing each one of them. So is it that control see goes to the entire process space of just one terminal and everything inside that terminal is one space and it ended in that particular space. Is that how it works. 248 00:28:49.920 --> 00:28:56.010 William Cheng: OK, so the way Unix deal with this is that if you're running stuff inside the terminal. There's one program will be running inside 249 00:28:56.310 --> 00:29:00.840 William Cheng: The one program will run in the foreground and all the other ones will be running in the background. 250 00:29:01.230 --> 00:29:07.950 William Cheng: Right. Okay. So, so they have this concept, right. So this is part of the UNIX design. There's a programming background window doesn't have that concept. Okay, so for 251 00:29:08.310 --> 00:29:19.260 William Cheng: Football for Unix and Linux one program is running the foreground and everybody else running inside the background. So when you press Control C control sees only deliver to the to the process running in the foreground. 252 00:29:20.640 --> 00:29:24.840 Chandrasekar Balachandran: Okay, so all the other your processor run in the background. They don't see the control C. 253 00:29:25.380 --> 00:29:26.070 Chandrasekar Balachandran: So is that, but 254 00:29:28.110 --> 00:29:34.470 William Cheng: What so so if you're running multiple terminals. Right. Okay. Only one of them is the current terminal right that's the one that is 255 00:29:34.920 --> 00:29:39.240 William Cheng: All the window right so this way, it makes it very, very clear who should receive the control see 256 00:29:39.810 --> 00:29:48.720 Chandrasekar Balachandran: I see. So when I select my particular term that means that that's the current context. And then when I hit the interrupt that particular thing which is in current context is the one that's receiving the interrupt. 257 00:29:49.200 --> 00:29:56.130 William Cheng: Right, right. So, so for for system like, you know, Linux, right when they designed the operating system when they designed the graphical user interface. 258 00:29:56.370 --> 00:30:03.840 William Cheng: They have to take all these things into account. So this way you can he can clearly identify who's going to receive the control, see, I see. Okay. 259 00:30:04.800 --> 00:30:13.020 Chandrasekar Balachandran: And the, the other follow up question that I had is, if in the situation where actually forth between two processes and the parent process. 260 00:30:13.530 --> 00:30:23.040 Chandrasekar Balachandran: Actually crashed. Does that mean that the child process will stop automatically or on the on the interrupt basis or if the if the parents context actually ends. 261 00:30:23.730 --> 00:30:36.750 Chandrasekar Balachandran: Does that mean that the child processes automatically end. I mean, I know that's in the case of threaten based on implementation, but does one process actually depend on the parents existence to go and create or does it become like a, like an orphan. 262 00:30:37.200 --> 00:30:48.570 William Cheng: Process. So, so once you create a child process, the child process is sort of an independent process. Okay, so, so they all run in parallel depend on how many CPU. Have they all run independently. 263 00:30:49.230 --> 00:30:58.020 William Cheng: So when you say you know the parent process crash. Right. So what does that mean, right, when the parent process crash. That means the operating system has killed the parent process right 264 00:30:58.170 --> 00:31:07.050 William Cheng: Now the operating system is always in control. Right. So when the parent process crash the organism will say, oh, now the parent is dead, and now the child process become an orphan. 265 00:31:07.560 --> 00:31:18.990 William Cheng: Then depends on what kind of opening system you're running, they will need to deal with the case where there's an orphan okay for the Unix operating system what they have to do is that they have to go to the orphan and then find the orphan, a new parent 266 00:31:20.220 --> 00:31:20.880 Chandrasekar Balachandran: Oh, I see. 267 00:31:21.240 --> 00:31:28.350 William Cheng: Okay, so, so, but but that's the Unix and Linux the Unix and Linux design. Okay, other audiences and they may decide to do something else. 268 00:31:29.010 --> 00:31:39.510 Chandrasekar Balachandran: I see. And so in that case are the parent and child processes sharing any kind of information, the same stack. So what I mean by that is if I felt a particular stage. 269 00:31:40.350 --> 00:31:48.330 Chandrasekar Balachandran: Does the code for the within the stack that the higher levels of the address space is the I mean like similar on slide number 41 270 00:31:48.660 --> 00:31:53.250 Chandrasekar Balachandran: Um, does the does the things share similar stack space. 271 00:31:53.730 --> 00:31:57.060 William Cheng: Well, so the parent and the child browser. They have a separate address space. 272 00:31:57.450 --> 00:32:06.000 William Cheng: So, you know, I was very specific when I talk about when you perform a full call for cooperation, the child process gets a copy of the parents address space, right. 273 00:32:06.510 --> 00:32:13.950 William Cheng: So just like making a copy of a piece of paper. When you get a copy. You can do anything you do with a copy. And that will not affect the original. Okay. 274 00:32:14.520 --> 00:32:21.930 William Cheng: So so so therefore they don't share anything. As it turns out, they the only thing that it will share is that they will share the extended address space. 275 00:32:22.530 --> 00:32:33.000 William Cheng: Okay, we haven't really talked about what that is. We said a while you know the process has address space. So now you know that they are not sharing the address space. Okay. But as it turns out they're sharing the extended address space. 276 00:32:33.540 --> 00:32:36.780 William Cheng: So there's still something that are being shared between that so 277 00:32:36.840 --> 00:32:53.370 Chandrasekar Balachandran: What I'm struggling to understand isn't like on slide number 42 which would illustrated showing the fork and then the different processes over there. So, at that stage when you're creating two copies. Does the code, the code segment also get copied over 278 00:32:54.990 --> 00:32:55.320 Chandrasekar Balachandran: Because 279 00:32:55.410 --> 00:32:57.750 Chandrasekar Balachandran: There's yeah so right. Sorry. 280 00:32:58.260 --> 00:33:03.120 William Cheng: So, so the code over here, they're exactly the same, right, so you can sort of, you know, conceptually, will you make a phone. 281 00:33:03.420 --> 00:33:10.530 William Cheng: Call you get a copy of the form or you get a copy of the code segment, but that's a really waste of time. Right. You don't because they are exactly the same thing. 282 00:33:10.800 --> 00:33:20.370 William Cheng: And how sad man they are read only. So you can't really modify them. So typically what the system will do that they will do some kind of an optimization to make it faster when you try to copy the address space. 283 00:33:20.550 --> 00:33:20.850 Chandrasekar Balachandran: Okay. 284 00:33:21.090 --> 00:33:28.350 William Cheng: So therefore, yeah. The tech segment the CO segment. You don't have to make a copy because if you can share a read only copy that's as good as making a copy 285 00:33:28.830 --> 00:33:35.700 William Cheng: Right, so we're sort of going to talk about the abstraction, the abstraction is that you make a copy. But in the actual implementation is that you can just share it. 286 00:33:36.450 --> 00:33:37.110 Chandrasekar Balachandran: I see. Okay. 287 00:33:37.140 --> 00:33:39.960 William Cheng: Okay, so all these memories segments, you can do the same trick. 288 00:33:40.830 --> 00:33:41.820 Chandrasekar Balachandran: I see. Okay. 289 00:33:43.200 --> 00:33:52.200 William Cheng: I mean, this is what I said it's the same tree. The tree is going to get a little complicated so we so we actually, we're going to talk about what to do with them when we go all the way to like around chapter seven. 290 00:33:53.400 --> 00:33:54.330 Chandrasekar Balachandran: Okay, okay. 291 00:33:54.840 --> 00:33:56.790 William Cheng: So right now, right now we just think about making a copy 292 00:33:57.210 --> 00:33:58.620 Chandrasekar Balachandran: OK. OK, so just considered us 293 00:33:58.650 --> 00:34:01.740 William Cheng: Right. So, and again, you only copy the address space. 294 00:34:02.250 --> 00:34:12.600 William Cheng: We haven't show you what the extended either spaces where the basic idea is that the extended address space is going to be going through your file systems. Okay, so things inside of our system, you don't make a copy of them. 295 00:34:13.290 --> 00:34:15.000 William Cheng: gave us the address space, you make a copy 296 00:34:16.020 --> 00:34:20.340 Chandrasekar Balachandran: Okay. Okay, cool. I think that's about all the questions. Thank you so much. Okay. 297 00:34:20.550 --> 00:34:20.880 William Cheng: Thank you. 298 00:34:25.440 --> 00:34:26.160 Tanvi Kasture: Good morning. Good. 299 00:34:26.850 --> 00:34:27.240 Morning. 300 00:34:28.380 --> 00:34:36.000 Tanvi Kasture: I wanted to ask you about like is the program counter and instruction pointer are the these are the same things. 301 00:34:38.520 --> 00:34:41.130 William Cheng: So let me go to those slides here. 302 00:34:44.280 --> 00:34:48.480 William Cheng: Okay, so sorry. What was the question again at the program counter is the instruction pointer. 303 00:34:48.900 --> 00:34:54.660 William Cheng: Yeah, before that the instruction pointer over here. They point to, you know, the tech segment. 304 00:34:56.340 --> 00:34:57.810 William Cheng: What was your question again, sorry. 305 00:34:58.680 --> 00:35:03.990 Tanvi Kasture: Is the program counter and instruction pointer. Are these are the same things. 306 00:35:04.140 --> 00:35:15.930 William Cheng: Yes program countering central point of their the same thing. Yeah, different CPU, they call them different names, but the idea is the same. You need to somewhere to point to your tech segment so that you know what instruction, you're executing 307 00:35:17.820 --> 00:35:25.860 Tanvi Kasture: So I did not get understand the SP how the ESPN. The ABP works. Can you elaborate more on this. 308 00:35:26.280 --> 00:35:33.870 William Cheng: Yeah so ESP right this picture over here ESP taught you know a point to the top of the stack and remember that inside your stack near the stack frames. 309 00:35:34.170 --> 00:35:41.040 William Cheng: At the bottom is the main function, right, so this is this document belong to me. Okay, so that's not the code for me. But it's the stack frame for me. 310 00:35:41.280 --> 00:35:49.980 William Cheng: Inside the stack brand new store function argument that local variables okay means I'm gonna call function called X right so here's the Sacramento X X called why why called z. 311 00:35:50.190 --> 00:36:00.780 William Cheng: And right now, you're in the middle of function z. So the top stack room over here belong to function z. And again, instead of stack rain we store the function argument and local variable for function z. 312 00:36:01.170 --> 00:36:06.270 William Cheng: Okay what if Z need to make another function call. Right, so see this ad is going to call a function called W. 313 00:36:06.540 --> 00:36:13.350 William Cheng: In order for you to build a stack frame for W. You need to know where the current top of the stack. So this way you can build a stack right on top of it. 314 00:36:13.680 --> 00:36:21.240 William Cheng: Yeah, so that's why we need ESP to point to the top of the stack on top of the stack. So this way when you make a function call. You can build another stack frame. 315 00:36:21.780 --> 00:36:32.010 William Cheng: Yeah. The next slide over here is what EDP right EDP point of the middle of the stack rank. So this way you can access function argument and local variable relative to where he BP is pointing 316 00:36:32.610 --> 00:36:44.070 William Cheng: Okay, so in chapter three, we're going to sort of see exactly how this is done. Right. So right now we just sort of give you a high level picture to say ABP point to the middle of the tasks that for a while ESP pointed at the top of the stack. Right. 317 00:36:45.660 --> 00:36:51.750 Tanvi Kasture: Okay, ATP. ATP actually points to the various the local 318 00:36:52.980 --> 00:37:03.030 Tanvi Kasture: Variables and the function or do mentor and vote if the higher level function wants to call the lower level function, then how will it work. 319 00:37:03.480 --> 00:37:07.380 William Cheng: Yeah, so when you need to call another function, you always build a stack frame on top of it. 320 00:37:07.860 --> 00:37:08.220 Tanvi Kasture: Okay. 321 00:37:08.580 --> 00:37:20.040 William Cheng: Okay, so, so, I mean. So again, if you think about your, your code your code is sitting inside the tech segment over here, all over the place. Right. So there's really no higher level functional lower level function. I mean, when you write your program. It looks 322 00:37:20.310 --> 00:37:29.010 William Cheng: That way, but in reality it's a flat space. Okay, so you can call any function that you want. Okay, thank you. Okay. You're welcome. 323 00:37:37.020 --> 00:37:40.410 William Cheng: If you have a question, feel free to unmute your microphone and ask the question. 324 00:37:53.220 --> 00:37:54.600 William Cheng: Nobody has any more questions. 325 00:38:09.000 --> 00:38:15.810 William Cheng: Alright, I'm going to sort of take a look at the chat area. So maybe somebody is asking any questions there. As it turns on. Nobody's asking question there. 326 00:38:17.070 --> 00:38:26.130 William Cheng: So if nobody's asking any question, then I will terminate the live lecture right now. So, last call. If you have any question you know 327 00:38:27.150 --> 00:38:30.060 William Cheng: You can, you know, write something. Yes. Any question. 328 00:38:40.590 --> 00:38:57.270 William Cheng: Okay, if there's no question. I'm going to terminate. You know this video and then I will post it, you know, in the class web page. So if you have any more questions, feel free to send me email. Okay, otherwise I will see you. Until next time. Okay. All right. Bye.