WEBVTT 1 00:00:01.170 --> 00:00:12.420 William Cheng: Okay, this is the third part of lecture 12 so we just finished the virtual file system. So now we're going to look at the actual file system and also we just finished. 2 00:00:13.410 --> 00:00:22.830 William Cheng: You know, the sort of the midterm exam coverage. So, part three today. This is all posts muttering material. Okay. Chapter 3 00:00:23.520 --> 00:00:31.770 William Cheng: Six is covering the final exam. Yeah. Alright, so we're going to see the actual file system as it turns out that the actual process them is actually pretty simple. 4 00:00:32.430 --> 00:00:36.540 William Cheng: It's kind of surprisingly simple so we're going to sort of take a look at what it takes to implement the actual file system. 5 00:00:37.290 --> 00:00:45.630 William Cheng: Then, so again, the, the, the idea here is that you want to build the data structure on the disk. And then we're going to sort of show you what the data structure on that this look like 6 00:00:45.900 --> 00:00:51.750 William Cheng: And then you can sort of imagine what kind of code that you have to write inside your system to access data structure on the desk guy. 7 00:00:52.200 --> 00:01:03.300 William Cheng: So hopefully this will also make it very clear, you know, the way the access data on that, this depends on what the data on the desk look like so. So, you know, so we know what the actual file system look like 8 00:01:04.680 --> 00:01:14.070 William Cheng: Alright, so the requirement for the actual file system is that, you know, once you start date on the DIS you don't forget it. I. So next time you can turn off the petroleum machine. 9 00:01:14.400 --> 00:01:23.910 William Cheng: And next time when you put your machine, you will find the data on to this. So, therefore, we need to, you know, sort of figure out how to lay out data on the desk. So later on we can go and retrieve the data. 10 00:01:24.510 --> 00:01:31.290 William Cheng: And also, you know, we need to survive software crashes, right, because you're operating system. My crash for no good reason. 11 00:01:31.830 --> 00:01:38.460 William Cheng: So in that case, you know, next time when you put the system. You want to make sure that the data, is data is still on the desk. Okay, so you guys are pretty lucky. 12 00:01:39.060 --> 00:01:46.740 William Cheng: Just like you know 15 years ago. Whenever you lose power or something like that, you know, when we reboot the machine. 13 00:01:47.190 --> 00:01:50.430 William Cheng: We have to worry that we might have. We might have lost the entire disk. 14 00:01:50.760 --> 00:01:56.760 William Cheng: Okay, so, so it gets in the good old Windows system every time, will you, you know, where you lose power next time when you reboot. 15 00:01:56.970 --> 00:02:05.700 William Cheng: In the beginning, what you will see a thing that's spinning as as checking. Just checking this and then it wasn't a while you're gonna say they cannot find some important file and then it will refuse to go to the operating system. 16 00:02:06.150 --> 00:02:11.610 William Cheng: Okay, so in that case, what do you do, but hopefully you have backup because if you don't have backup, you're going to be really chocolate big trouble. 17 00:02:11.820 --> 00:02:20.070 William Cheng: Yeah, so even today system when you're running Ubuntu 16 point or for the virtual machine. After that, the virtual machine once in a while, at the entire virtual machine will refuse to boot. 18 00:02:20.610 --> 00:02:29.190 William Cheng: Okay, so, you know, we don't know exactly why that be that way, whether it will be the case. And that's why it's very, very important for all your work to have backups. 19 00:02:29.640 --> 00:02:36.600 William Cheng: Because in case the virtual machine doesn't boo. All you have to do the install a new virtual machine and then go to a backup get all your files and everything will be okay. 20 00:02:36.960 --> 00:02:40.800 William Cheng: Okay, so they will be a mistake to assume that nothing ever crashed. 21 00:02:41.310 --> 00:02:50.760 William Cheng: Now, so they don't know. We also want to sort of talk about what are the crash recovery technique that we have in today's operating system. So in this case, you know, so if something crash. 22 00:02:51.090 --> 00:02:54.360 William Cheng: Will be able to sort of recover from the crashes. Yeah. 23 00:02:55.020 --> 00:03:07.290 William Cheng: And also the fastest them since the file system are built on the disk devices and the disc are really, really slow devices. So a lot of the stuff that we're going to sort of talk about is to make the dis appear to be fast, right, we're gonna talk about all kinds of trick. 24 00:03:07.890 --> 00:03:09.360 William Cheng: To make things look fast. Okay. 25 00:03:10.920 --> 00:03:22.650 William Cheng: All right, so everything. Use the desk or even the operating system use the desk. So, you know, we talked about on you know the inside of houses. Then there's regular file. There's directory. There's device. 26 00:03:23.550 --> 00:03:26.310 William Cheng: So as it turns out, directory is kind of special because when you 27 00:03:26.820 --> 00:03:35.610 William Cheng: Know when you need to find a file when you perform path name resolution and we mentioned before, it's a very, very long process. So, therefore, you know, we need to speed things up. 28 00:03:36.060 --> 00:03:41.640 William Cheng: So if you're actually, we need to worry about a couple of things over here. One thing is that is that is that the lookout needs to be fast. 29 00:03:42.120 --> 00:03:55.200 William Cheng: So for example, if you try to find a file to execute and the program is going to be your slash users slash Ben right users slash Ben. That's what you all programs are on Linux slash users slash Ben. There's actually over 2000 files. 30 00:03:56.070 --> 00:04:02.520 William Cheng: Okay. So last time we talked about path and resolution. If you do this one entry at a time is going to be really, really slow. So, so, of course, 31 00:04:02.880 --> 00:04:08.610 William Cheng: It's important to try to make things faster and also we like to be able to name our file. Anything that we want. 32 00:04:08.970 --> 00:04:19.320 William Cheng: Okay. I mean, these days, when you have a desktop, you know, operating system. The way you try to create a file you want the fans to be what don't you want the file name to be 1000 characters long. You can actually do that. 33 00:04:19.770 --> 00:04:26.880 William Cheng: Okay, in the good old days, they're actually limited to a very, very small number of characters against are very convenient. So later on, we also going to go, go, go. 34 00:04:27.780 --> 00:04:34.590 William Cheng: Go Go going to see some tricks, how to create a file system so you can you can actually name your component name as long as you want. Yeah. 35 00:04:35.850 --> 00:04:45.960 William Cheng: Alright, so the file access over here. Again, there are two kinds of access. One is sequential access. The other one is random acts. So again, sequential access is that you open we write rewrite or something like I sequential access 36 00:04:46.440 --> 00:04:56.340 William Cheng: Random Access over here. What is random access right we mentioned before, one of the way. Random acts as far as how you open a file and then you use LLC to position your cursor position to anywhere you want. 37 00:04:56.670 --> 00:04:58.620 William Cheng: Okay, but generally would only do that. 38 00:04:59.100 --> 00:05:08.550 William Cheng: Okay. So, therefore, if you want to upload a file system to make it fast. And you can you can you can either optimize it for sequential access or optimizing for random access, what would you do 39 00:05:08.910 --> 00:05:17.190 William Cheng: Well, in that case, you will always optimize your file system for sequential access because that's more that's more common. Right. So this way, on the average, your file system will perform faster. 40 00:05:17.640 --> 00:05:26.670 William Cheng: Okay, so it's very difficult to try to put these on these analysis them to be fast in all aspects, right. So, because there's no free lunch. There's always a trade off. Okay. 41 00:05:28.560 --> 00:05:39.750 William Cheng: All right, so what we're going to do is that we're going to look at an example of what a file system look like. And we'll look at a very simple file system. And that's the system file system. Right. So again, for our Colonel assignment that part of its implemented for you. 42 00:05:40.170 --> 00:05:53.040 William Cheng: It's all included in a instead of library file, but now we're going to look at exactly what system father look like. So this way you know even though you don't have to code for this isn't follow us there. You can sort of imagine what it's doing now. 43 00:05:55.080 --> 00:06:00.000 William Cheng: Alright, so this is our system is a very simple boss file system. It's kind of slow 44 00:06:00.330 --> 00:06:08.730 William Cheng: But you know when you run your kernel seven, you're going to see that it's actually OK. It doesn't really not that bad. Right. It just compare against today's standard is kind of slow. Okay, they're also not 45 00:06:09.480 --> 00:06:14.820 William Cheng: Terribly tolerant to crashes. If you have an operating system crash. And if you're using the system file system. 46 00:06:15.600 --> 00:06:23.730 William Cheng: You know so. So again, why would you organism crash. Well, yeah. Because there's a bug inside the colonel next time when you reboot the system. This is the bathhouses and might not be usable. 47 00:06:24.480 --> 00:06:37.800 William Cheng: OK. So again, this is really not a you know who's really not good. And that's why when we run out hurdles. I mean, we always have to run. We need x right we need x minus x. So you always start with a fresh desk. Okay, so this way you know 48 00:06:39.060 --> 00:06:45.630 William Cheng: Even if you mess up the system PA system it's okay because every time when we restart. We're going to start with a fresh this all the data will be there now. 49 00:06:46.560 --> 00:06:50.970 William Cheng: This is about them. As it turns out, it's reasonable the space efficient. So what does it mean to 50 00:06:51.630 --> 00:06:56.490 William Cheng: Be space efficient right so you have a big disk over here, you try to build a file system hierarchy, you know, 51 00:06:56.910 --> 00:07:06.210 William Cheng: Instead of it. So again, the forces of hierarchy. It's a data structure on the desk in order for you to build a data structure on to this, you need to have ways to find, you know, to, to, to actually find stuff inside 52 00:07:07.440 --> 00:07:11.850 William Cheng: You need to be able to find stuff on the desk. Okay, so in order for you to find that you need. 53 00:07:12.120 --> 00:07:20.730 William Cheng: You need other data structure to help you to find things. So if the other data structure actually going to take up the entire this space. Well, then in that case it's not very efficient in space. 54 00:07:21.360 --> 00:07:30.660 William Cheng: Okay. So over here, what talk about what's talking about over here is that for system file, file system, all the extra data structure and then let you get to the actual data. They actually they don't take up too much space. 55 00:07:31.350 --> 00:07:38.460 William Cheng: Okay. So in this case, you know, most of the the you know that this capacity is going to be used to store the the data for the files. 56 00:07:38.640 --> 00:07:45.060 William Cheng: Okay and and and and also that's that's really what you want because you don't really want to waste a lot of state by keeping track of stuff. 57 00:07:45.570 --> 00:07:54.060 William Cheng: Okay. But remember, there's a space time trade off. If you want your file access on this to be fast, you're willing to spend more space. Right. So in this case you will kind of be more more 58 00:07:54.330 --> 00:07:57.870 William Cheng: More wasteful and again this is typical you know space time trade off. 59 00:07:58.560 --> 00:08:04.020 William Cheng: Yeah, there's a comment here that for this is above us is then there was an old file system. So, therefore, there's no compression 60 00:08:04.320 --> 00:08:13.440 William Cheng: And again, if you're compressing your data is going to require it to to spend time doing it, you will be able to save space where you're going to end up spending time. Okay. Okay, good. I'll trade off. 61 00:08:14.490 --> 00:08:22.560 William Cheng: The, the thing that we need to worry about is that what kind of on this data shirt, do you have in order for you to build a file system. So that's what we're going to talk about how do you represent a file. 62 00:08:22.890 --> 00:08:25.920 William Cheng: Okay, so again we are recording the actual process then 63 00:08:26.430 --> 00:08:35.370 William Cheng: The, the job of the actual file system is are you going to start with. I know number and then you need to change them into a disk address. So we go to this address, you're going to find a data structure for the file. 64 00:08:35.850 --> 00:08:46.590 William Cheng: Okay, so we're going to talk about what that data structure actually look like that. So again, the number is just an array index. Right. So the red index is going to give you an I know and the I know is they own disk representation, you know, 65 00:08:47.940 --> 00:08:54.360 William Cheng: Have a file right again. This could be a regular file could be a directory alphabet device file could be a symbolic link. Okay. All right. 66 00:08:55.080 --> 00:09:02.400 William Cheng: Over here, there's no comment over years and you also need to worry about how to manage free space, right. So if you think about you have a disk over here you have the file system hierarchy. 67 00:09:02.670 --> 00:09:10.890 William Cheng: On the file system hierarchy. It doesn't take up the entire entire disk. Okay, so what is the rest of the this the rest of the disk over here, they are free space. 68 00:09:11.400 --> 00:09:19.980 William Cheng: Okay, so part of the job, but you'll forces them is not only to manage the file system hierarchy. It also need to manage all the free space that are available on the desk. 69 00:09:20.340 --> 00:09:24.690 William Cheng: Okay, so therefore you again. So this is kind of like keep memory management right in the beginning. 70 00:09:24.900 --> 00:09:36.030 William Cheng: The entire. This is just free space. And once you create files in it. And now we have part of the faster you know part of the desk over here is going to be allocated to the file system hierarchy and the rest of us are still free. 71 00:09:36.690 --> 00:09:41.910 William Cheng: So therefore, the job of the file system to keep track of also all the all the free space. 72 00:09:42.450 --> 00:09:48.840 William Cheng: Guys are going to sort of take a look at the data structure for this free space and also the the data structure for the file system hierarchy. Yeah. 73 00:09:49.530 --> 00:10:02.580 William Cheng: I mean, actually, we already know what the, the, the data structure for the help file system hierarchy, right, we have directory instead of directly we map component into I know numbers. So in the air, all we care is our, how do you actually store the I notes. Yeah. 74 00:10:04.530 --> 00:10:14.640 William Cheng: Alright, so let's take a look at the system PA system layout. So the, so the way you lay out the desk over here is that you divided this into something called this blocks there. 75 00:10:15.120 --> 00:10:18.450 William Cheng: So what what this blocks that this blocks are actually logical unit. 76 00:10:18.960 --> 00:10:22.950 William Cheng: Okay, so they are you know so so the the fastest. I'm gonna actually randomly decide 77 00:10:23.130 --> 00:10:32.220 William Cheng: how big that this block is ok. So, for convenience. We're going to assume that every this blog is one kilobytes. Each okay so we'll get one kilobytes is 1024 bytes over here. 78 00:10:32.430 --> 00:10:38.520 William Cheng: Okay. The reason we do that is that we're going to make the math a little easier to to to to calculate. If we deal with one kilobyte block that 79 00:10:38.910 --> 00:10:42.810 William Cheng: In the good old Unix we saw in the blue block right the booth blog over here. I mean, 80 00:10:43.710 --> 00:10:51.900 William Cheng: I guess in chapter three was we saw blue block, right. So we don't really say what a block is at that point the pool blog is half a kilobytes in size. 81 00:10:52.230 --> 00:10:56.460 William Cheng: Okay, so, so again, that was that was that was sort of the first time we talked about a block. 82 00:10:56.790 --> 00:11:05.280 William Cheng: That. So again, the operating system can actually, you know, sort of decide, whatever the block sizes so they can divide the, the date the entire this into a rail blocks. 83 00:11:05.850 --> 00:11:15.930 William Cheng: Okay, so, so basically what will happen is that we can look at it this this way. Okay. The desk is simply an array of blocks. So if you need to go to any place on the desk. All you need is a block number 84 00:11:16.470 --> 00:11:21.330 William Cheng: Okay, so we're here at the block number of years 012 all the way to the end of the desk over here. 85 00:11:21.540 --> 00:11:29.250 William Cheng: As it turns out, the first two blocks are special. The first blog over here or block them a zero is no as the booth, blah. And that's the one that we saw before. In chapter three. 86 00:11:29.610 --> 00:11:42.990 William Cheng: Right, the one that has the partition table, the one that has the boot loader, all that kind of stuff, so that's that's block number zero okay block number one is known as the super blog over here. The superblock describe the rest of the file system. 87 00:11:44.010 --> 00:11:46.260 William Cheng: OK. So again, the super blog over here. It's going to be 88 00:11:47.910 --> 00:11:57.570 William Cheng: Going to sort of tell you. So what is the rest of the file system and the rest of houses and has two things. One is the file system hierarchy. If you want to get to the file system hierarchy. All you need is to know where the root. 89 00:11:58.080 --> 00:12:06.360 William Cheng: The root directory. I know is, well, why does he know the root directory. I know they then from the I wanted to fund the route you know you can find the entire file system hierarchy. 90 00:12:06.870 --> 00:12:11.820 William Cheng: OK, so the information of where the route. I know his stories that are super block. Okay. Also, 91 00:12:12.300 --> 00:12:20.340 William Cheng: The free blocks, you know, on the desk also need to be arranging some data structure. So, typically the way we sort of think about is that they're going to be arranged into a linked list. 92 00:12:20.790 --> 00:12:24.450 William Cheng: Okay, so therefore there's going to be there's going to be a list of food. Food Blog. 93 00:12:24.660 --> 00:12:36.090 William Cheng: If you so so you don't take all the free blog you you link them together into a giant legless. So in this case, if it's a single Inglis all you need to do is to point to the head of learning this and if you can get to the how you can get to the entire list. 94 00:12:37.050 --> 00:12:43.530 William Cheng: Okay, so therefore the super VA is going to contain these two important pieces of information. So you can get to the file system hierarchy. You can also get to 95 00:12:43.950 --> 00:12:48.780 William Cheng: Get to the cleaners that they also other stop inside the super blog and I will go to sort of talk about that. 96 00:12:49.590 --> 00:12:58.830 William Cheng: Now, the next part over here is know is the is the the iOS contains a list of notes. Okay, so again, I'll be here. I'm even though it's called a list, which 97 00:12:59.220 --> 00:13:08.940 William Cheng: We should also think about as an array. Right. So we are going to divide them into a read over here. Each one of them is I know this is I know number zero design on number 1234 all the way to the last. I know. 98 00:13:10.170 --> 00:13:19.980 William Cheng: Okay, so. And so in this case over here. Right. Every, every file is represented by I know every I know has an auto number and the I know number is simply the array index into the eilis 99 00:13:20.910 --> 00:13:32.340 William Cheng: Okay, so, so, so, so over here it's a little bit to see exactly what I know look like. And the last part over here is known as the data region. And so again, the data region over here divided into blocks over here. So the idea here is that 100 00:13:32.970 --> 00:13:40.740 William Cheng: You know so. So what's inside the data region. Right. So instead of data region is part of your file system hierarchy and also the rest of the data region over here belong to the free list. 101 00:13:41.640 --> 00:13:49.080 William Cheng: OK. So again, over here, you know, so, so, so if you want to build a fire file system hierarchy. We started out with. I know zero over here. I know zero is going to point to 102 00:13:49.410 --> 00:13:55.020 William Cheng: To to data block see inside the data region over here. And then, you know, inside this there but so get 103 00:13:55.470 --> 00:14:02.820 William Cheng: The route. I know it's a directory file, right. So again, if you open it up, you're going to find component name followed by I don't number. So inside a data region over here. 104 00:14:03.000 --> 00:14:14.280 William Cheng: They will be references to other two to two other I know number. And again, if you go to the other number and you need to check whether it's a directory of it's a file. If it's a directory, they will again point to the data region over here and then they will pointed 105 00:14:14.580 --> 00:14:20.250 William Cheng: Over here so you can see that this data structure going up and down like this, eventually you will find the entire file system hierarchy. 106 00:14:20.700 --> 00:14:30.240 William Cheng: Then the rest of the data region over here doesn't belong to the file system hierarchy, so therefore they belong to the freelance and then starting from the super blog. We're going to link all the blocks together over here so we can find that 107 00:14:31.410 --> 00:14:40.980 William Cheng: Alright, so that's the basic structure, you know, of the system PA system. Right. So again, this is layout. We start with the booth blah by super blah, followed by a bunch of notes and then followed by the data region. 108 00:14:41.790 --> 00:14:51.870 William Cheng: Yeah. Alright, so I sort of also sort of you some color code over here that did a regional view. I told him blue. So later on when you see a blog that's blue. So they sort of come from the data region. Yeah. 109 00:14:53.790 --> 00:15:03.630 William Cheng: Alright, so get over here. I'm going to read this to rise to the desk is simply an array of blogs, a one kilobytes yeast dry. So again, that's the abstraction and the reality we also going to implement things like that. 110 00:15:04.080 --> 00:15:12.870 William Cheng: But the block size can be anything we want. Typically the blocks that is going to be the multiple of pay, have a page size. Okay so so modern days. 111 00:15:13.320 --> 00:15:20.100 William Cheng: The page size is four kilobytes. So, therefore, you know now blocking be four kilobytes eight kilobytes 16 kilobyte 32 kilobytes. 112 00:15:20.490 --> 00:15:25.170 William Cheng: Sometimes the, you know, sort of broad can be really, really big. It could be, you know, on the order of megabytes. 113 00:15:25.530 --> 00:15:32.490 William Cheng: I mean today. You know, we have, you know, really big this so the block size get bigger, right in the good old days, the page size is actually half a kilobytes. 114 00:15:32.880 --> 00:15:44.430 William Cheng: So we're going to see the block size in the old UNIX system, you know, to be on the multiples of habit kilobytes. Right. Alright, so again the discipline is a logical units. They are usually the multiple page sizes. Yeah. 115 00:15:45.540 --> 00:15:56.370 William Cheng: Says, Okay. So the way we sort of think about it, this is the one dimensional view over here. So if you have a block numbers again. What is the block number of Brock number is the integer. How big is this integer 116 00:15:57.420 --> 00:16:03.120 William Cheng: OK. So again, you know, if every blog over here is one kilobytes over here. So if you have a one terabyte 117 00:16:03.390 --> 00:16:13.710 William Cheng: You know data over here. The how many blocks you have why, in this case, you're going to have 1 billion blocks and each block over here can be represented by integer. So in this case, again, a block number is simply a four byte number 118 00:16:15.060 --> 00:16:21.300 William Cheng: Okay, because we're going to dress up to 4 billion, you know, blocks over here. So even if it's one terabytes and they've every block is one 119 00:16:21.660 --> 00:16:33.330 William Cheng: Every block. So one kilobytes in size, you can still use for bikes to specify block numbers, right. So again, the block number is just an integer. What about I know number. I don't know. But he's also just an integer. So again, it's going to be four bytes long. Yeah. 120 00:16:35.550 --> 00:16:44.460 William Cheng: Alright. So over here I sort of tell you what the super blog is right. The superblock describe the layout of the rest of the fastest them. How do you describe the layout of the rest of the process and 121 00:16:45.150 --> 00:16:51.060 William Cheng: So one thing that you will say, you know, that you mentioned the super blog. So where does the island start 122 00:16:51.450 --> 00:17:01.920 William Cheng: There. What is the block number for the beginning is and how many blocks is as is and this will also tell you whether the data reach and starts, right. So again, all this information is going to be stored inside a super blah because, you know, if you 123 00:17:02.250 --> 00:17:05.520 William Cheng: Because you have to have that information somewhere, right. So, therefore, those things are stored inside 124 00:17:06.210 --> 00:17:18.780 William Cheng: Then it also contains the head of the look freelance. It also contain the I know number for the route. I know. Yeah, I'm typically the route. I know has I know number zero right so so again you don't really. You can also assume that that's going to be the 125 00:17:19.950 --> 00:17:25.020 William Cheng: Number for the route item. Right. The is over here as an array of index knows right so that's what that's what 126 00:17:25.320 --> 00:17:34.860 William Cheng: The term. I know it's come from. So we just have a you know a re index and that will give you the other files every one of these. I know representative file that's, again, very, very simple data structure. 127 00:17:36.240 --> 00:17:44.940 William Cheng: Whoops. So this is what I know look right. Okay, so I know every I know it's a fixed size data structure. So that's why the eilis is an array of fixed size data structure. 128 00:17:45.330 --> 00:17:54.480 William Cheng: Okay, so, so, so, so again, this is what I know my look like is the system file system. If you want to know exactly what it looks like. So again, the textbook doesn't really mention everything 129 00:17:55.020 --> 00:18:00.600 William Cheng: So if you want to see an example what it looks, it looks like a winning source code, you know, inside the system Papa system header file. 130 00:18:00.930 --> 00:18:03.150 William Cheng: That was sort of show you what's inside. I know. Yeah. 131 00:18:03.480 --> 00:18:15.450 William Cheng: Alright, the first part of the things that I know is that it sort of the first two parts over here. It's kind of a self reference it says that, you know, where's this I know which device does it sit on. And what is this the the I O number for this. I know. 132 00:18:15.870 --> 00:18:24.420 William Cheng: OK. So again, the first part over here is that device number major device number followed by minus device number, right. So again, this is the 30th is a four by number. The second one is that it's a self reference 133 00:18:24.810 --> 00:18:33.180 William Cheng: The I O number for this, I note. Okay, so this way if you pass this data structure around, you can actually look at this data, they're just like, Oh, I know. Number seven, or something like that. Now, 134 00:18:33.810 --> 00:18:40.080 William Cheng: The next one over here, again, I mentioned before, you know, Unix like to use. I don't know. For some reason they use the same word. 135 00:18:40.530 --> 00:18:47.520 William Cheng: For protection mode and also for file type. So this one is actually called mode. But again, this one is not the production mode is actually a file type 136 00:18:48.030 --> 00:18:55.320 William Cheng: There. So again, this one tells you what it this far as the regular file, it's a directory file, whether it's a symbolic link or whether it's the device. Yeah. 137 00:18:55.980 --> 00:19:01.920 William Cheng: Alright, the next one over here is the link out right again link on is a number of hard links that are pointing to this. I know. 138 00:19:02.670 --> 00:19:08.940 William Cheng: OK. So again, the link. Oh, if the link is going to zero, that means that nobody's putting this. I know. So, therefore, this I know she'll get free 139 00:19:09.540 --> 00:19:11.730 William Cheng: Now, so you should never see Link are going to zero. Yeah. 140 00:19:12.270 --> 00:19:20.700 William Cheng: The last day. The next field over here, this is the other the user ID and the group ID. Right. So again, the user ID 16 bits long, the group IDs system bizarre. So again, this is a four or five number 141 00:19:21.180 --> 00:19:27.540 William Cheng: The next number over here is going to be the file size and the file sizes for bias long. It says how many bites are in this file. 142 00:19:28.260 --> 00:19:34.080 William Cheng: Okay, so again this is so, so, so in this isn't about us is that a file size can never be bigger than four gigabytes. 143 00:19:34.560 --> 00:19:43.620 William Cheng: Okay, because we only use four bytes over here to store the file size modern offices and modern process them, you know, the file can be much bigger. Right. You know, if you have a video files can be really big. 144 00:19:44.160 --> 00:19:47.910 William Cheng: So in that case, you know, we're going to need more data to actually store the file size. Yeah. 145 00:19:48.180 --> 00:19:53.820 William Cheng: Then the last part over here. It's called the this map that this match, Joe, you were all the data is for this file. 146 00:19:54.030 --> 00:20:00.540 William Cheng: So what is the data. I mean, are these data for the file. What know right because when you open a text file we open a text about what do you see 147 00:20:00.810 --> 00:20:07.590 William Cheng: You see the text I use are you storing storing that file. Okay. So for example, if you look at my for to list out. Ah. 148 00:20:08.160 --> 00:20:16.080 William Cheng: Ok mile for to the formula that he doesn't have the device major device number. Amount of device number doesn't have the I know number, all that kind of saw 149 00:20:16.650 --> 00:20:21.090 William Cheng: My for $2. It's just a bunch of texts that that you have seen in warm up one 150 00:20:21.660 --> 00:20:32.550 William Cheng: Okay, so you were to get to the content of the file, you're going to use the map. Right. So yeah, what does a map right the map help you to find stuff. So in this case, this mobile. We're here to help you to find the content of this file. 151 00:20:33.990 --> 00:20:44.100 William Cheng: Okay, so again, please understand that the I note over here is is I did. I know actually consider a meta data for your file, it describes how to find the data for your file. 152 00:20:44.520 --> 00:20:50.670 William Cheng: Okay. So, where's your data. Right. So the data, you'll fall again, they are in the data region. The I note over here is inside the I list. 153 00:20:51.030 --> 00:21:00.270 William Cheng: Okay, so by going to the I note over here. You follow that this map that this map is going to point to the data region. So this way you can actually find find the data for your file. 154 00:21:01.650 --> 00:21:07.380 William Cheng: Okay, so, so, so, so again this is, you know, sort of one level and direction. I was going to see that it's going to be multiple level interaction. 155 00:21:08.790 --> 00:21:13.230 William Cheng: For cystic fibrosis, then that this map is simply 13 pointers. 156 00:21:13.590 --> 00:21:24.150 William Cheng: Okay, so okay here's I know at the top part over here is what we saw before we go, there's a top bar. The last part over here is 13 this pointer. So what are these pointers. Right. So this pointers are block numbers. 157 00:21:24.840 --> 00:21:35.070 William Cheng: Okay. So, therefore, this is just 13 block numbers. So that wasn't so this is why the I know is a fixed size data structure. Okay. Because at the end over here. They're just 13 integers there. 158 00:21:35.820 --> 00:21:38.790 William Cheng: Right. As it turns out, the first 10 over here are special. 159 00:21:39.510 --> 00:21:47.250 William Cheng: Well, maybe I shouldn't say it that way. The first time over here. They are direct data pointer over here. So there was sort of shows you where the data is for your file. 160 00:21:47.790 --> 00:21:58.290 William Cheng: So, for example, what you'll find is 20 bytes long okay the 20 bytes actually fits into one killer by block over here. So what we can do is I'm going to allocate one Brock over here of data once kilobytes in size. 161 00:21:58.830 --> 00:22:06.690 William Cheng: So I guess I just mentioned that you feel father's 20 bytes long. The first time he bites over here is going to contain your data right hello world or something like that guy. 162 00:22:06.840 --> 00:22:15.030 William Cheng: And then we can use the first this part over here to remember the block number for this one kilobyte this block and all the other despite all the other point over here, there will be no appointment. 163 00:22:15.240 --> 00:22:25.290 William Cheng: Right, so yeah. What is no finder, the null pointer over here, point to block number zero and we know the block number zero is the blue block it doesn't belong to the data region. So, therefore, we're going to treat it as a null pointer. 164 00:22:26.400 --> 00:22:32.760 William Cheng: Okay, the first one over here is going to contain the block number. So again, the block number is going to be a block number inside the data regions over here. 165 00:22:33.150 --> 00:22:41.100 William Cheng: So therefore can use that to store the data for the five. OK, so now I'm going to assume that the blocks that equal to one, or one kilobyte. This will make our math a little easier. 166 00:22:41.910 --> 00:22:48.600 William Cheng: Right so point zero through nine over here are direct pointer. They point directly to blogs that can also point to no 167 00:22:49.470 --> 00:23:00.510 William Cheng: There's no data point point 10 over here is the indirect pointed pointed 11 is a doubling direct point point point at 12 over here is the triple a great point. So we're going to see what they look like they're 168 00:23:01.410 --> 00:23:07.830 William Cheng: All right, so, so firstly example over here if we if our file is about 10 kilobytes in size. 169 00:23:08.310 --> 00:23:18.780 William Cheng: Guys. So in that case, when I have 10 data blocks over here. Each one of them is one kilobytes in size over here, right. So all we need to do is that we need to allocate block inside the data region over here. And then we're going to point to it. 170 00:23:19.110 --> 00:23:28.200 William Cheng: But that's okay everybody we're here, we're going to name that by the block number, guys, are they ever going to store the bottom over here inside of this map in the in the first time pointer over here. 171 00:23:28.620 --> 00:23:34.050 William Cheng: Okay, so in this case pointer 10 1112 they will point to know they will contain the value of zero. 172 00:23:34.770 --> 00:23:43.380 William Cheng: Okay. So, this way we can actually get to our data guys it again if our data is 10 gigabytes law right how do we actually retrieve our data. We go to the first 173 00:23:43.710 --> 00:23:51.690 William Cheng: You know, the, the first the first pointer over here inside of this map, and this will give us a block number then we followed the pointer over here to the data are on the desk. 174 00:23:51.900 --> 00:24:00.270 William Cheng: And here is our file or files going to start by zero here by 1234 all the way to buy one kilobytes. And then he will continue to the next block over here. 175 00:24:00.540 --> 00:24:06.270 William Cheng: Well, so therefore again in the in the data structure over here. They will, they will point to these these these this block. 176 00:24:06.480 --> 00:24:10.860 William Cheng: That this can be scattered all over the place inside the data region over here, right. 177 00:24:11.040 --> 00:24:20.550 William Cheng: But, but our logical view of the fall over here is I'm going to start with blogs zero followed by clockwise follow up block three all the way to block the and all these block or treat it as if they are continuous data. 178 00:24:21.630 --> 00:24:28.980 William Cheng: Okay, so this way when you have a RC file or something like that, you can sort of think about all these Bronco be here are concatenate it together so that they form one file. 179 00:24:30.630 --> 00:24:40.170 William Cheng: Alright. So again, if you have a father or 10 kilobytes long. The first kilobytes will be still here at the second kilobyte will still here, etc. They might be allocated all over the place inside the actual file system. 180 00:24:40.380 --> 00:24:48.540 William Cheng: But as far as your father's concerned, there are contiguous there the contiguous offset your entire file. Yeah. 181 00:24:49.920 --> 00:24:54.060 William Cheng: Alright, so, so, so, so in this case, you know, this is what a direct pointer look like they 182 00:24:54.570 --> 00:24:58.890 William Cheng: Should contain the block number that will that will go directly to to the state of blocks right 183 00:24:59.190 --> 00:25:07.440 William Cheng: What if you're fine. It's bigger than 10 kilobytes. Right. So in this case, we're going to use the next pointer over here. The next pointer is indirect pointer. So the looks like this over here. 184 00:25:07.710 --> 00:25:12.090 William Cheng: The next one, go over here is going to point to this block. Okay, so this will be your eye color. 185 00:25:12.750 --> 00:25:18.810 William Cheng: Color agree but but this also come from the blue region because all the data over here on the region. 186 00:25:19.200 --> 00:25:27.630 William Cheng: Okay, so in this case this is yeah this this problem here is also one kilobytes in size. So in this case, we can actually store 256 pointer into this as well. 187 00:25:28.020 --> 00:25:36.630 William Cheng: Yeah. So inside this this market. We are going to divide them into 256 pointer. Every one of them is going to point to, you know, the same block is the same kind of block as the first hand over here. 188 00:25:37.560 --> 00:25:48.180 William Cheng: Okay, so that's why a pointer number 10 over here. It's an indirect pointer, it points to this blog that contains 200 contains up to 256 pointer, each one of them point directly to a display. 189 00:25:49.050 --> 00:25:57.030 William Cheng: Okay, so therefore each, each one of them is one kilobytes in size. There's 256 of them in there. So this one can store 256 kilobytes of data. 190 00:25:57.240 --> 00:26:06.000 William Cheng: Plus 10 kilobytes of data right here. So if your file sizes, less than 266 kilobytes. This is all you need. And the last two pointers over here, there will point to knock 191 00:26:06.870 --> 00:26:16.860 William Cheng: Yeah. What if your phone is bigger than 250 66 kilobytes. Well, then in that case you will need the next pointer over here. The next ponder over here will be a double indirect pointer. So they 192 00:26:17.580 --> 00:26:24.750 William Cheng: will look like this. It will point to a blog over here. Again, this Brock is inside the data region and they come from the blue region over here, but like color purple. 193 00:26:25.170 --> 00:26:28.590 William Cheng: Because they are double the double indirect pointer. 194 00:26:29.010 --> 00:26:42.510 William Cheng: So therefore, this is all part of the blog like this, we're going to divide them into 256 pointer over here. Each one of them point to a green block like this. And each one of the been putting getting bra points to 256 different this box. 195 00:26:43.050 --> 00:26:50.430 William Cheng: Okay. So this guy's harmony. You know how many kilobytes are here, right. So this guy. Want to have 256 times 256 196 00:26:50.670 --> 00:27:00.510 William Cheng: That will be two to the eight times to to the A that's equal to, to, to the 62 to the CC CC 4000. So this is the 64,000 times one killer by the 64 megabytes. 197 00:27:00.870 --> 00:27:13.470 William Cheng: There. So if your file size is less than 64 megabytes plus 200 266 kilobytes, then this is all you need. And the last point over here, points to Know If Your phone is bigger than 64 megabytes plus 256 198 00:27:14.190 --> 00:27:20.490 William Cheng: Plus one is six kilobytes. And then you need the last point or the last point here is going to be a triple indirect pointer over here. So again, 199 00:27:20.670 --> 00:27:24.900 William Cheng: It's going to find your blog like this. I call it a yellow. But again, it comes from the blue region. 200 00:27:25.080 --> 00:27:32.820 William Cheng: It's going to point to 250 cents brought that look like the purple one over here. And each one of these pointer over here is going to want you 256 and the green block. 201 00:27:33.030 --> 00:27:38.730 William Cheng: Each one of the 250 grand bra is going to point to, you know, again, that the data block over here. 202 00:27:39.540 --> 00:27:49.080 William Cheng: Okay, so if you add up all the stories over here. How much do you have right so before we have we have to to the 16th, we're going to multiply by two to the eight over here is going to be two to the 24 203 00:27:49.320 --> 00:27:56.670 William Cheng: To to the 24 816 million each one of them is one kilobytes last 16 millions on one kilobyte is going to be 16 gigabyte. 204 00:27:57.600 --> 00:28:10.140 William Cheng: Okay, so in Sydney. So insistence using this particular data structure or Falcon actually get to 16 gigabyte. But, you know, for system for versus them. They actually they artificially limit it to two gigabyte. 205 00:28:11.220 --> 00:28:24.300 William Cheng: Well, so again, there's a, you know, because the file size has to fit inside for buys over here. So, the largest fast. I should only go to four gigabytes, but for some reason this isn't a file system, you know, stored as a regular integer 206 00:28:25.410 --> 00:28:30.090 William Cheng: Not a regular sign integer. So therefore, the actual file size can only go to two gigabytes. 207 00:28:30.750 --> 00:28:37.140 William Cheng: Okay, and also in the time of the system for us is that that passes them was actually designed maybe in the mid 70s. 208 00:28:37.650 --> 00:28:45.180 William Cheng: So they survive to them, you know, 80s or something like that. It's a very, very popular process them. But at that time, they say, why do you need to follow this bigger than two gigabyte. 209 00:28:45.810 --> 00:28:54.900 William Cheng: Okay, so therefore they actually artificially limited to two gigabyte right even though this data structure can store up to 16 gigabytes of data for your file. Yeah. 210 00:28:56.640 --> 00:29:02.910 William Cheng: So, so this picture over here. So please understand that the blue part over here is actually the data for your file. 211 00:29:03.150 --> 00:29:08.430 William Cheng: Okay. So yeah, if you have a text file the text file rarely gets this big right but if you have a video file. 212 00:29:08.670 --> 00:29:18.300 William Cheng: Okay, your video file that the video is stored in the blue region right here on this picture. So remember all these other parts of your also come from the blue region of the desk, but now they are used to to 213 00:29:19.110 --> 00:29:30.900 William Cheng: Know all these data box over here. What are they, therefore they are used for you to reach the blue data. OK. So the blue data is actually the data for your file all the other stuff over here. They're all consider metadata. So it was 214 00:29:31.920 --> 00:29:38.820 William Cheng: What a meta data, the meta data or the data that you use to find the actual data that you that the find the actual data that you actually need. 215 00:29:39.690 --> 00:29:42.000 William Cheng: Okay, so therefore we're going to just draw a picture like this. 216 00:29:42.750 --> 00:29:51.150 William Cheng: OK, this is the content of the file. So this is the file data and everything else that will lead you to the content out there actually a farm farm meta data. 217 00:29:51.480 --> 00:30:02.640 William Cheng: OK, so the. I know, right. The I know I should describe where your data is so this one is also known as the fall meta data. So all this stuff that are outside over here. They are all metadata that will help you to find the data file. 218 00:30:03.180 --> 00:30:16.800 William Cheng: Okay, so yeah. What is data over here. If you are a video file, then this will be a video. If you're a JPEG files and this will be an image if you're a text file. This will be, you know, I see file. This will be your source code, what if, what if you have a directory file. 219 00:30:17.940 --> 00:30:29.100 William Cheng: Okay, if you have a directory file, then this will be the content of your direct with our so again at the content or direct with our it's an array of directory entries again every entries over here is going to be the component A 220 00:30:29.280 --> 00:30:36.420 William Cheng: Follow, but I know number and then. And that's an array, right. So this array, array over here is that actually spill over all the way to all these data blocks over here. 221 00:30:38.640 --> 00:30:48.480 William Cheng: OK. So again, if this is a device far than the only two integers and this case, you only need the first blog over here. And so, so, so again, you have the blue part over here. It's going to be the content. 222 00:30:48.810 --> 00:31:01.470 William Cheng: Of your file and the file can be any kind of our can be a regular file can be a director about can be a symbolic link can also be a device. Well then, all right. Again, this, this picture is very important for you to understand what is data. And what is the metadata. 223 00:31:03.240 --> 00:31:13.260 William Cheng: Alright, so again for directory fall over here the lookup table is the file content right so until the entire blue part over here. So this is a directory. I know that everything will be here is the, you know, 224 00:31:14.640 --> 00:31:17.580 William Cheng: It's a lookup table for your directory file. Okay. 225 00:31:19.860 --> 00:31:20.280 William Cheng: Alright. 226 00:31:21.540 --> 00:31:26.970 William Cheng: So that's it. Okay, so this is what the file system hierarchy look like, or is it again. 227 00:31:27.720 --> 00:31:36.570 William Cheng: What is the process of hiring argue look like right so this show you what you know what a father look like. And the father is described by. I know. So now we know how to implement an I know 228 00:31:37.170 --> 00:31:46.290 William Cheng: Right. The I know it's going to take out. I know number. So that's another way is we thought we have all these fields, they will be to fill out, and then we need to allocate data blocks over here for the file to store the file content. 229 00:31:46.500 --> 00:31:50.430 William Cheng: And now we know what I know look like. And now you know what the file system hierarchy look like right 230 00:31:50.790 --> 00:32:00.240 William Cheng: Right, because before we sort of show you what a director, if I look like. And now this is what a regular follow clients. This is what a director Apollo glass. So if you know the location of the route. I know. 231 00:32:00.570 --> 00:32:05.280 William Cheng: Now you can, you can, starting from the route. I know you can reach every part of your custom hierarchy. 232 00:32:06.840 --> 00:32:18.420 William Cheng: Alright, so again, using the you know what we talked about in chapter one, you know, for you know for for the virtual file system view of the Father, Son, and now with the actual implementation. Now you can actually reach the entire file system hierarchy. Yeah. 233 00:32:19.920 --> 00:32:24.450 William Cheng: Alright, so the rest of the disco be here is going to be the free list right so we're gonna sort of talk about what the free list. Okay. Right. 234 00:32:24.750 --> 00:32:31.740 William Cheng: Okay, so the freelance over here. It's an organized as a linked list over here. So here's a link lists. So, so this link doesn't go to the next part of your point. 235 00:32:32.550 --> 00:32:45.150 William Cheng: So this is the boss is ma. They do this in a weird way, every linguists over here element over here. It's going to be a note inside the know there is there's 100 pointer over here. The first 99 pointers over here, point to a free block. 236 00:32:45.600 --> 00:32:50.790 William Cheng: The next point. The last point here, over here is the next pointer points to the next note on the free list. 237 00:32:52.350 --> 00:33:01.680 William Cheng: OK. So again, you're free. This is a single a linked list over here. So again, there are a bunch of notes over here right every note over here is going to be a display. It's gonna be one kilobytes in size over here. 238 00:33:01.860 --> 00:33:09.060 William Cheng: But we're only we're not using the entire line kilobytes. We're only going to use 256 point we're only going to use 100 pointer over here. So, 239 00:33:10.350 --> 00:33:18.900 William Cheng: Let's take a look at this picture over here we have one kilobytes over here. Right. Each point over here is four bytes long. So at the bottom over here. We're gonna have 400 bytes right here. 240 00:33:19.230 --> 00:33:28.830 William Cheng: Okay, so they will be used as pointers, the top bar over here is going to be unused that the first point over here and you know the first 99 partner over here. It's going to point to a free this block. 241 00:33:29.640 --> 00:33:35.730 William Cheng: Okay, the last one over here is going to point to the next note on the link list right and the next element, a little less. What does it look like 242 00:33:35.910 --> 00:33:42.690 William Cheng: It look exactly like this. The first 99 pointer over here point of free this block. And the last one over here pointing the next guy on the link list. 243 00:33:42.900 --> 00:33:47.940 William Cheng: That so you keep all the links over here and then this will this way you can link all the free blocks together. 244 00:33:48.150 --> 00:33:57.540 William Cheng: The last one over here. Well the next point of view will point to now and now you have, you know, not by traversing this list, you will be able to find all the free block on your desk. 245 00:33:59.760 --> 00:34:13.020 William Cheng: Okay. All right. So, so he had the house. So, and also, where's the link does right you have a single even this you have to be able to find the handling this as it turns out, this entire 100 pointer over here. There are part of the superblock 246 00:34:13.560 --> 00:34:22.290 William Cheng: OK, so the supervisor over here. We're gonna have 100 point over here. So the supervisor over here is going to be the head of the link there at the supermarket. Again, this is actually one kilobytes in size. 247 00:34:22.740 --> 00:34:29.790 William Cheng: Okay, but in this case we only going to store 100 partner in that and that will be the head of the feet, free less. So again, that means that the first one for the first 248 00:34:30.000 --> 00:34:43.680 William Cheng: 99 pointer what directly point to a free blog. And the last one over here appointed the next note on the free list. And again, the first 99 ponder over your point of free blah. And the last one will be appointed the next book on the free list and then again you continue on that one. 249 00:34:45.030 --> 00:34:50.940 William Cheng: All right, so, so, so good. Now I hope you're convinced starting from the superblock you can find your entire file system. 250 00:34:51.300 --> 00:35:03.660 William Cheng: Hierarchy because you know where the route. I know is there and then you can ask you to find your entire free list over here because the, the, the first note of the free list is actually stored inside this is that a super blah. Okay. 251 00:35:04.860 --> 00:35:09.480 William Cheng: All right. So yeah, I mean, that's just the Bible says them very, very simple. So let's talk 252 00:35:10.110 --> 00:35:14.790 William Cheng: sort of talk a little bit about how do you allocate block from the free less, right, wouldn't you need to allocate abroad. 253 00:35:15.210 --> 00:35:19.470 William Cheng: Okay, so if we go back to the previous pictures over here that when you try to create a file. 254 00:35:19.830 --> 00:35:30.600 William Cheng: That we use to create a file. How do you create a file, right, you need to. I know number so therefore you can allocate one. I know. Once you allocate I note over here, then we need to store data for the file. So in that case, we need that data blog over here. 255 00:35:31.410 --> 00:35:41.850 William Cheng: Okay, so in that case, again, we need to ask the other that we need to ask the file system that says, give us a free blog and then we can actually take a free blog from our free list and move it into the file system hierarchy. 256 00:35:42.630 --> 00:35:48.540 William Cheng: OK. So again, that's, that's what we need to do when we had the allocated this blah, we're going to, we're going to take this block from the free list. 257 00:35:48.810 --> 00:35:59.760 William Cheng: And move it into the file system hierarchy or I'm moving the file system hierarchy. That means that we're going to use one of these pointer over here to point to the fall. So now this this bar will belong to the file system hierarchy and no longer belong to the free less 258 00:36:00.210 --> 00:36:07.950 William Cheng: Okay, so that's what we mean by allocating a free blog. Okay, alright, so here it says, How do you allocate a free blah. Well, you go to the free list. 259 00:36:08.340 --> 00:36:17.940 William Cheng: Okay, so how do you go to the food. That's right. The head of the Phoenix rises again. The idea here is that abstractly, you have a linked list of three blocks or the head of the freelance I'll be here is inside the supervisor. 260 00:36:18.840 --> 00:36:24.060 William Cheng: Okay, so definitely this guy will go to the super bra and then we're going to check if we have any free blocks here directly 261 00:36:24.390 --> 00:36:33.030 William Cheng: Directly inside of superblock by checking the first 99 pointer over here. Okay. If one of them. One of them is actually pointing to a free blog and then that will be the blog that we allocate 262 00:36:33.330 --> 00:36:38.220 William Cheng: Okay. So in this example, all the first 99 pointer over here. They point to a free this blah. 263 00:36:38.910 --> 00:36:46.020 William Cheng: Okay. So this guy is which one we allocate well we can allocate anyone but will allocate from the first one, right. So we're going to take the first one over here and we're going to return it to 264 00:36:46.260 --> 00:36:58.200 William Cheng: Wherever the Nita. So in this case, what do we have to do all we have to do is to validate this point so that this partner point. And now, and now we can return this free blog over here by returning the block number over here, returned it into whoever that needs it. 265 00:36:59.490 --> 00:37:11.040 William Cheng: Okay so ago when you try to, I'll try to remember this information inside the inside of this map. All you need is a block number, right, so, so, so again, all you need is a four byte block number. So this for box about number. What does it come from. 266 00:37:11.340 --> 00:37:17.670 William Cheng: They come from right here, right. So, so over here. This one over here, what content abroad number you just returned to us, hey, this is the body can use 267 00:37:17.850 --> 00:37:23.820 William Cheng: Yeah, and also you remove this pointer. So now this blog is no longer in the free list. And now that belong to the hierarchy. 268 00:37:24.480 --> 00:37:37.830 William Cheng: That's okay. Very, very simple. So when you're done, it will look like this. Then this one over here will be now and then, this point is removed over here we're going to return the return this block number as a return value when you try to allocate a display. 269 00:37:39.000 --> 00:37:46.860 William Cheng: Okay, we don't have to actually relate your return this block all we needs to do is to return a block number. Okay, so in this case the block number will coming from the superblock 270 00:37:47.790 --> 00:37:50.940 William Cheng: So this guy's. Do we have to actually go to the disk to return this box number 271 00:37:51.300 --> 00:37:56.970 William Cheng: Okay. So as it turns out, the super blog over here is typically the entire superblock is cash inside the operating system memory. 272 00:37:57.120 --> 00:38:05.100 William Cheng: So, therefore, what you need to manipulate data, is that a super blah, you don't have to go to the desk and you don't want to go to the dentist, because that this is a very, very slow device. Okay. 273 00:38:05.280 --> 00:38:10.470 William Cheng: If you have to retreat. This information when it is then you have to go away for it. And that will take a very long time. So that's why 274 00:38:10.800 --> 00:38:15.390 William Cheng: You know, the first or the head of the head of the free list is cached inside of Supergirl 275 00:38:16.110 --> 00:38:21.180 William Cheng: Okay, so this way you know that you know the assets time we will be super fast because you don't have to go to the desk that 276 00:38:21.630 --> 00:38:30.270 William Cheng: All right. What if you need to ask for another block. Well, so we need as well. Another blog over here. Then again, we need to follow the point O number one over here. We're going to invalidate. This was what I will point to now. 277 00:38:30.450 --> 00:38:37.710 William Cheng: And then we're also going to return that this block number over here to whoever that needs it. So again, the conceptually over here, we move this block. 278 00:38:38.010 --> 00:38:49.350 William Cheng: We remove this block on the freelance and we move into the fastest of hierarchy guys again. Do we have to go to the desk, the answer will be no, because, you know, we hear what the other superbug over here is cached inside of our system. 279 00:38:50.100 --> 00:38:58.530 William Cheng: Yeah, so we can actually do this for 99 times. So when you try to allocate 99 point 99 blocks over here, none of the time, but we go we have to go to the desk, because they are all you know 280 00:38:58.980 --> 00:39:06.870 William Cheng: The operation is done simply using a using the superblock okay but when we tried to allocate the 100th time. What do we have to do. Yeah. 281 00:39:07.590 --> 00:39:17.130 William Cheng: Alright, so I'll be here. So let's say the audience that the first 99 point over here is going to be able to know. And now we need to allocate we need to ask for one more time and now the last one over your point to 282 00:39:17.490 --> 00:39:19.950 William Cheng: Get this one last one over here. It's going to be at this block number 283 00:39:20.310 --> 00:39:30.240 William Cheng: There but this one over here. This one will be the one that we need to allocate but if we allocate this one over here, we simply return this one to the operating system that needs it. I return it to a file. 284 00:39:30.450 --> 00:39:36.660 William Cheng: Then we're going to break are limitless right are like this look like this over here. So again, I'm going to draw my lenses again right look like this over here. 285 00:39:36.870 --> 00:39:42.300 William Cheng: This one is inside a superbug over here, right, if we simply return this blog over here. Now we're going to break the chain. 286 00:39:43.140 --> 00:39:48.030 William Cheng: Okay, in order for us to not to break the chain over here, we started on this day, what should be the final stage. 287 00:39:48.240 --> 00:39:57.270 William Cheng: Right, the final stage show me that this one, you know, this is when I get rid of this. And now this one is going to be become the head of the free less. So this needs to go into the superblock 288 00:39:59.040 --> 00:40:03.870 William Cheng: Okay, so we know the initial the initial stages, looking like this. The final stage is going to live there. So what do we do over here. 289 00:40:03.990 --> 00:40:13.410 William Cheng: We go to the desk over here. We're going to read this, this blog. We have a discipline number over here. We're going to pass it. This book number over here to the device driver without a device, you have to say, hey, go get this this block for me. 290 00:40:13.620 --> 00:40:18.360 William Cheng: And then our current authorized gonna fall asleep, and then the. Did you know that this control is going to take over. 291 00:40:18.540 --> 00:40:30.390 William Cheng: Transfer the data in detail in the operation is done. What it will do is it a wake up your kernel swear when you're Carlson, I got woken up. So now you know that this data over here is a memory. So what you will do is that you will copy this 100 pointer into the superblock 292 00:40:31.980 --> 00:40:40.620 William Cheng: Okay, so when you are you copy pointer, you're going to end up pointing to the same place. So when you finish doing that point zero, we will point to the same place as this point over here. 293 00:40:40.800 --> 00:40:53.730 William Cheng: Point A wall upon the same thing as this. So, all these will be exactly the same place. So don't look like this. Okay, all these partner will enter this one over here and now this block over here will be the one that you return and this frog is unlinked from the free list. 294 00:40:54.870 --> 00:41:00.660 William Cheng: Okay. So, okay, if we go back to the original picture over here. So again, here is our linked list for free list. I will point to the next part to the next. 295 00:41:00.900 --> 00:41:12.750 William Cheng: The last sort of reappointed and now in the beginning, over here, this is inside a super blog all the 99 percenters over here. They're all know on your last wonder is valid. So therefore, we just did over curious that we move this header, you know, the move. 296 00:41:14.400 --> 00:41:27.390 William Cheng: Move the head of the free less into the super blog over here. So the first 99 point over here, they will pointed the free this block. And the last point or via. Where does the point to it points to the next guy over here on the link list. So now our free list is intact again. 297 00:41:28.530 --> 00:41:40.530 William Cheng: Okay, so in this case this this blog. We don't need anymore. So this will be the block number that we retire as a partner 99 just like before, we simply return this book. Number two, wherever that needs it. OK, so now our free less is in a good state again. 298 00:41:42.810 --> 00:41:44.610 William Cheng: Okay, so why do we do like this. 299 00:41:45.660 --> 00:41:56.940 William Cheng: That. So when we do it like this over here. If you try to allocate 100 block the first 99 times when he should allocate a new blog. You don't have to go to the desk. And then the last one over here, we allocate the 300 00:41:57.540 --> 00:42:03.990 William Cheng: Time at that time you need to go to the desk. Okay, so this way that this will look like it's 100 time fasts. 301 00:42:04.260 --> 00:42:15.690 William Cheng: Will look like it's 100 times faster than the actual speed of the best because 90 99% of the time it will take you zero time and only one time, one other 100 times in this case you will have to go to the real desk. 302 00:42:16.710 --> 00:42:21.300 William Cheng: Okay. So, on the average, the performance of that is, is going to be look like it's 100 times faster. 303 00:42:22.470 --> 00:42:32.730 William Cheng: Okay, so that's why the free the free list or we had this weird data structure over here, I would have wanted to partner. So why don't you use 220 300 points. So again, because, you know, again, there's a space time trade off over here. 304 00:42:33.180 --> 00:42:39.150 William Cheng: So in this example for the system boss is that somehow they choose 100 point over here, one of the reason is because this is 305 00:42:39.480 --> 00:42:49.170 William Cheng: A really old file system where every Brock's is only half of kilobytes in size. Okay, so today. If you want to do similar stuff. Maybe we'll have more pointers, you know, more pointer inside a free blog. 306 00:42:50.130 --> 00:43:03.900 William Cheng: Okay. All right, so we're caught up with the same at the same place as summer 2019 so I'm going to stop right here. And next time we're going to continue with chapter six and look at, you know, look, look at the rest of the system PA system. Okay.