From owner-freebsd-hackers Mon Dec 8 12:46:28 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id MAA09298 for hackers-outgoing; Mon, 8 Dec 1997 12:46:28 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id MAA09280 for ; Mon, 8 Dec 1997 12:46:18 -0800 (PST) (envelope-from luigi@labinfo.iet.unipi.it) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id UAA29200; Mon, 8 Dec 1997 20:45:09 +0100 From: Luigi Rizzo Message-Id: <199712081945.UAA29200@labinfo.iet.unipi.it> Subject: Re: Why FIONREAD has no dual for write ? To: tlambert@primenet.com (Terry Lambert) Date: Mon, 8 Dec 1997 20:45:09 +0100 (MET) Cc: julian@whistle.com, hackers@FreeBSD.ORG In-Reply-To: <199712081822.LAA23908@usr01.primenet.com> from "Terry Lambert" at Dec 8, 97 06:22:14 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > 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/ _____________________________|______________________________________