I guess it depends on what you mean by "aware".
Insofar as the read()
s system call is a request to the kernel to copy the contents of a file starting at the present position to the program's designated memory buffer, read()
on a regular file will accomplish this task the same way whether or not there is concurrently a memory mapping of the file. There is no "awareness".
Now, it the file is both mmap()
ed and read()
, there may well be a performance optimization to be achieved. For example, if the file is read()
first, then the sections of the file that have been read are probably already in the page cache and subsequently accessing the memory mapping will not have to access them again from disk. Or conversely, if there is a memory mapping that has already been paged in, a subsequent read()
will not have to go to disk again. So in that sense you might, in some sense, consider the mmap()
and read()
"aware" of each other.