Home >>Operating System Tutorial >Operating System File System

Operating System File System

Operating System File System

File

A file is a set of similar information named for secondary storage, such as magnetic disks, magnetic tapes, and optical disks. A file is usually a sequence of bits, bytes, lines, or records whose importance is determined by the creator and user of the data.

File Structure

A File Structure should be in compliance with the appropriate format that the OS can understand.

  • A file has a certain structure which is specified by its type.
  • A text file is a series of lines arranged into characters.
  • A source file is a list of functions and procedures.
  • An object file is a series of bytes which are arranged into blocks which the machine can understand.
  • As different file structures are specified by the operating system, it also contains the code to support that file structure. Unix, MS-DOS supports minimum file structure number.

File Type

File type refers to the operating system's ability to differentiate various file types such as source files from text files and binary files etc. Many operating systems support a great many file types. MS-DOS and UNIX operating systems have the following file types –

Ordinary files

  • These are the files which contain information about the users.
  • They may have text, databases, or programme executable.
  • Various operations may be applied to such files as adding , modifying, deleting or even removing the entire file.

Directory files

These files contain a list of the names of the files and other information relating to them.

Special files

  • Often these files are called device files.
  • These files are physical devices such as disks, terminals , printers, networks, tape drives, etc.

These files are of two types −

  • character Special files − details are treated by character, as in the case of terminals or printers.
  • block Special files − data are handled in blocks, as in the case of disk and tapes.

File Access Mechanisms

Data access mechanism applies to how one can access a data 's records. There are several ways to access data −

  • Access Sequential
  • Direct / Access random
  • Indexed control sequentially

Sequential access

A sequential access is that in which the records in some sequence are accessed, i.e. the information in the file is handled in order, one record after another. The most primitive method of access is this. Example: Typically the compilers access files in this fashion.

Direct/Random access

  • Organization offers random access paper, accessing information directly.
  • record has its own address on the document, by means of which it can be accessed directly for reading or writing.
  • The records need not be inside the file in some sequence, and they need not be on the storage medium in adjacent areas.

Indexed sequential access

  • This mechanism builds on sequential access basis.
  • For each file an index is generated which contains pointers to different blocks.
  • Index is sequentially searched, and its pointer is used to directly access the file.

Space Allocation

Files are used by operating system to allocate disc spaces. Operating systems implement three principal methods of allocating disk space to files.

  • Contiguous Allocation
  • Linked Allocation
  • Indexed Allocation

Contiguous Allocation

  • file occupies a contiguous disk address space.
  • The address assigned to the disk is in linear order.
  • Simple to implement.
  • External fragmentation is a significant problem with this kind of technique of allocation.

Linked Allocation

  • file carries a list of links to blocks of disk.
  • Directory includes link / pointer to a file's first row.
  • No External fragmentation
  • Effectively used in access file sequentials.
  • Inefficient in case of file with direct access.

Indexed Allocation

  • Provides solutions to contiguous and related allocation problems.
  • An index block that has all the pointers to the files is generated.
  • Each file has its own index block which stores the disk space addresses that the file occupies.
  • Directory includes the index block addresses of files

No Sidebar ads