What does sync() _really_ do?

Jim Balter jim at segue.segue.com
Thu Dec 20 13:13:52 AEST 1990


In article <4670 at pkmab.se> ske at pkmab.se (Kristoffer Eriksson) writes:
>When I type "sync" once after some disk writing activity on my system,
>there is a delay before I get the prompt back. If that delay is not caused
>by sync() waiting for disk blocks to be written, then I wonder what it is
>caused by. How do your systems act? Do they give you any delay?

sync does a synchronous write of the superblock.  It also does synchronous
reads of the inode blocks because an inode is only a fraction of a block.
Then it puts all the dirty blocks on the disk queues (starting disk I/O if it
isn't in progress) and returns.  In addition, it's possible for the the inode
reads or other activity to cause pages of your shell to be kicked out (dirty
ones would have to be synchronously written) and they might have to be read
back in before you see your prompt.

Even if sync waited on dirty block writes, that would be a 1-deep "sync queue",
not the fabled 2-deep queue.



More information about the Comp.unix.internals mailing list