From owner-freebsd-questions Tue Mar 12 10:13:48 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id KAA02670 for questions-outgoing; Tue, 12 Mar 1996 10:13:48 -0800 (PST) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id KAA02638 for ; Tue, 12 Mar 1996 10:13:10 -0800 (PST) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id TAA20924; Tue, 12 Mar 1996 19:06:55 +0100 From: Luigi Rizzo Message-Id: <199603121806.TAA20924@labinfo.iet.unipi.it> Subject: Re: non-blocking read ? To: leisner@sdsp.mc.xerox.com (Marty Leisner) Date: Tue, 12 Mar 1996 19:06:55 +0100 (MET) Cc: msmith@atrad.adelaide.edu.au, questions@freebsd.org In-Reply-To: <9603121743.AA08403@gnu.mc.xerox.com> from "Marty Leisner" at Mar 12, 96 09:43:09 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > >That's my problem... some programs (noticeably the "harvest" cache) > >work as a single-threaded process which serves concurrent > >requests by trying to avoid blocking calls. It appears to do a nice > >job, but for some things (say reads/seeks etc. from disk) it appears > >that there is no way to avoid delays -- at least to my knowledge. > > How long a "delay" are you having? It's "just" a design problem. If one tries to avoid blocking operations then it would be a shame to be forced to used them. [with current disks, a read issued right after an lseek might get a delay in the 10..100ms range; something that you want to avoid if you have something else to do. Forking a process to absorb the delay might help but is expensive] Someone suggested doing async IO and handling SIGIO (I suppose this refers to doing i=O_NONBLOCK; fcntl(handle, F_SETFL, &i) But I have a doubt: if, afterwards, you do lseek(handle, ...) result=read(handle, buf, size); The lseek might be non blocking -- no problem with that. The read is non-blocking because of the previous call to fcntl(). But how much data will be available when I get the SIGIO (or select will return that I/O is possible) ? The amount I requested (assuming it is available), or the system idea of a block, or what ? Thanks 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/ ====================================================================