From: bill@franklin.com (bill) Subject: Re: random historical lore (directory locations, sync) Date: 29 Jan 1992 22:24:59 GMT
In article <Jan.28.12.38.48.1992.20413@dumas.rutgers.edu> hedrick@dumas.rutgers.edu (Charles Hedrick) writes:
: At some point somebody asked about doing sync more than once.
: Traditionally before taking down a system people type sync three
: times. There is actually a reason. The first sync simply scheduled
: all dirty blocks for writing. But it didn't wait for them all to be
: written. However a second sync would block until the first one had
: finished, i.e. all dirty blocks had actually been written out. So if
: you wanted to make sure the disk was up to date, you had to do two
: syncs. Why 3 rather than 2 I couldn't say though.
Sigh, that old myth again. No, that's not what the three syncs are
for. Here's the reality. A sync does not return until all the
blocks in the _buffer cache_ are queued for writing. However, most
of those blocks are still in the _disk queues_ after the sync
returns. There is no way in older Unixes to know when they are out
of the disk queues. So, the first sync flushes the buffer cache;
the second and third are there just so that the typist waits a
decent amount of time until all blocks have made it out of the
disk queue before taking the system down.