POSIX O_DIRECT与Windows FILE_FLAG_WRITE_THROUGH& FILE_FLAG_NO_BUFFERING [英] POSIX O_DIRECT vs Windows FILE_FLAG_WRITE_THROUGH & FILE_FLAG_NO_BUFFERING

查看:244
本文介绍了POSIX O_DIRECT与Windows FILE_FLAG_WRITE_THROUGH& FILE_FLAG_NO_BUFFERING的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,然后在阻止设备文件上使用带open()的POSIX O_DIRECT和在Windows上将FILE_FLAG_WRITE_THROUGHFILE_FLAG_NO_BUFFERINGCreateFile()组合在一起的方式相同-正确地假定为我?

From what I can gather, then using POSIX O_DIRECT with open() on blocking device files works just the same way as combining both FILE_FLAG_WRITE_THROUGH and FILE_FLAG_NO_BUFFERING with CreateFile() on Windows - is this correctly assumed by me?

打开:

O_DIRECT 尝试最小化往返于此文件的I/O的缓存影响.通常,这会降低性能,但在以下方面很有用 特殊情况,例如应用程序自行缓存时. 文件I/O是直接在用户空间缓冲区中进行的.

O_DIRECT Try to minimize cache effects of the I/O to and from this file. In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user space buffers.

创建文件:

如果使用 FILE_FLAG_WRITE_THROUGH ,但 FILE_FLAG_NO_BUFFERING 也未指定,以便系统缓存生效,然后 数据被写入系统缓存,但不刷新而被刷新到磁盘 延迟.如果 FILE_FLAG_WRITE_THROUGH FILE_FLAG_NO_BUFFERING 都指定了,这样系统缓存就不会生效,然后 数据立即刷新到磁盘,而无需通过Windows 系统缓存.操作系统还请求以下内容的直写 硬盘的本地硬件缓存到持久性介质.

If FILE_FLAG_WRITE_THROUGH is used but FILE_FLAG_NO_BUFFERING is not also specified, so that system caching is in effect, then the data is written to the system cache but is flushed to disk without delay. If FILE_FLAG_WRITE_THROUGH and FILE_FLAG_NO_BUFFERING are both specified, so that system caching is not in effect, then the data is immediately flushed to disk without going through the Windows system cache. The operating system also requests a write-through of the hard disk's local hardware cache to persistent media.

推荐答案

是的,在Windows系统中将这两个标志用作POSIX系统上的O_DIRECT会产生非常相似的效果.由于这是两个不同的操作系统,因此可以预期没有完全匹配的内容.

Yes, it will have a very similar effect to use those two flags in a Windows system as O_DIRECT on a POSIX system. Since these are two different OS's, you can expect that there is no EXACT match.

但是,除非您试图确切地了解文件系统是如何工作的,否则您会得到"不要缓冲数据,并尽快将其直接写到磁盘上"选项.

However, unless you are trying to understand exactly how the filesystem does things, you get "don't buffer the data, and write it straight to disk as soon as possible" from both of those options.

这篇关于POSIX O_DIRECT与Windows FILE_FLAG_WRITE_THROUGH& FILE_FLAG_NO_BUFFERING的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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