Docsity

Operating System - File Access Methods - Notes, Study notes of Operating Systems

Partial preview of the text

Download Operating System - File Access Methods - Notes and more Study notes Operating Systems in PDF only on Docsity!

File Access Methods

1

Sequential file

  • (^) A sequential file is one in which records can only be accessed sequentially, one after another, from beginning to end.

While Not EOF { Read the next record Process the record }

Program 13.1 Program 13.1 Processing records in a sequential fileProcessing records in a sequential file

  • (^) The following code show how to access all records in a sequential file.

Updating sequential files

  • (^) Files involved in updating:
    • (^) New master file
      • (^) The file contains the most current data
    • (^) Old master file
      • (^) The permanent file that should be updates
    • (^) Transaction file
      • (^) It contains changes to be applied to the master file
    • (^) Error report file
      • (^) The error report contains a listing of all errors discovered during the update process and is presented to the user for corrective action

Indexed files

  • (^) An indexed file is made of a data file, which is a sequential file, and an index.

Mapping in an indexed

file

Logical view of an indexed file

Mapping in a hashed file

Hashed files

  • (^) In an indexed file, the index maps the key to the address.
  • (^) An hashed file uses a function to accomplish this mapping.
  • (^) The hashed file eliminates the need for an extra file (index).

Hashing method

  • (^) For key-address mapping, you can select one of several hashing methods: - (^) Direct method ( - (^) key=address - (^) Modulo division method - (^) address = key % list_size + - (^) Digit extraction method - (^) Other methods

Modulo division method

Digit extraction method

  • (^) For example: 1 25870  1 58 1 22801  1 28 1 21267  1 12 … 1 23413  1 34

Text versus binary

  • (^) A text file is a file of characters.
    • (^) It can not contain integers, floating-point numbers, or any other data structures in their internal memory format.
    • (^) Example: the data sent to the printer
  • (^) A binary file is a collection of data stored in the internal format of computer.

File Allocation Techniques

17

Contiguous Allocation

  • (^) Single set of blocks is allocated to a file at the time of creation
  • (^) Only a single entry in the file allocation table
    • (^) Starting block and length of the file
  • (^) External fragmentation will occur
    • (^) Need to perform compaction 19

20 Leads to external fragmentation