Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Dec 1997 20:45:09 +0100 (MET)
From:      Luigi Rizzo <luigi@labinfo.iet.unipi.it>
To:        tlambert@primenet.com (Terry Lambert)
Cc:        julian@whistle.com, hackers@FreeBSD.ORG
Subject:   Re: Why FIONREAD has no dual for write ?
Message-ID:  <199712081945.UAA29200@labinfo.iet.unipi.it>
In-Reply-To: <199712081822.LAA23908@usr01.primenet.com> from "Terry Lambert" at Dec 8, 97 06:22:14 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > We have a 20 years old interface (FIONREAD..) and I can understand that
> > at that time some needs (e.g. synchronizing streams) were simply not
> > there. Now we have new requirements and apps, and it would be appropriate
> > to work on a common interface which is as device independent as
> > possible.
> 
> IMO, the canonically "correct" thing to do would be to read and write
> using a non-blocking descriptor.  This eliminates the multiple reader/
> write buffer consumption races.

so in practice FIONREAD should not be used either... that's a
possibility.

> It's short, it's elegant, and you can still use "select()" for the
> readability/writeability to avoid turning the program into a polling
> loop.

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().

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.

	Cheers
	Luigi
-----------------------------+--------------------------------------
Luigi Rizzo                  |  Dip. di Ingegneria dell'Informazione
email: luigi@iet.unipi.it    |  Universita' di Pisa
tel: +39-50-568533           |  via Diotisalvi 2, 56126 PISA (Italy)
fax: +39-50-568522           |  http://www.iet.unipi.it/~luigi/
_____________________________|______________________________________



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