From owner-freebsd-questions Tue Mar 12 13:54:43 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id NAA21948 for questions-outgoing; Tue, 12 Mar 1996 13:54:43 -0800 (PST) Received: from genesis.atrad.adelaide.edu.au (genesis.atrad.adelaide.edu.au [129.127.96.120]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id NAA21939 for ; Tue, 12 Mar 1996 13:54:37 -0800 (PST) Received: from msmith@localhost by genesis.atrad.adelaide.edu.au (8.6.12/8.6.9) id IAA29184; Wed, 13 Mar 1996 08:32:48 +1030 From: Michael Smith Message-Id: <199603122202.IAA29184@genesis.atrad.adelaide.edu.au> Subject: Re: non-blocking read ? To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Date: Wed, 13 Mar 1996 08:32:48 +1030 (CST) Cc: leisner@sdsp.mc.xerox.com, msmith@atrad.adelaide.edu.au, questions@freebsd.org In-Reply-To: <199603121733.SAA20865@labinfo.iet.unipi.it> from "Luigi Rizzo" at Mar 12, 96 06:33:14 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Luigi Rizzo stands accused of saying: > > > > Luigi Rizzo stands accused of saying: > > > > is there a simple way to issue a non-blocking read to a regular file ? > > > > > > > > Ideally, I would like a > > > > > > > > nbread(handle, buf, count); > > > > > > > > which would start reading from the disk, and could then notify > > > > the completion of I/O via select(). > > > > > > Use async I/O and handle SIGIO like everybody else 8) > > > > Reads to regular files are non-blocking by default -- you either read > > the next block or return EOF...note, they may take "time", but it isn't > > 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. Grr, read my original response. I wasn't being stupid. Look at fcntl, in particular O_ASYNC, and signal in regards to SIGIO. (This is how Harvest works). You'll need to do a bit more work internally to track your I/O, but it may be worth the effort. > Luigi -- ]] Mike Smith, Software Engineer msmith@atrad.adelaide.edu.au [[ ]] Genesis Software genesis@atrad.adelaide.edu.au [[ ]] High-speed data acquisition and (GSM mobile) 0411-222-496 [[ ]] realtime instrument control (ph/fax) +61-8-267-3039 [[ ]] Collector of old Unix hardware. "Where are your PEZ?" The Tick [[