Date: 10 Sep 1999 10:47:16 +0300 From: Ville-Pertti Keinonen <will@iki.fi> To: Luigi Rizzo <luigi@labinfo.iet.unipi.it> Cc: current@freebsd.org Subject: Re: An FS question perhaps... non blocking I/O. Message-ID: <86wvtzgqd6.fsf@not.demophon.com> In-Reply-To: Luigi Rizzo's message of "9 Sep 1999 20:06:50 %2B0300" References: <199909091418.QAA05520@labinfo.iet.unipi.it.newsgate.clinet.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
Luigi Rizzo <luigi@labinfo.iet.unipi.it> writes: > Is there any way to guarantee (more or less strictly, see below) > that when i issue a read() on a file (a real file coming from a > UFS i mean) such read will not block because data from the disk is > not in memory yet, yet avoid that i end up in a busy loop. There is no way to guarantee that a read will not block on disk I/O. The same applies to writes. The read/write calls should never return EAGAIN for local files, even if they are set for non-blocking I/O. This actually makes sense. Given virtual memory, you also don't know if your call to read or the memory you're copying to is actually in memory, it might block to page something in, which is also disk I/O and is comparable to the I/O for the actual file. So even if non-blocking would "work" on local files (how could it, meaningfully?), it would be a hint at best. > Any suggestion ? Would async I/O help in a case like this, considering > the possible overhead for handling signals when a transfer is > complete ? Yes, aio is probably the best alternative. It is quite expensive, though. Another alternative is to use multiple processes, but it also has considerable overhead. FreeBSD and typical Unix-like systems in general aren't perfect. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86wvtzgqd6.fsf>