Sequential File Allocation

A) SEQUENTIAL:

AIM:

To write a C program for implementing sequential file allocation method

DESCRIPTION:

The most common form of file structure is the sequential file in this type of file, a fixed format is used for records. All records (of the system) have the same length, consisting of the same number of fixed length fields in a particular order because the length and position of each field are known, only the values of fields need to be stored, the field name and length for each field are attributes of the file structure.

ALGORITHM:

  1. Start the program.
  2. Get the number of files.
  3. Get the memory requirement of each file.
  4. Allocate the required locations to each in sequential order a). Randomly select a location from available location s1= random(100);
    if(b[s1].flag==0)
    {
      for(j=s1;j<s1+p[i];j++)
      {
        if((b[j].flag)==0)count++;
      }
      if(count==p[i]) break;
    }
  5. Allocate and set flag=1 to the allocated locations.
    for(s=s1;s<(s1+p[i]);s++)
    {
      k[i][j]=s; j=j+1;
      b[s].bno=s;
      b[s].flag=1;
    }
  6. Print the results file no, length, Blocks allocated.
  7. Stop the program