Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Dec 1997 19:45:05 -0500
From:      Bakul Shah <bakul@torrentnet.com>
To:        Luigi Rizzo <luigi@labinfo.iet.unipi.it>
Cc:        hackers@freebsd.org
Subject:   Re: Why FIONREAD has no dual for write ? 
Message-ID:  <199712090045.TAA06826@chai.torrentnet.com>
In-Reply-To: Your message of "Mon, 08 Dec 1997 20:45:09 %2B0100." <199712081945.UAA29200@labinfo.iet.unipi.it> 

next in thread | previous in thread | raw e-mail | index | archive | help
> I agree with the above, except that it does not work in all situations.
> E.g. I am not sure but does select() guarantee that you don't
> end up writing/reading one byte at a time ? I know in practice things
> are different, but there is no standard behaviour I think, so the risk
> is still there. In the audio driver I had to modify the behaviour of
> select() (block size) using a separate ioctl().

Perhaps one solution is to add an ioctl to set high/low
watermarks on a device and add new event bits POLLIN_WM and
POLLLOUT_WM for the poll() syscall.

In pollfd->events you set these bits instead of (or in
addition to) POLLIN/POLLOUT.  On return the corresponding bit
in pollfd->revents is set only if there are _greater than low
watermark_ bytes on input and _less than high watermark_
bytes on output.  This guarantees that you can transfer some
minimum number of bytes on read/write (provided you use the
O_EXCL mode).

This is a more general solution that allows finer control
over when to schedule IO and is useful in all sorts of
situations.

> Plus there are apps which want only to check the status of the queue in
> a descriptor without actually doing the I/O, for whatever reason they
> like.

This can be handled by POLL{IN,OUT}_WM.

Comments?

-- bakul



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712090045.TAA06826>