Author: Stan Eisenstat
Subject: Re: [Cs323] global files
Date: Friday, 13 Nov 2020, 07:15:22
> Message Posted By: Unknown
>
> How does the sytem keep track of how much of the file has been read so
> far? For example, if one process reads part of the file, then the file
> would be "advanced" by the number of bytes read by the first process and a
> second process would not be able to read those. Is that kept track in the
> global file table in some sort of struct?
The following is a simplified description.
Each file descriptor is an index into a table that is
stored in the system side of a process. The entry at
that index is a pointer to an entry in a global file
table that is stored outside the process. That entry
includes the index of the next byte in the file to read
or write.
When a process calls read() (write() is similar), the
index of the next byte to read is advanced. If another
process has a file descriptor that refers to the same
entry in the global file table (e.g., as the result of
a fork()), its next read will start at the new position,
not the old one.
--Stan-
PREV
INDEX
NEXT