Email or username:

Password:

Forgot your password?
Top-level
Drew DeVault

Async I/O is also often used for I/O multiplexing, which is when you have more than one source of I/O and want to have several I/O operations in flight at the same time, but otherwise you don't need the CPU while they work. You don't need async I/O for that, you need poll(2).

6 comments
Drew DeVault

And finally, if your program is I/O bound then you don't need threads.

Mikołaj Hołysz

@drewdevault I'd disagree here, a program can be I/O bound (let's say small requests to a slow service / on a slow network), but you might still want to e.g. accept input from the user while the slow service is doing its thing. If you don't have threads or async i/o, you're waiting on the network while the user thinks your program is broken.

Drew DeVault

@miki bzzzzzt, wrong

You want I/O multiplexing to address this case, which is not the same thing as async I/O.

_L4NyrlfL1I0

@drewdevault how exactly does async I/O differ from I/O multiplexing in your understanding?

I/O multiplexing is IIUC having a single thread of execution and using poll() / epoll() / select() / ... to periodically check which I/O is ready and then handling that (either directly or via callbacks). Most nontrivial programs that do that do it via callbacks and an event loop.

1/2

@miki

Rich Felker

@drewdevault You don't need them for parallelism to utilize resources well. You might still want/need them for a simpler programming model.

Go Up