bf8
bf8

Reputation: 100

c - Write directly to disk, bypass page cache?

I am trying to determine a way to time a write to disk as accurately as possible.

Calling the write() function writes the file first to the page cache, and then later the system automatically flushes it to disk (if my understanding is correct).

Is there a way to bypass the page cache? Or, would the process involve writing to the page cache, and then flushing the page cache (but how would you then time how long simply flushing the specific data that was written takes)

Upvotes: 0

Views: 1798

Answers (1)

stark
stark

Reputation: 13189

For Linux you can open the disk device with the O_DIRECT flag to bypass page cache.

Upvotes: 2

Related Questions