Class 11 | Concept of File Management | Operating System Notes

UNIT 5
Class 11 Operating System File Management

Concept of File Management

Original Scanned PDF – View Notes

01

File

  • A file is named collection of related information that recorded on secondary storage such as magnetic disk, magnetic tape and optional disk.
  • In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by file creator or user.
02

Attributes of File

Following are some file attributes:

1. Name

Only information which is in human readable form.

2. Identifier

File is identified by a unique tag (number) within file system.

3. Type

It is needed for system that support different types of files.

4. Location

Pointer to file location on device.

5. Size

Current size of file.

6. Protection

Controls and assigns the power of reading, writting, executing.

7. Time, Data and User Identification

This is the data for protection, security and usage monitoring.

03

Operation on File

The OS must do to perform basic file operations given below.

  1. Creating file
  2. Writing file
  3. Reading file
  4. Repositioning within a file
  5. Deleting a file
  6. Protection
  7. Truncating file

1. Creating File

Allocate space and then make an entry in the directory.

2. Write

  • Required name of file and the information to be written.
  • Search the directory to find location of file.
  • Keep a write-pointer to the location in the file.
  • Update the pointer after each write.

3. Read

  • Requires name of file and information to be read.
  • Search the directory to find location of file.
  • Keep a read-pointer to the location in the file.
  • Update the pointer after each read.

4. Repositioning Within a File

Change the value of the file-position pointer.

5. Delete

Deallocate the space and remove entry.

6. Protection

Changing access-control information such as who can read, write, execute and so on.

7. Truncate

Change the allocation space to zero and deallocate file space.

04

File Allocation

  • File allocation is the process of storing files in the disk blocks.
  • File allocation method defines how the files are stored in the disk.
  • There are three main disk space or file allocation methods.
  1. Contiguous Allocation
  2. Indexed Allocation
  3. Linked Allocation
05

1. Contiguous Allocation

  • In this scheme, each file occupies a continuous set of blocks on the disk.
  • The directory entry for a file with continuous allocation contains:
  1. Address of starting blocks.
  2. Length of allocated portion.

Example: If a file requires n blocks and block b is starting location then block assigned to the file will be:

b, b+1, b+2 ... b+n-1

Directory

FileStartLength
count02
trt143
mail73

Advantage

  • Both random and sequential access are supported.
  • Extremely fast to access.

Disadvantage

  • Suffers from both internal and external fragmentation.
  • Large size file in different to allocate.
06

2. Linked List Allocation

  • In this scheme, each file is a linked list of disk blocks which need not be contiguous.
  • Disk blocks is scattered anywhere on the disk.
  • The directory entry contains a pointer to the starting and the ending file block.
  • Each block contains pointer to the next block occupied by file.

Advantage

  1. Very flexible in terms of size.
  2. Does not suffer from external fragmentation.

Disadvantage

  • Large no of seeks are needed to access blocks causes slower access.
  • Does not support random or direct access.
  • Pointer adds extra overhead.
07

3. Indexed Allocation

  • In this allocation, a special blocks known as the index block contains the pointer to all blocks occupied by a file.
  • Each file has its own index block.
  • The ith entry in the index block contains the disk address of the ith file block.
  • The directory entry contains the address of the index block.

Advantage

  • Support direct access to the blocks occupied by file.
  • Overcomes the problem of external fragmentation.

Disadvantage

  • Pointer overload is greater.
  • For small files it is inefficient in terms of memory utilization.
Indexed allocation diagram showing disk blocks numbered zero to eleven and a directory entry for txt pointing to index block B 0 1 2 3 4 5 6 7 8 9 10 11 Directory Filename index Block txt B
Fig: Indexed allocation and directory entry

Discussion

Share a helpful question, idea, or explanation with other students.

Leave a Comment

Write a clear question, answer, or helpful explanation.
Your email will not be published.

Download Our Offline App

Study class-wise notes even when internet is not available. Get the app from Play Store.

Nepal eNotes offline app preview
Get it on Google Play