异步I / O Linux [英] Asynchronous I/O Linux
问题描述
需要异步I / O处理
计划通过Linux上的aio *调用使用异步I / O
情况:
我用AF_INET和SOCK_STREAM标志(TCP)打开了套接字
发送缓冲区有限制高水位
写入该套接字异步,当发送缓冲区溢出时,要断开套接字
所以,我有问题:
-
当我对TCP套接字进行异步调用aio_write时,当I / O完成到达时 - 当缓冲区写入到套接字缓冲区或交付被确认时?
$
b$ b
尊敬的,
Andrew
任何真实的,至少现在,从 aio(7)
:
当前Linux POSIX AIO实现在glibc的用户空间中提供。这有一些限制,最明显的是维护多个线程来执行I / O操作是昂贵的并且扩展性差。基于内核状态机的实现异步I / O的工作已经进行了一段时间(参见io_submit(2)
,io_setup 2)
,io_cancel(2)
,io_destroy(2)
,io_getevents(2)
),但是这个实现还没有成熟到POSIX AIO实现可以使用内核系统调用完全重新实现。
而是通过 select(2)
/ poll(2)
/ epoll(7)
。 p>
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:
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?
How's best to handle this with lio_listio techniques
Regards, Andrew
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 (seeio_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)
.
这篇关于异步I / O Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!