Summary of threading for experienced non-Python programmers?

Paul Rubin http
Sat Mar 29 10:38:34 EDT 2008


"Diez B. Roggisch" <deets at nospam.web.de> writes:
> In which sense is that different? AFAIK select lets you avoid polling
> and provides notifications (possibly with timeouts) for IO-events. So
> where exactly is the difference? I read TFA, and it does mention that
> select/poll have potential for optimization, but not something that
> disqualified them (or rather select) as being not async.

Select blocks until the data is ready, while with AIO the i/o happens
completely in the background and your process gets an interrupt when
the i/o completes.  Also, with select based i/o, usually the kernel
reads data from the external device into a system buffer, and then you
do a read system call that copies the data from the system buffer to
your buffer.  AIO can be set up so the i/o happens directly into your
buffer, avoiding the extra copying.  You can also initiate a bunch of
different i/o events with a single system call, avoiding some context
switches.

http://www.ibm.com/developerworks/linux/library/l-async/

describes select as "asynchronous, blocking" as opposed to AIO which
is asynchronous and nonblocking.  Other descriptions I've seen reserve
"asynchronous i/o" for AIO-like schemes.  It's just a terminological
thing.

The PDP-10 operating systems even let you define your own page fault
handlers, so you could do i/o with something like mmap and not get
delayed in the cases where the page you wanted wasn't in memory.  I
guess that's even more asynchronous than AIO.



More information about the Python-list mailing list