Hello friends I am beginning this discussion by assuming that you knows the few basics of OS (UNIX) especially about kernel and its working, so let’s start the discussion.
The kernel identifies particular inodes by their file system and inode number and allocated incore inode at the request of higher level algorithms, here higher level algorithms means we are considering some abstract levels so higher level means above the current abstract level.
The OS kernel uses algorithm iget to allocate incore copy of inode, the kernel maps device number and inode number into hash queue and searches the queue for the inode if it cannot find the inode, it allocates one from the free list and locks it. After that kernel prepares, read the disk copy of the newly accessed inode into incore copy. It already knows the inode number and logical device and computes the logical disk block that contains the inode according to how many disk inodes that fits into the disk block. The computation is followed by the following formula:
Block_number = ((inode_number – 1 ) / number_of_inodes_per_block) + start_block_of_inode_list
Where division operation returns the integer part of the quotient
Algorithm iget
    INPUT:     file system inode number.
OUTPUT:     locked inode.
    while( not done)
            if(inode in inode cache )
                       if( inode locked )           
                           Sleep( event inode becomes unlocked );
                        if (inode on inode free list)
                            remove from free list;
              return inode;
              if (no inodes on free list )
              return error;
           remove the new inode from free list;
           reset inode number and file system number ;
           remove inode from the old hash queue, place on new one;
           read inode from disk (algorithm bread);
           initialize inode;
           return (inode);

Related Post

Leave a Reply