How write() works

tomas@tuxteam.de tomas@tuxteam.de
Tue Nov 30 14:48:00 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Nov 30, 2010 at 02:17:10PM +0200, Marcus Clyne wrote:
> Hi,
>
> I'm trying to find out how write() works, specifically what has happened 
> before it returns successfully [...]

> 1) The data has been written to kernel memory, and may or may not have yet 
> been written to the final storage location [...]

> 2) The data has been written to the final storage medium [...]

> I'm assuming that it is situation 1, but I'd like to be certain.  Any 
> clarification on this would be much appreciated.

Yes, it's most definitely (1). The kernel usually decides when commit to
media happens, possibly juggling things to increase throughput. Elevator
and all those things. It wouldn't make sense to put the app to wait for
as long as this happens.

See fsync(2) if you want to make sure that things are on disk (well,
there's the cache on the disk drive; it's turtles all the way down ;-)

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFM9RD7Bcgs9XrR2kYRAp8gAJ991p+Ut/arE2jEzdGKbBjkp1y0CwCeId06
3f6MIdTOpzvL7i6B6zDgeHE=
=0B2B
-----END PGP SIGNATURE-----



More information about the Libc-help mailing list