Re: aio_read/write versus O_NONBLOCK



On Thu, 15 May 2008 21:56:27 GMT Scott Lurndal <scott@xxxxxxxxxxxxx> wrote:
| phil-news-nospam@xxxxxxxx writes:
|>On Thu, 15 May 2008 18:55:43 GMT Scott Lurndal <scott@xxxxxxxxxxxxx> wrote:
|>| phil-news-nospam@xxxxxxxx writes:
|>|>On Wed, 14 May 2008 00:13:59 -0400 Barry Margolin <barmar@xxxxxxxxxxxx> wrote:
|>|>| In article
|>|>| <fe463120-697d-4100-9ca8-b74083491664@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
|>|>| RazvanD <razvand@xxxxxxxxx> wrote:
|>|>|
|>|>|> Hi!
|>|>|>
|>|>|> Could someone point me to some articles or give me some hints on the
|>|>|> advantages/disadvantages of asynchronous operations on files (aio_read/
|>|>|> aio_read) versus normal operations (read/write) used with O_NONBLOCK
|>|>|> when opening a file.
|>|>|>
|>|>|> aio_read/aio_write are indeed more flexible. But, at least on Linux/
|>|>|> glibc, they are implemented using POSIX threads. Wouldn't a carefully
|>|>|> designed program using O_NONBLOCK for files best a program using
|>|>|> aio_read/aio_write? I think my question should be: are asynchronous I/
|>|>|> O operations only more flexible or are they also faster?
|>|>|
|>|>| I'm not certain about Linux, but on many systems O_NONBLOCK has no
|>|>| effect on ordinary file streams.
|>|>
|>|>It has not had any effect on ordinary file streams in Linux in the programs
|>|>I have written that tried it (a couple of them).
|>|>
|>|
|>| It's pretty much of a waste of time. O_NONBLOCK doesn't make any sense
|>| for file descriptors that can't block on a read (i.e. disk-based files).
|>
|>Could you explain why you believe that to be the case?
|>
|
| It's simple. The disk is always there, so a read must always complete
| in a bounded time. O_NONBLOCK was added to Unix to handle cases where
| a blocking read can be unbounded (serial ports, parallel ports, network
| ports).

But a bounded time is not zero time. There are things that can be done
while a disk is being read.


| Just like poll(2) and select(2) always rval a disk-based file descriptor
| as readable and writeable, if they support disk-based files at all.

It would be useful if one could do poll(2) or select(2) on descriptors open
to 2 or more disk devices or files when doing multiple I/O. A typical example
is copying a file from one disk to another. Using poll(2) would allow which
descriptor really becomes ready next to be handled right then. Both I/O
operations could be easily overlapped. Of course it is the case that the OS
does buffer the writes. In some cases (Linux) it still does this badly so
it is still useful to do things like O_SYNC or O_DIRECT. Otherwise I have
to do things like multiprocessing with pipes or multithreading. It just gets
messy to do what would otherwise be simple if O_NONBLOCK worked on files and
disk devices.

--
|WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance |
| by the abuse department, bellsouth.net is blocked. If you post to |
| Usenet from these places, find another Usenet provider ASAP. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
.



Relevant Pages

  • Re: aio_read/write versus O_NONBLOCK
    ... | for file descriptors that can't block on a read. ... in a bounded time. ... a blocking read can be unbounded (serial ports, parallel ports, network ... Just like polland selectalways rval a disk-based file descriptor ...
    (comp.unix.programmer)
  • FreeBSD 6.2-STABLE crash under moderate disk activity
    ... FreeBSD 6.2-RELEASE and 6.2-STABLE both repeatedly crash with moderate disk activity. ... The problem occurs with two different disk drives, ... <ACPI PCI bus> on pcib0 ... 2 ports with 2 removable, ...
    (freebsd-stable)
  • Re: CLARITY re: challenge: end of life for 6.2 is prematurewithbuggy 6.3
    ... If the new php package works fine on your build box, ... For most of the ports this works, ... just my effort with debian is much smaller than fbsd ports. ... I've had a disk down of course it was in gmirror and the situation ...
    (freebsd-stable)
  • Re: Upgrade from 32-bit to AMD-64?
    ... and you have to immediately recompile ALL of your installed ports (and ... temporary amd64 root filesystem, installworld/kernel into that, boot ... Load a new hard disk with the 64-bit code. ...
    (freebsd-stable)
  • 2TB+ on ahd broken? (6.2-R)
    ... 29320 card, and when I export a 7TB disk to the card, and kept getting ... 7TB or 2.3TB disk, ahd failed w/ the messages at the end of the ... <ACPI PCI bus> on pcib0 ... 2 ports with 2 removable, ...
    (freebsd-stable)