The Advantages & Disadvantages of Unix File Descriptors

File descriptors are the numbers Unix systems assign to files -- one number for each file. This includes not only stored data, but also your devices: Unix treats your screen, your printer and your keyboard as files with their own descriptors. The descriptors give your operating system a tool for recovering data and deciding where to send it.

  1. Unix Files

    • Unix uses a three-table structure to manage open files. At the base of the structure lies the v-node table, which maintains files on the operating system. Above that lies a table containing all currently open files. At the top lies the process table, which contains the file descriptors identifying any open files. When a computer user needs to access a particular file, the file descriptor retrieves the contents or carries out operations on the file, such as reading, writing or saving.

    Descriptor Advantages

    • Using descriptors make it easy to redirect the input or output from an operation: As Unix treats your monitor as a file, you can send output that would normally show up on-screen to some other destination. If you get lots of unwanted and unhelpful error messages during an operation, for example, change the file descriptor attached to the error-alert process to change where the computer sends them. You can redirect error messages to a file folder, or make them disappear completely.

    Descriptor Drawbacks

    • One potential drawback to using descriptors is that two processes can use a descriptor to access a file simultaneously. That can result in each process making different, contradictory changes, or one process undoing the changes made by the other. The same problems can develop if a single process uses the same file descriptor in different operations. Unix has several methods for getting around this problem by making the process atomic -- structuring the commands so that the multiple uses of the descriptor become a single fluid operation.

    Considerations

    • As part of the data storage and retrieval system, file descriptors in Unix and other operating systems face common challenges. Most computers hold many small files and a handful of large ones: When using descriptors, data recovery has to recover small files without wasting processing power, but it must also access large files efficiently. Descriptors can identify the location and size of a file in detail, or reference just a single block in a series of linked file. Different systems take different approaches to descriptors.

Related Searches:

References

Resources

Comments

Related Ads

Featured