[OT] poll() vs. AIO (was: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground)

Rich Felker dalias at aerifal.cx
Fri Aug 19 05:41:03 UTC 2011


On Fri, Aug 19, 2011 at 05:03:03AM +0200, Laurent Bercot wrote:
> > that era) did not.  (In single-CPU systems, which most DNIX boxes
> > were, LWP's are just a way to reorganize the problem and offer no
> > inherent performance or maintainability advantage over an AIO
> > approach, and might actually be a performance liability.)
> 
>  Threads are also purely a question of taste. Rich likes them. Lots
> of people like them. I don't. Alan Cox doesn't. YMMV.

For what it's worth, I *despised* threads until I got around to
implementing the pthread interfaces, which was significant in two ways
- for one thing, it became clear that the icky feel of bloat was a
consequence of NPTL/Drepper and not fundamentally necessary, but
perhaps more importantly, I was forced to really learn the API and
learn how to use it right.

One of the big reasons I now consider threads one of the best (but not
always "the best", of course) approach to non-blocking operations is
that they're the only idiom that allows one to mechanically transform
blocking code into a non-blocking form. Anything else potentially
requires major rewrites of core program logic. This matters a lot more
often than one might think, when you inherit or want to integrate
library code that was intended for sequential/standalone processing
into an interactive program or persistent server.

One of the most significant results of this observation in relation to
writing *new* code is the fact that, with threads, you can actually
use stdio FILEs for most or all of your io, even in programs dealing
with asynchronous events from many sources, reducing or eliminating
the need to roll your own buffering.

Rich


More information about the busybox mailing list