kaio
[Top] [All Lists]

Re: quick question

To: kaio@xxxxxxxxxxx
Subject: Re: quick question
From: Stephen Meyles <smeyles@xxxxxxxxxx>
Date: Thu, 15 Jun 2000 22:56:52 -0700
Cc: Pierre Phaneuf <pp@xxxxxxxxxxxxxxx>
Organization: Meyles Consulting Corporation
References: <39495BF3.B0C618C5@ludusdesign.com>
Sender: owner-kaio@xxxxxxxxxxx
Hi Pierre,

They are definitely distinct models.  All forms of the regular
read/write in Linux are synchronous in nature whereas the AIO interface
is asynchronous.  Unix Network Programming Vol 1 by Stevens presents a
decent explanation of the difference between these models although he
does not actually detail the asynchronous model.  O'Reilly's Posix 4
Programming is said to have a good intro to the asynchronous model
although I can't claim to have read it myself.

I commonly use an analogy to explain the difference between the two
models.  Imagine you need to buy some donuts from a bakery:

Synchronous model (=read/write+O_NONBLOCK)
==========================================
You phone bakery and ask if the donuts have arrived yet.  If not, you
phone again later.  You repeat this until the bakery tells you the
donuts are in.  Now that you know the donuts have arrived, you must
still go to the bakery, place your order and pay before receiving the
goods.  Note that even though you phoned earlier and were told that the
donuts were in, the bakery could sell out before you get there.

Asynchronous model (AIO)
========================
You phone the bakery, give them your credit card number and place your
order.  The bakery phones you when they have your order ready for
pickup.


As you can see, in the synchronous model, the I/O request is not
actually successfully submitted to the system until after notification
(repeated reads or a select/poll call more typically).  Also, the
information returned by calls such as select may not be accurate by the
time you actually issue the I/O request (socket closes before you can
issue a write for example).

With the asynchronous model, the I/O request is submitted once, and
notification is issued only upon completion (or failure).  With this
model you spend no time blocked in system calls.  Additionally, a proper
asynchronous I/O system can apply intelligence in servicing the
outstanding requests (merging contiguous disk requests for example). 
The cost associated with this model is complexity.  Each request must
carry its own contextual information.

Regards,

Stephen Meyles


Pierre Phaneuf wrote:
> 
> How does POSIX AIO differs from using O_NONBLOCK and the regular
> open/read/write API? Any pointers to Fine Manuals are welcome!
> 
> Please CC the answer to me, since I am not on the mailing list, thank
> you!
> 
> --
> Pierre Phaneuf
> Systems Exorcist

<Prev in Thread] Current Thread [Next in Thread>
  • quick question, Pierre Phaneuf
    • Re: quick question, Stephen Meyles <=