You are not logged in.
Pages: 1
When fflush() flushes a file stream, what does the other end of the stream connect to? I assume it's connected to the file system buffer, meaning that calling fflush() forces all dirty pages to be flushed to the FS buffer. What then is the intermediary buffer between the application and the FS buffer called, and why is it necessary if the FS buffer already exists?
How I see it:
Application data space -> File buffer -> File system buffer -> Disk
I don't know the official name of what I call "file buffer".
Conversely, the sync() utility forces all file system buffers to disk, which is unrelated to what fflush() does, right?
Offline
[No, wait, I don't have anything particularly helpful. Never mind. I am as yet unable to fully comprehend *nix IO.]
Last edited by Peasantoid (2010-05-14 21:57:02)
Offline
fflush's man page gives a fairly reasonable explanation of what it does, and actually mentions the variation between fflush and sync. To wit...
DESCRIPTION
For output streams, fflush() forces a write of all user-space buffered data for the given output or update stream via the stream's underly‐
ing write function.
NOTES
Note that fflush() only flushes the user space buffers provided by the C library. To ensure that the data is physically stored on disk the
kernel buffers must be flushed too, for example, with sync(2) or fsync(2).
Offline
Offline
Pages: 1