gpt4 book ai didi

file - POSIX O_DIRECT 与 Windows FILE_FLAG_WRITE_THROUGH & FILE_FLAG_NO_BUFFERING

转载 作者:行者123 更新时间:2023-12-03 16:17:36 25 4
gpt4 key购买 nike

据我所知,然后使用 POSIX O_DIRECTopen()阻止设备文件的工作方式与组合 FILE_FLAG_WRITE_THROUGH 的工作方式相同和 FILE_FLAG_NO_BUFFERINGCreateFile()在 Windows 上 - 这是我正确假设的吗?

打开:

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.



创建文件:

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 系统中将这两个标志用作 O_DIRECT 会产生非常相似的效果。在 POSIX 系统上。由于这是两个不同的操作系统,您可以预期没有完全匹配。

但是,除非您试图确切地了解文件系统是如何工作的,否则您会从这两个选项中得到“不要缓冲数据,并尽快将其直接写入磁盘”。

关于file - POSIX O_DIRECT 与 Windows FILE_FLAG_WRITE_THROUGH & FILE_FLAG_NO_BUFFERING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15971746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com