 Hello everyone. I, Mrs. Komal Rahul Pradeshi, working as an assistant professor in Department of Computer Science and Engineering of Valjan Institute of Technology, Solapur, going to deliver a lecture on allocation of disk blocks using ALOC algorithm and other file types used in Unix operating system. The learning outcome of this session are, at the end of this session, student will be able to demonstrate the algorithm for allocation of disk blocks. Student will be able to define other file types in Unix operating system. Let us see allocation of disk blocks. Whenever process wish to write some contents into the file, kernel allocates disk blocks to the process. These disk blocks are present on disk and these free disk blocks are allocated to the process one at a time. So, whenever process wish to write content to the file, the disk blocks are allocated by kernel to the process. Here the file system superblock contains an array used to cache the number of free disk blocks. As free disk blocks should be allocated to the process, it is necessary to keep track of number of free disk blocks in the system and this is given by superblock. There is one utility program called as MKFS which is also called as MEC file system. It maintains free disk blocks in linked list manner where each node of the linked list is nothing but a data block and each data block contains array of free disk block and one entry from that array points to the next data block which again contains array of free disk blocks. So, as shown here this is the linked list of free disk blocks where each block contains an array of free disk blocks and each entry in this array points to the next data block. Let us see example of this. Now consider this is a superblock list which contains total 4 data blocks. Now as I said here this is data block 1 that data block 1 contains an array which contains number of free disk blocks. One entry from that array points to the next data block which again contains free disk blocks. So, in this way the free disk blocks are arranged in array along with linked list. One entry from that array points to the next disk block. So, this is what the structure of free disk block present in the superblock list. All these free disk blocks are maintained by superblock. Now let us see how these free disk blocks are allocated to the process when process wish to write some content to the file. This is done by using ALOCK algorithm. So, input to this ALOCK algorithm is file system number. This algorithm is used to allocate the free disk block to the process whenever process wish to write content to the file. So, initially that process check whether superblock is locked. If superblock is not locked means it is not used by any other process then what it will do? It will remove the block from the free block list whatever array we seen right now one of the block from that array is removed. Then if it is the last block of that array, if it is the last block from that free list then lock the superblock because if that superblock array is empty then we need to lock that superblock and we have to read the just taken from we have to read the block which is taken from the free list. Then copy that block number in block into the superblock and release the block buffer using the buffer release algorithm and unlock the superblock and wake up all the processes which are go to sleep because superblock is locked. This is done whenever we have last free disk block present in that array. We need to refill the superblock but if it is not last free block in that array then just get the buffer using gate block algorithm for that disk block okay and zero the content of the buffer means take the buffer and write that content of the buffer to the disk block and then zero the content means remove the content from that buffer and write that content into the disk block and allocate that buffer to the newly assigned free disk block. Then decrement the total count of the free blocks then mark the superblock is modified. Superblock is modified because the free disk block is now allocated to the process it is removed from free list okay and return that buffer to the process and then stop. If superblock is locked initially then that process goes to sleep for the event that superblock should become free and process will enter into the loop and this process will continue and that process will wake up whenever that block buffer is removed it is released by using the buffer release algorithm. So this is what about the alloc algorithm allocation of the disk block. Now let us see example of the same. Now this is the initial superblock list now as we can see here there are n number of data blocks here I have shown only two here this is the first data block which contains an array of free disk blocks and one of the entry from that array point to the next free disk block numbers okay. So whenever process wish to access the number free disk block okay then that first disk blocks is allocated then whenever again process wish to write the content to the file the next disk block is allocated each disk block is allocated one at a time so like that one by one the disk blocks are allocated to the process. Now the last disk block that is 109 is there in that superblock list so it is now the time to fill that superblock from the next array. So here that 109 is allocated to the process and again the new superblock list will be from the next link list node that is 211. So here this is the new superblock list which is filled and to fill that superblock superblock has been locked and again whenever process wish to write some content to the file one after another all these free disk blocks are allocated to the process whenever it reach to last free disk block again it is filled by the next array and so on. So this is what about the allocation of the disk block. Now as the disk blocks are allocated the blocks can also be free. So consider that this is what your original configuration of the superblock list in the first list there are only one free list free disk block present and other are free space this array contains no more free disk blocks it contains only one and in this case suppose process free a block number 949 then that 949 is easily placed into the superblock because it contains free space for that disk block so it is placed into the superblock. Now just think and write that what will happen if process free a block and superblock list is full just write down your answer let us see the answer what we said that superblock list is full and process free the disk block then that newly freed block here it becomes a link block okay now consider that this is your superblock list which two data blocks here these are the array of that data blocks and at that time the process free the disk block 226 okay then what kernel will do kernel write the superblock list into the block and write that block to the disk means all this all this superblock free disk blocks are returned to this disk block so all these are returned to the disk block 226 and that 226 is placed in as a data block and this 226 is a single it is the only member of that list so it is the link so this 226 is the next link node for the link list and it this will be the next configuration of the superblock so this becomes this is the only one node into the into this block okay which points to the next array so this is what about a lock and free algorithm of the disk blocks okay now there are other file types present in unix there are two types one is pipes and second is special file pipes pipes are also called as first in first out this differs from the regular file because data is transient data transient means once data is read it cannot be read again data is read in order in pipes so data in pipe is stored in the same way as it is stored in a regular file so this is what about pipe next is the next special files are block device special files and character device special files both are devices so file inode do not reference any data in this case so inode has two numbers okay as everything is created as a file in unix operating system these devices are also created as a file so inode of these files has two numbers one is major device number and another is minor device number major device number indicates device type search as whether it is terminal or disk and minor device number indicates unit number of the device and using major and minor number it is easy to identify which type of device is this so this is all about the other file types and allocation and deallocation of disk block of the process so these are the references thank you