Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
On 06/19/2012 03:11 PM, Derek Martin wrote: > On Sat, Jun 16, 2012 at 12:59:44PM -0400, MBR wrote: >> On 6/12/2012 11:22 PM, Jack Coats wrote: >>> In old SunOS days, we could issue the 'sync' command, twice, to ensure >>> all system >>> buffers had been written to disk. You could experiment to see if >>> issuing it occasionally >>> in your script helps. Or issue it outside the script, even in a chron >>> might help. >> Actually, calling 'sync' multiple times from a script really won't >> help. To the best of my knowledge, no Unix kernel has ever >> contained code that counts the number of times sync() (the system >> call that the 'sync' command issues) has been called. > The reason I was taught to do this differs from what you put forth, > and regardless it's certainly true that no modern Unix should ever > require a user to run sync manually, except possibly in very rare > circumstances. > > I don't claim to know the veracity of this, but I was taught (by a > college professor who taught Unix system adminsistration as a course, > for whatever that's worth) that the reason to sync twice (not three > times) is that, as you say, the first call to sync schedules the > kernel to sync the buffers, but does not necessarily complete before > the system call returns; however (as I was told) a SUBSEQUENT call to > the sync() system call would block until any previously scheduled sync > had completed. Thus, the completion of the SECOND sync command > guarantees that the FIRST sync completed flushing the buffers to disk. > > Now, I certainly have not spent the time to look at the code to any > antiquated Unix kernels to confirm whether this was ever actually true, > anywhere. And I don't intend to. But it's at least plausible that it > was true at one point in some popular Unix. As you yourself said, for > quite a long while now on Linux (since August of 1995), sync() actually > does wait until the buffers are flushed. But even that is mostly > irrelevant as the kernel forces the buffers to be flushed periodically > and flushes them prior to system shutdown (assuming it can, of > course). I agree with your explanation. In any case, the halt system call at that time did not wait. Also, system calls were generally single threaded. -- Jerry Feldman <gaf at blu.org> Boston Linux and Unix PGP key id:3BC1EB90 PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66 C0AF 7CEA 30FC 3BC1 EB90
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |