page cache , process map issues
Tolga Evren
tolgae at paro.com.tr
Thu Sep 22 08:09:50 UTC 2005
Hi Gurus ,
I need to understand the interaction between the page cache (which is
used for file systemn data cache) , and virtual memory map of a process
which uses data from the cache.
Where does the pages which are read from the disk is mapped inside a
process?
Imagine a simple c program:
char *buf;
buf = (char *)malloc(1000);
This buf is allocated inside the heap , or in detail it is first
reserved (in swap file) ,and on demand , it is allocated (inside the
phy.ram)
Then imagine that the code has the following line:
*buf = 65 ;
So i modifed the contents the buffer.
As far as i know , if the pages which are modified like this , needs to
be written to the swap disk in order to be reused again .
So if these pages pageout by the os , they are written to the swap
file.
Now consider that ,i start to read data files by using read ,or
readv or pread system calls. ( readv and pread are the io calls which
oracle or other database systems uses on unix)
fdes=open("/data/spss/x1.dat",O_RDONLY);
while (fdes)
{
printf("%d\n",read(fdes, buf,sz));
}
I wonder how things happen now.
How the data blocks which are cached inside the page cache mapped to the
process?
If the file is read first time by this process , the file must be read
from the disk. Then the blocks are cached inside the page cache. The
page cache has no backing storage inside the swap file ,
but instead it is directly mapped from the data file itself.
(Is this correct?)
When my process reads data from the disk , then does the page that is
inside the page cache copied into the process map ? Or is it shared and
no copy takes place?
Kind Regards,
tolga
More information about the redhat-list
mailing list