'Unix system file tables

I am confused about Unix system file tables.

  • When two or more processes open a file for reading, does the system file table create separate entries for each process or a single entry?

  • If a single entry is created for multiple processes opening the same file, will their file offsets also be the same?

  • If process 1 opens file1.txt for reading and process 2 opens the same file file1.txt for writing, will the system file table create one or two entries?



Solution 1:[1]

The same file may be opened simultaneously by several processes, and even by the same process (resulting in several file descriptors for the same file) depending on the file organization and filesystem. Operations on the descriptors like moving the file pointer, or closing it are independent (they do not affect other descriptors for the same file). Operations of the file (like a write) can be seen by operations on the other descriptors (a posterior read can read the written data).

This is from the open(System call) wiki page

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kalyanaraman Santhanam