接头系统调用,什么传递到管道?数据或行踪信息? [英] Splice system call, what is passed to the pipe? Data or whereabouts info?

查看:86
本文介绍了接头系统调用,什么传递到管道?数据或行踪信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有了一个接头,我们都可以留在内核中.但是我不确定是传递给管道的是数据还是行踪信息.

I know with a splice, we can all stay in the kernel. But I am not sure whether it is the data or the whereabouts info that get passed to the pipe.

感谢@vinayak,现在我知道实际上有往返于管道缓冲区的数据复制.但是然后,我只是想知道为什么我们不能仅仅将行踪和长度信息传递给管道?

EDIT 1: Thanks @vinayak, now I know there is actually data copy to and from the pipe buffer. But then, I just wonder why we can not just pass whereabouts and length info to the pipe?

  • 在单个过程中,地址空间是相同的
  • 在差异处理之间,如果管道缓冲区是线性映射的,它也可以工作.如果没有,我们可以使用DMA地址.

推荐答案

在此处引用

splice()是一种系统调用机制,用于从一个文件到另一个文件执行I/O操作. 内核空间中的另一个文件,而无需执行与用户之间的复制 空间.这是提高I/O性能的一种方式.接头系统调用 避免将所有数据从用户空间复制到内核空间&反之亦然.它 从输入文件&的指定偏移量中读取&写入管道 在内核空间中.不会将数据复制到用户空间. 可以调用以将数据从管道写入以下位置的输出文件: 指定/当前的偏移量.

A splice() is a system call mechanism to do i/o from one file to another file in kernel space without doing copying from/to user space.It is a way of improving I/O performance. The splice system call avoids all data copy from user space to kernel space & vice versa. It reads from the specified offset from the input file & writes to a pipe in the kernel space. There is no copying of data to user space.Then it can be called to write the data from the pipe to the output file at the specified/current offset.

splice()通过使用管道缓冲机制打开文件来工作 数据源的描述符,然后是数据宿的描述符,然后使用 splice()可以将两者结合在一起.换句话说,splice()起作用 在用户可以控制和移动数据的内核缓冲区上 到/从缓冲区到/从任意文件描述符到/从任意文件描述符.指定 与管道的偏移量是通常的错误.如果没有指定偏移量 输入/输出文件描述符,则当前偏移量为 假定为指定的偏移量.当前文件之一 描述符必须是管道,否则会出错.

splice() works by using the pipe buffer mechanism to open a file descriptor for a data source and another for a data sink then by using splice() it can join the two together. In other words, splice() work on a kernel buffer that the user has control over and moves data to/from the buffer from/to an arbitrary file descriptor. Specifying offset with pipe is an error as usual. If no offset is specified with an input/output file descriptor then the current offset will be assumed to be the offset specified. Currently one of the file descriptor must be pipe otherwise it is an error.

这篇关于接头系统调用,什么传递到管道?数据或行踪信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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