[go: up one dir, main page]

0% found this document useful (0 votes)
1K views3 pages

Implementation of Sequential File Allocation Technique

The document describes an algorithm to implement sequential file allocation technique. It takes as input the number of files and memory requirement of each file. It allocates memory sequentially by selecting random free locations and marking them as allocated by setting a flag. It prints the file number and allocated block. The user can enter more files. The program implements this algorithm to sequentially allocate files to disk blocks.

Uploaded by

dillip murali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views3 pages

Implementation of Sequential File Allocation Technique

The document describes an algorithm to implement sequential file allocation technique. It takes as input the number of files and memory requirement of each file. It allocates memory sequentially by selecting random free locations and marking them as allocated by setting a flag. It prints the file number and allocated block. The user can enter more files. The program implements this algorithm to sequentially allocate files to disk blocks.

Uploaded by

dillip murali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

EX NO : 5A IT18412 OPERATING SYSTEM CONCEPTS LABORATORY DATE:08/09/21

IMPLEMENTATION OF SEQUENTIAL FILE ALLOCATION TECHNIQUE

AIM: To implement the sequential file allocation technique.

ALGORITHM:
STEP 1: Start the program.

STEP 2: Gather information about the number of files.

STEP 3: Gather the memory requirement of each file.

STEP 4: Allocate the memory to the file in a sequential manner.

STEP 5: Select any random location from the available location.

STEP 6: Check if the location that is selected is free or not.

STEP 7: If the location is allocated set the flag = 1.

STEP 8: Print the file number, length, and the block allocated.

STEP 9: Gather information if more files have to be stored.

STEP 10: If yes, then go to STEP 2.

STEP 11: If no, Stop the program.

PROGRAM:
#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

void recurse(int files[]){

int flag = 0, startBlock, len, j, k, ch;

printf("Enter the starting block and the length of the files: ");

REG NO: 190801001 PAGE NO:


EX NO : 5A IT18412 OPERATING SYSTEM CONCEPTS LABORATORY DATE:08/09/21

scanf("%d%d", &startBlock, &len);

for (j=startBlock; j<(startBlock+len); j++){

if (files[j] == 0)

flag++;

if(len == flag){

for (int k=startBlock; k<(startBlock+len); k++){

if (files[k] == 0){

files[k] = 1;

printf("%d\t%d\n", k, files[k]);

if (k != (startBlock+len-1))

printf("The file is allocated to the disk\n");

else

printf("The file is not allocated to the disk\n");

printf("Do you want to enter more files?\n");

printf("Press 1 for YES, 0 for NO: ");

scanf("%d", &ch);

if (ch == 1)

recurse(files);

else

exit(0);

return;

REG NO: 190801001 PAGE NO:


EX NO : 5A IT18412 OPERATING SYSTEM CONCEPTS LABORATORY DATE:08/09/21

int main()

int files[50];

for(int i=0;i<50;i++)

files[i]=0;

printf("Files Allocated are :\n");

recurse(files);

getch();

return 0;

SAMPLE INPUT/OUTPUT:
Files Allocated are :

Enter the starting block and the length of the files: 2 5

2 1

3 1

4 1

5 1

6 1

The file is allocated to the disk

Do you want to enter more files?

Press 1 for YES, 0 for NO: 0

RESULT:
Thus implementation the sequential file allocation technique is implemented successfully.

REG NO: 190801001 PAGE NO:

You might also like