是什么在UNIX中读取和$ P $垫之间的区别? [英] What is the difference between read and pread in unix?

查看:175
本文介绍了是什么在UNIX中读取和$ P $垫之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么功能之间的差异阅读() $ P $垫()在UNIX?< BR>
当他们之间的选择,我应该采取什么样的两点考虑?

What is the difference between the functions read() and pread() in unix?
When choosing between them, what points should I take into consideration?

我GOOGLE了他们之间,但没有结果的差异。

I googled for the difference between them but without results.

推荐答案

$ P $垫()的作品就像阅读()的,但是从指定位置读取该文件的没有修改文件指针。

Pread() works just like read() but reads from the specified position in the file without modifying the file pointer.

当你需要你可以使用它来反复读取固定偏移数据,例如,在文件指向单个记录数据库索引,以节省的寻求()的来电。

You would use it when you need to repeatedly read data at fixed offset, for example a database index that points to individual records in file, to save on seek() calls.

基本上使用的阅读(),如果你的数据是连续的或 $ P $垫()如果你知道,或者可以在那里计算偏移读的。

这篇关于是什么在UNIX中读取和$ P $垫之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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