Starting from:

$30

UCS1411-Lab 11 File Allocation Techniques Solved

AIM:

 To develop a C program to implement the various file allocation techniques.

 Algorithm: 

1.  Get Main memory size and block size as input. 

2.  Create a Main memory with ‘n’ number of blocks of equal size. 

3.  Main memory is maintained as Linked List with structure containing block id, Free /   Filename,  Link  to  next  Memory  block  ,  Link  to  Next File  block  (only  for  Linked Allocation),  File  block  table(  integer  array  to  hold  block  numbers  only  for  Indexed Allocation) 

4.  Get the number of files and their size as input. 

5.  Calculate the no. of blocks needed for each file.

6.  Select the Allocation Algorithm. 

– For every algorithm display Directory information and File information. 

7.  For Contiguous Allocation  - For each file do the following

i.         Generate a random number between 1 to ‘n’

ii.       Check  for  continuous  number  of  needed  file  free  blocks  starting  from  that  random block no.  iii. If  free  then  allot  that  file  in  those  continuous  blocks  and  update  the  directory structure. 

iv.     else repeat step 1

v.       If no continuous blocks are free then ‘no enough memory error’  

vi.     The  Directory  Structure  should  contain  Filename,  Starting  Block,  length  (no.  of blocks)

8.  For Linked Allocation- For each file do the following 

i.            Generate a random number between 1 to ‘n’ blocks. 

ii.          Check that block is free or not. 

iii.        If free then allot it for file. Repeat step 1 to 3 for the needed number of blocks for file and     create     linked     list     in     Main     memory     using     the     field     “Link     to  Next File block”.  iv.          Update  the  Directory  entry  which  contains  Filename,  Start  block  number,  Ending Block Number. 

v. Display  the  file  blocks  starting  from  start  block  number  in  Directory  upto  ending block  number  by  traversing  the  Main  memory  Linked  list  using  the  field  “Link  to  Next File block”. 

20.For Indexed Allocation - For each file do the following

i.            Generate a random number between 1 to ‘n’ blocks for index block.

ii.          Check if it is free else repeat index block selection 

iii.        Generate  needed  number  of  free  blocks  in  random  order  for  the  file  and  store  those block numbers in index block as array in File block table array.  iv. Display the Directory structure which contains the filename and index blocknumber. Display the File Details by showing the index block number’s File Block Table.

SAMPLE INPUT & OUTPUT:

 

Main Memory size: 500 

Size of each block in the disk: 10 KB 

Number of files to be allocated: 5

Name of the File1: ****

Size of the file1: ****   

 •     •

 

FILE ALLOCATION TECHNIQUES     

1.  Contiguous

2.  Linked 

3.  Indexed 

 

Choose the Allocation scheme: 1

 

CONTIGUOUS ALLOCATION 

Directory                     

 File Name    Start    length                      

    *****        ***      ***                     

    *****        ***      ***                 

        •

        •                         

        •                    

     *****        ***      ***

Choose the Allocation scheme: 2    

 

LINKED ALLOCATION

 

Directory                     

 File Name    Start    End                     

    *****        ***      ***                     

    *****        ***      ***                 

        •

        •                         

        •                    

     *****        ***      ***

 

Individual File listing  

 

 File name   Data-block 1    Data-block j     Data-block k Data-block l Data-block final

 

 

Choose the Allocation scheme: 3   

 

INDEXED ALLOCATION

 

Directory                     

 File Name    Indexed Block                     

    *****         ***                          

    *****         ***                   

        •

        •                         

        •                    

     *****         ***      

 

Display the Index table for all the files in the following manner 

File Name      Block Indexed 

***                Data-block 1                      Data-block j                    

Data-block k                     

Data-block l

Data-block final 



•  

More products