我知道有了拼接,我们都可以留在内核中。但我不确定传递给管道的是数据还是行踪信息。
编辑 1: 谢谢@vinayak,现在我知道实际上有数据复制到管道缓冲区和从管道缓冲区复制。但是,我只是想知道为什么我们不能只将行踪和长度信息传递给管道?
- 在同一个进程中,地址空间是一样的
- 在不同的进程之间,如果管道缓冲区是线性映射的,它也可以工作。如果不是,我们可以使用 DMA 地址。
最佳答案
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() 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.
关于linux - 拼接系统调用,传递给管道的是什么?数据或行踪信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17268826/