On Wed, Feb 04, 2004 at 15:20:12 -0800, Carl Spalletta wrote: > > --- Jan Hudec <bulb@ucw.cz> wrote: > > On Sun, Feb 01, 2004 at 15:52:01 -0800, Carl Spalletta wrote: > > > > In a recent O'Reilly Press book "Java NIO" by R. Hitchens... > > > > FIRST ALTERNATIVE: read() syscall > > > Nonblocking read.. > > > There is no non-blocking read from disk! > > There is only an aio_read, which is a different syscall. > > You are correct - although I am discussing how the system > uses the pagecache which is by definition from memory. To be clear, the read syscall, when operating on a filesystem file ignores O_NONBLOCK flag completely. So what you described in "Nonblocking read.." never happens in kernel. > > the mechanizm for loading pages is the > > same for read as for page-fault. > > I am not sure how a simple read() of a regular file in > a disk based filesystem can generate a page fault - the > read goes to disk to get the info to copy to the userspace > buffer, while a page_fault on an uncached page of an mmapped > file uses the readpage() method. > > Is this incorrect? Can you explain further? Read does not generate page fault. However it uses ->readpage() to populate the page cache and then copies it's contents to userspace. Direct read only happens with O_DIRECT flag (and in such case, the read must be buffer-aligned). ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/