Asynchronous I/O Linux

谁说我不能喝 提交于 2019-12-06 13:01:02

问题


Need an async I/O Processing

Plan to use async I/O through aio* calls on Linux

The situation:

I have opened socket with AF_INET and SOCK_STREAM flags (TCP) Have limit high watermark for send buffers Want to write to that socket asynchronously, and when send buffer overflows, want to disconnect an socket

So, I have questions:

  1. When I made async call to aio_write on TCP socket, when I/O completion will arrives - when buffer written out into socket buffer or delivery is confirmed? How I can manage this behavior?

  2. How's best to handle this with lio_listio techniques

Regards, Andrew


回答1:


You want to avoid AIO on Linux for anything real, at least for now, From aio(7):

The current Linux POSIX AIO implementation is provided in userspace by glibc. This has a number of limitations, most notably that maintaining multiple threads to perform I/O operations is expensive and scales poorly. Work has been in progress for some time on a kernel state-machine-based implementation of asynchronous I/O (see io_submit(2), io_setup(2), io_cancel(2), io_destroy(2), io_getevents(2)), but this implementation hasn't yet matured to the point where the POSIX AIO implementation can be completely reimplemented using the kernel system calls.

Instead, look into non-blocking IO with select(2)/poll(2)/epoll(7).



来源:https://stackoverflow.com/questions/9751345/asynchronous-i-o-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!