异步I / O Linux [英] Asynchronous I/O Linux

查看:290
本文介绍了异步I / O Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要异步I / O处理



计划通过Linux上的aio *调用使用异步I / O



情况:



我用AF_INET和SOCK_STREAM标志(TCP)打开了套接字
发送缓冲区有限制高水位
写入该套接字异步,当发送缓冲区溢出时,要断开套接字



所以,我有问题:


  1. 当我对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:

  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

解决方案

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).

这篇关于异步I / O Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆