Re: Non-blocking I/O

Zachary Amsden (amsdenz@aavid.com)
Tue, 21 Jul 1998 09:34:54 -0400


-----Original Message-----
From: Richard Gooch <Richard.Gooch@atnf.CSIRO.AU>
To: Chris Wedgwood <chris@cybernet.co.nz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>; sroy@wipinfo.soft.net <sroy@wipinfo.soft.net>; linux-kernel@vger.rutgers.edu <linux-kernel@vger.rutgers.edu>
Date: Tuesday, July 21, 1998 5:17 AM
Subject: Re: Non-blocking I/O

>> O_NONBLOCK is meaningless for read/write because its not clear what
>should
>> happen and how you would make the code work in practice. I think
>O_NONBLOCK
>> for read/write is asking fro trouble, unless I can think of a sane
>SAPI for
>> it.
>
>How's that? We have non-blocking I/O for reading and writing right now
>for ttys, pipes and sockets. The interface is simple and well
>understood. How is extending that to regular files a conceptual
>problem?

Should be very easy indeed, just check for O_NONBLOCK when you are going to block a process waiting for disk I/O, and return the number of bytes read so far. Of course, all I/Os that you return EWOULDBLOCK on need to be scheduled so that at some point in the future they won't block. If the buffer cache locks in pages with pending transfer to userspace, I suppose it would also be wise to check for misbehaving processes chewing up a whole bunch of buffer cache with nonblocking I/O requests that they never service with some kind of timeout mechanism on the locks.

Zachary Amsden
amsden@andrew.cmu.edu

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html