Sender: Mark Harrison From: markh@usai.asiainfo.com Subject: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Newsgroups: alt.folklore.computers References: User-Agent: tin/pre-1.4-19990413 ("Endemoniada") (UNIX) (Linux/2.0.36 (i586)) Message-ID: <12oah7.eh.ln@bigbird.sw.asiainfo.com> Lines: 20 X-Trace: /Kkf2O/cBQDtxPK5Y+4H3xi+wB+7OIa+y5HwNus8QaSr2oafP2s0kYVGhT/g0vse8apjiLwJRTIl!qLfPM/uh3SkA3iv1kyLOeSnb4H+INLN9rYJrjPxr8xxf7hylUvguVA/+jRDoDHuqmw== X-Complaints-To: abuse@gte.net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Wed, 12 May 1999 02:44:16 GMT Distribution: world Date: Wed, 12 May 1999 02:44:16 GMT Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!isdnet!newsfeed.cwix.com!4.1.16.34!cpk-news-hub1.bbnplanet.com!washdc3-snh1.gtei.net!news.gtei.net!dfiatx1-snr1.gtei.net.POSTED!not-for-mail Sarr J. Blumson wrote: : Just run "sync" twice and shut if off IIRC. fsck would run when you rebooted, : but it wouldn't find any problems and the disks were small... I was always curious why the unix manuals would always recomment "sync; sync; halt" My mentor of sorts (this was in 1984) had worked on the Nixdorf unix port and said it was unnecessary. "If you don't trust it the first time, what makes you think it's going to work the second time?" Anything I missed? Mark. -- Mark Harrison "Open the floppy disk door, Hal." AsiaInfo Computer Networks http://usai.asiainfo.com:8080/ Beijing, China / Santa Clara, CA markh@usai.asiainfo.com ###### Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) From: aek@spies.com (Al Kossow) Newsgroups: alt.folklore.computers References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> Distribution: world Originator: aek@spies.com NNTP-Posting-Host: goonsquad.spies.com Message-ID: <3738e0b1.0@news.spies.com> Date: 11 May 1999 19:00:17 -0700 X-Trace: 11 May 1999 19:00:17 -0700, goonsquad.spies.com Lines: 22 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!enews.sgi.com!news.sgi.com!news.spies.com!spies.com!aek From article <12oah7.eh.ln@bigbird.sw.asiainfo.com>, by markh@usai.asiainfo.com: > Sarr J. Blumson wrote: > : Just run "sync" twice and shut if off IIRC. fsck would run when you rebooted, > : but it wouldn't find any problems and the disks were small... > > I was always curious why the unix manuals would always recomment > "sync; sync; halt" > > My mentor of sorts (this was in 1984) had worked on the Nixdorf > unix port and said it was unnecessary. "If you don't trust it > the first time, what makes you think it's going to work the > second time?" > > Anything I missed? Sync can take a while to complete in the background. Without the second sync, the halt might occur before all of the disc I/O has finished. Modern versions may differ, but this was how it worked on V6 and V7. ###### Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> From: greg andruk Organization: meow ergo vulis Date: 11 May 1999 23:47:41 -0400 Message-ID: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> Lines: 21 X-Newsreader: Gnus v5.7/XEmacs 20.4 - "Emerald" Cancel-Lock: sha1:UqN3LePEw4vlznphkzpNzijEazs= NNTP-Posting-Host: 32.100.244.155 X-Trace: 12 May 1999 03:48:05 GMT, 32.100.244.155 X-Notice: Items posted that violate the IBM.NET Acceptable Use Policy X-Notice: should be reported to postmaster@ibm.net X-Complaints-To: postmaster@ibm.net Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!isdnet!nntp.abs.net!news-peer.gip.net!news.gsl.net!gip.net!newsfeed2.us.ibm.net!ibm.net!news3.us.ibm.net!32.100.244.155 markh writes: > I was always curious why the unix manuals would always recomment > "sync; sync; halt" > My mentor of sorts (this was in 1984) had worked on the Nixdorf > unix port and said it was unnecessary. "If you don't trust it > the first time, what makes you think it's going to work the > second time?" > Anything I missed? Yeah, you were looking for something to make sense. The sync(2) call isn't necessarily, um, synchronous. It initiates a cache enema, but can return before the data is actually written to disk (Sun and linux work this way, other implementations may differ). Running 'sync' twice (Hmm, I learned it as 3 times) might not do much, but at least it buys time for the first sync to finish before the halt kicks in. There is an fsync() that waits, but that's per descriptor instead of for the whole system. -- Misc. Meowing: **meow** ###### From: Dennis Ritchie Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: Wed, 12 May 1999 05:29:18 +0100 Organization: Bell Labs, Lucent Technologies Lines: 22 Message-ID: <3739039E.9DE@bell-labs.com> References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> Reply-To: dmr@bell-labs.com NNTP-Posting-Host: cebu.cs.bell-labs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01 (Win95; U) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.maxwell.syr.edu!newsfeed.cwix.com!204.127.161.3!wn3feed!worldnet.att.net!207.24.196.41!nntphub.cb.lucent.com!news markh@usai.asiainfo.com (and previous askers of the question) wrote: > > Sarr J. Blumson wrote: > : Just run "sync" twice and shut if off IIRC. fsck would run when you rebooted, > : but it wouldn't find any problems and the disks were small... > > I was always curious why the unix manuals would always recomment > "sync; sync; halt" > > My mentor of sorts (this was in 1984) had worked on the Nixdorf > unix port and said it was unnecessary. "If you don't trust it > the first time, what makes you think it's going to work the > second time?" > > Anything I missed? If you actually typed "sync; sync; halt" then I can see the possible timing issue. However, if you were told to type "sync" and then do it again, this had to do with giving you a chance to ponder whether you remembered to do it at all the first time. Dennis ###### From: Eric Levenez Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: 12 May 1999 12:43:56 GMT Organization: Tasha Inc. Lines: 28 Message-ID: <7hbt2c$rec$1@front7.grolier.fr> References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> NNTP-Posting-Host: ppp-175-151.velizy.club-internet.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: front7.grolier.fr 926513036 28108 195.36.175.151 (12 May 1999 12:43:56 GMT) NNTP-Posting-Date: 12 May 1999 12:43:56 GMT X-Face: (X#mE%m~xkAcHidWL",*K0}^dSr;O@^GQMld)TyxVIy%v:.1m4(W%CJP.f+${`En!#Jiy6+do!U$l%RTtl9Ag_cZc[LLljpp_Mdil{A%xC4l9.!.W+`-}9vFjrxr X-Image-Url: http://perso.club-internet.fr/levenez/images/el.jpeg X-Url: http://perso.club-internet.fr/levenez X-Newsreader: Alexandra.app (Version 0.82) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!isdnet!grolier!club-internet!not-for-mail markh@usai.asiainfo.com wrote: > Sarr J. Blumson wrote: > : Just run "sync" twice and shut if off IIRC. fsck would run when you rebooted, > : but it wouldn't find any problems and the disks were small... > > I was always curious why the unix manuals would always recomment > "sync; sync; halt" > > My mentor of sorts (this was in 1984) had worked on the Nixdorf > unix port and said it was unnecessary. "If you don't trust it > the first time, what makes you think it's going to work the > second time?" The first sync is first locking the superblock of the partition, then it start writing all blocks in background. The second sync start but stay waiting on the superblock lock until the first one unlock it after having written all the blocks. Then the second sync start, but leaves immediately because all the blocks have been written. -- -------------------------------------------------------------------- Éric Lévénez "Felix qui potuit rerum cognoscere causas" mailto:levenez@club-internet.fr Publius Vergilius Maro, http://perso.club-internet.fr/levenez Georgica, II-489 -------------------------------------------------------------------- "We are Microsoft. You will be assimilated. Resistance is futile." ###### From: Will Rose Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: 12 May 1999 15:55:55 GMT Organization: CTS Network Services Lines: 29 Distribution: world Message-ID: <7hc8ab$88u$1@nusku.cts.com> References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> <3738e0b1.0@news.spies.com> NNTP-Posting-Host: crash-i2.cts.com X-Trace: nusku.cts.com 926524555 8478 205.163.0.7 (12 May 1999 15:55:55 GMT) X-Complaints-To: usenet@nusku.cts.com NNTP-Posting-Date: 12 May 1999 15:55:55 GMT User-Agent: tin/pre-1.4-19990413 ("Endemoniada") (UNIX) (crash/3.2 (i386)) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!feed2.news.luth.se!luth.se!news-peer-europe.sprintlink.net!news.sprintlink.net!howland.erols.net!news.idt.net!nntp2.cerf.net!mercury.cts.com!nusku.cts.com!not-for-mail Al Kossow wrote: : From article <12oah7.eh.ln@bigbird.sw.asiainfo.com>, by markh@usai.asiainfo.com: :> Sarr J. Blumson wrote: :> : Just run "sync" twice and shut if off IIRC. fsck would run when you rebooted, :> : but it wouldn't find any problems and the disks were small... :> :> I was always curious why the unix manuals would always recomment :> "sync; sync; halt" :> :> My mentor of sorts (this was in 1984) had worked on the Nixdorf :> unix port and said it was unnecessary. "If you don't trust it :> the first time, what makes you think it's going to work the :> second time?" :> :> Anything I missed? : Sync can take a while to complete in the background. : Without the second sync, the halt might occur before : all of the disc I/O has finished. : Modern versions may differ, but this was how it worked on : V6 and V7. The other approach was 'sync and wait 30 seconds'. Will cwr@crash.cts.com ###### From: Roman Belenov Newsgroups: alt.folklore.computers Subject: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: Wed, 12 May 1999 21:24:02 +0400 Organization: NSTL Lines: 18 Message-ID: <19891.990512@nstl.nnov.ru> References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> Reply-To: Roman Belenov NNTP-Posting-Host: postnews.dejanews.com Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: The Bat! (v1.043) S/N D2F7ACD5 Priority: Normal To: greg andruk Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news-fra1.dfn.de!bignews.mediaways.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp2.dejanews.com!nnrp1.dejanews.com!not-for-mail Hello Greg, I've heard that when the second sync command exits, the data will be flushed. Isn't it true, at least on some systems ? ga> Yeah, you were looking for something to make sense. The sync(2) call ga> isn't necessarily, um, synchronous. It initiates a cache enema, but ga> can return before the data is actually written to disk (Sun and linux ga> work this way, other implementations may differ). Running 'sync' ga> twice (Hmm, I learned it as 3 times) might not do much, but at least ga> it buys time for the first sync to finish before the halt kicks in. Best regards, Roman mailto:roman@nstl.nnov.ru ###### Date: 12 May 99 14:05:08 -0800 From: "Charlie Gibbs" Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <19891.990512@nstl.nnov.ru> Message-ID: <438.801T404T8453945@sky.bus.com> Newsgroups: alt.folklore.computers X-Newsreader: THOR 2.5a (Amiga;TCP/IP) NNTP-Posting-Host: news.skybus.com X-Trace: 12 May 1999 16:55:16 -0800, news.skybus.com Lines: 15 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news-fra1.dfn.de!news0.de.colt.net!colt.net!dispose.news.demon.net!demon!news.maxwell.syr.edu!news-peer1.sprintlink.net!news-in-central.sprintlink.net!news.sprintlink.net!news.westel.com!news.skybus.com!204.244.247.105 In article <19891.990512@nstl.nnov.ru> roman@nstl.nnov.ru (Roman Belenov) writes: >I've heard that when the second sync command exits, the data will be >flushed. Isn't it true, at least on some systems ? "Sync three times on the console if you want me. Close all the pipes if the answer is no..." (with apologies to Tony Orlando and Dawn) -- cgibbs@sky.bus.com (Charlie Gibbs) Remove the first period after the "at" sign to reply. ###### From: David Scheidt Newsgroups: alt.folklore.computers Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: 12 May 1999 23:59:44 GMT Organization: EnterAct L.L.C. Turbo-Elite News Server Lines: 14 Message-ID: <7hd4lg$5a8$1@eve.enteract.com> References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <19891.990512@nstl.nnov.ru> NNTP-Posting-Host: 207.229.143.42 User-Agent: tin/pre-1.4-19990216 ("Styrofoam") (UNIX) (FreeBSD/3.1-STABLE (i386)) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.maxwell.syr.edu!newsfeed.enteract.com!news.enteract.com!not-for-mail Roman Belenov wrote: : I've heard that when the second sync command exits, the data will be : flushed. Isn't it true, at least on some systems ? I was taught that sync(8) wrote all buffers that had been scheduled for a write, and scheduled all dirty buffers for writing. By doing it twice, you guaranteed that all dirty buffers were written to disk. David, who supposes he should go look at the source... -- dscheidt@enteract.com Ketchup, therefore, shows both thixotropic and pseudoplastic rheological properties. -- John Schmitt, in AFU ###### From: lucvdv@null.net (Luc Van der Veken) Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: Wed, 12 May 1999 21:16:23 GMT Organization: . Message-ID: <373bd29a.2458364@news.uunet.be> References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> <7hbt2c$rec$1@front7.grolier.fr> NNTP-Posting-Host: pool02b-194-7-89-104.uunet.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.451 Lines: 21 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!isdnet!newsfeed.icl.net!dispose.news.demon.net!demon!tank.news.pipex.net!pipex!warm.news.pipex.net!pipex!krypton.inbe.net!INbe.net!not-for-mail alt.folklore.computers << Eric Levenez (12 May 1999 12:43:56 GMT); > The first sync is first locking the superblock of the partition, then > it start writing all blocks in background. > > The second sync start but stay waiting on the superblock lock until > the first one unlock it after having written all the blocks. Then > the second sync start, but leaves immediately because all the blocks > have been written. What is the second sync good for, if you switch off your computer while it's still waiting? The prompt will pop up again [after typing the second sync] before it [the first one] has finished anyway, it my experiences are right. When I was small, they told me all it was about was giving the system some time to finish the first sync. FWIW, systems never shut down anyway (people just keep them running to see how long it takes the OS to crash ;-) ###### Sender: eric@ruckus.brouhaha.com From: Eric Smith Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> <7hdcos$bdq$1@goblin.uunet.ca> X-Disclaimer: Everything I write is false. Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy. Date: 13 May 1999 00:42:05 -0700 Message-ID: Lines: 12 X-Newsreader: Gnus v5.5/Emacs 20.2 NNTP-Posting-Host: ruckus.brouhaha.com X-Trace: 12 May 1999 23:45:25 -0700, ruckus.brouhaha.com Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!enews.sgi.com!news.sgi.com!news.spies.com!ruckus.brouhaha.com mtpins@visi.com (Michael T Pins) writes: > There is no guarantee that the sync will be finished before the call > returns. On many flavors of unix, the sync program only calls sync(2), > then returns control to the user. The actaul sync'ing of the discs may > or may not be finished. However, the second sync command *cannot* return > until the first sync has finished (it can't invoke sync(2) until the first > one has finished). In other words, the purpose of the second sync is to > insure the first one is actually finished. If sync(2) doesn't execute synchronously, what mechanism are you claiming that imposes the constraint "it can't invoke sync(2) until the first one has finished"? ###### From: triso@remove-me.inasec.ca (Tris Orendorff) Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: Thu, 13 May 1999 02:14:23 GMT Organization: UUNET Canada News Transport Lines: 26 Distribution: world Message-ID: <7hdcos$bdq$1@goblin.uunet.ca> References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> NNTP-Posting-Host: 209.47.93.27 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Newsreader: News Xpress 2.01 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!isdnet!newsfeed.cwix.com!18.24.4.11!newsswitch.lcs.mit.edu!cyclone.bc.net!news.uunet.ca!tris In article <12oah7.eh.ln@bigbird.sw.asiainfo.com>, markh@usai.asiainfo.com wrote: > Sarr J. Blumson wrote: > : Just run "sync" twice and shut if off IIRC. fsck would run when you > rebooted, > : but it wouldn't find any problems and the disks were small... > > I was always curious why the unix manuals would always recomment > "sync; sync; halt" > > My mentor of sorts (this was in 1984) had worked on the Nixdorf > unix port and said it was unnecessary. "If you don't trust it > the first time, what makes you think it's going to work the > second time?" Wise words, indeed. I am sure that sync originally had a timing bug and the repeat running was to make sure it really finished. Poor planning, shoddy programming all around followed by a poor fix by some undisciplined code typist. ----- BEGIN GEEK CODE BLOCK ----- Version: 3.12 GCS d++ s a C+ UC++++ P+ L E- W+ N++ o- K++ w+ O+ M !V PS+ PE Y+ PGP t+ !5 X- R- tv--- b++ DI++ D+ G+ e+ h---- r+++ y+ ------ END GEEK CODE BLOCK ------ ###### Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> <7hdcos$bdq$1@goblin.uunet.ca> X-Newsreader: NN version 6.5.3 (NOV) From: mtpins@visi.com (Michael T Pins) Lines: 40 Message-ID: Date: Thu, 13 May 1999 03:59:02 GMT NNTP-Posting-Host: 209.98.98.8 X-Complaints-To: abuse@visi.com X-Trace: ptah.visi.com 926567942 209.98.98.8 (Wed, 12 May 1999 22:59:02 CDT) NNTP-Posting-Date: Wed, 12 May 1999 22:59:02 CDT Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.maxwell.syr.edu!chippy.visi.com!news-out.visi.com!ptah.visi.com!not-for-mail triso@remove-me.inasec.ca (Tris Orendorff) writes: >In article <12oah7.eh.ln@bigbird.sw.asiainfo.com>, markh@usai.asiainfo.com wrote: >> Sarr J. Blumson wrote: >> : Just run "sync" twice and shut if off IIRC. fsck would run when you >> rebooted, >> : but it wouldn't find any problems and the disks were small... >> >> I was always curious why the unix manuals would always recomment >> "sync; sync; halt" >> >> My mentor of sorts (this was in 1984) had worked on the Nixdorf >> unix port and said it was unnecessary. "If you don't trust it >> the first time, what makes you think it's going to work the >> second time?" >Wise words, indeed. I am sure that sync originally had a timing bug and the >repeat running was to make sure it really finished. Poor planning, >shoddy programming all around followed by a poor fix by some undisciplined >code typist. Unwise words, indeed. There is no guarantee that the sync will be finished before the call returns. On many flavors of unix, the sync program only calls sync(2), then returns control to the user. The actaul sync'ing of the discs may or may not be finished. However, the second sync command *cannot* return until the first sync has finished (it can't invoke sync(2) until the first one has finished). In other words, the purpose of the second sync is to insure the first one is actually finished. Before you start spouting nonsense about "a timing bug" and "Poor planning, shoddy programming", I suggest you actually find out something about what you're talking about. Say, reading the man pages for sync and sync(2) for starters.... -- ************************************************************************** * Michael T Pins | mtpins@visi.com * * keeper of the nn sources | mtpins@icaen.uiowa.edu * * ftp://ftp.visi.com/users/mtpins | #include * ###### From: jmfbahciv@aol.com Newsgroups: alt.folklore.computers Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: Thu, 13 May 99 10:21:49 GMT Organization: UltraNet Communications, Inc. Lines: 21 Message-ID: <7hefde$eic$4@antiochus.ultra.net> References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <19891.990512@nstl.nnov.ru> <438.801T404T8453945@sky.bus.com> NNTP-Posting-Host: d5.dial-12.mbo.ma.ultra.net X-Complaints-To: abuse@ultra.net X-Ultra-Time: 13 May 1999 12:09:18 GMT X-Newsreader: News Xpress Version 1.0 Beta #4 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.maxwell.syr.edu!newsswitch.lcs.mit.edu!news.ultranet.com!d5 In article <438.801T404T8453945@sky.bus.com>, "Charlie Gibbs" wrote: >In article <19891.990512@nstl.nnov.ru> roman@nstl.nnov.ru >(Roman Belenov) writes: > >>I've heard that when the second sync command exits, the data will be >>flushed. Isn't it true, at least on some systems ? > >"Sync three times on the console if you want me. > Close all the pipes if the answer is no..." > >(with apologies to Tony Orlando and Dawn) > ROTFL! That's a new one for me. It never occurred to me until now that composing lyrics could be a very good "how to program" device. It certainly wouldn't limit the information to a class room. /BAH Subtract a hundred and four for e-mail. ###### Newsgroups: alt.folklore.computers Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <19891.990512@nstl.nnov.ru> <7hd4lg$5a8$1@eve.enteract.com> Organization: Plethora . Net - More net, less spam! X-Newsreader: trn 4.0-test70 (17 January 1999) From: seebs@plethora.net (Peter Seebach) Lines: 21 Message-ID: Date: Thu, 13 May 1999 15:40:24 GMT NNTP-Posting-Host: 205.166.146.8 X-Complaints-To: abuse@plethora.net X-Trace: ptah.visi.com 926610024 205.166.146.8 (Thu, 13 May 1999 10:40:24 CDT) NNTP-Posting-Date: Thu, 13 May 1999 10:40:24 CDT Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.belnet.be!news-feed.inet.tele.dk!bofh.vszbr.cz!scrappy.visi.com!chippy.visi.com!news-out.visi.com!ptah.visi.com!not-for-mail In article <7hd4lg$5a8$1@eve.enteract.com>, David Scheidt wrote: >Roman Belenov wrote: > >: I've heard that when the second sync command exits, the data will be >: flushed. Isn't it true, at least on some systems ? > >I was taught that sync(8) wrote all buffers that had been scheduled for a >write, and scheduled all dirty buffers for writing. By doing it twice, you >guaranteed that all dirty buffers were written to disk. I was told that you did it three times because the time it took to type this command three times on a slow console was long enough for all the writes to actually happen. -s -- Copyright 1999, All rights reserved. Peter Seebach / seebs@plethora.net C/Unix wizard, Pro-commerce radical, Spam fighter. Boycott Spamazon! Will work for interesting hardware. http://www.plethora.net/~seebs/ Visit my new ISP --- More Net, Less Spam! ###### From: jmfbahciv@aol.com Newsgroups: alt.folklore.computers Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: Thu, 13 May 99 10:38:20 GMT Organization: UltraNet Communications, Inc. Lines: 48 Message-ID: <7hegcd$eic$6@antiochus.ultra.net> References: <12oah7.eh.ln@bigbird.sw.asiainfo.com> <7hdcos$bdq$1@goblin.uunet.ca> NNTP-Posting-Host: d5.dial-12.mbo.ma.ultra.net X-Complaints-To: abuse@ultra.net X-Ultra-Time: 13 May 1999 12:25:49 GMT X-Newsreader: News Xpress Version 1.0 Beta #4 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!feed2.news.luth.se!luth.se!arclight.uoregon.edu!logbridge.uoregon.edu!newsswitch.lcs.mit.edu!news.ultranet.com!d5 In article , mtpins@visi.com (Michael T Pins) wrote: >triso@remove-me.inasec.ca (Tris Orendorff) writes: > >>In article <12oah7.eh.ln@bigbird.sw.asiainfo.com>, markh@usai.asiainfo.com wrote: >>> Sarr J. Blumson wrote: >>> : Just run "sync" twice and shut if off IIRC. fsck would run when you >>> rebooted, >>> : but it wouldn't find any problems and the disks were small... >>> >>> I was always curious why the unix manuals would always recomment >>> "sync; sync; halt" >>> >>> My mentor of sorts (this was in 1984) had worked on the Nixdorf >>> unix port and said it was unnecessary. "If you don't trust it >>> the first time, what makes you think it's going to work the >>> second time?" > >>Wise words, indeed. I am sure that sync originally had a timing bug and the >>repeat running was to make sure it really finished. Poor planning, >>shoddy programming all around followed by a poor fix by some undisciplined >>code typist. > >Unwise words, indeed. >There is no guarantee that the sync will be finished before the call >returns. On many flavors of unix, the sync program only calls sync(2), >then returns control to the user. The actaul sync'ing of the discs may >or may not be finished. However, the second sync command *cannot* return >until the first sync has finished (it can't invoke sync(2) until the first >one has finished). In other words, the purpose of the second sync is to >insure the first one is actually finished. > >Before you start spouting nonsense about "a timing bug" and "Poor planning, >shoddy programming", I suggest you actually find out something about what >you're talking about. Say, reading the man pages for sync and sync(2) for >starters.... > And, thus, timesharing was born. Why should a whole system wait for a [put favorite slow device here] to finish? /BAH Subtract a hundred and four for e-mail. ###### Newsgroups: alt.folklore.computers From: eric@fudge.uchicago.edu (Eric Fischer) Subject: Re: why sync twice?" (was Re: PDP-11 emulation and Unix v7) X-Nntp-Posting-Host: fudge.uchicago.edu Message-ID: Sender: news@midway.uchicago.edu (News Administrator) X-Newsposter: Pnews 4.0-test51 (15 Jan 97) Organization: The University of Chicago References: <7hdcos$bdq$1@goblin.uunet.ca> Date: Thu, 13 May 1999 14:26:56 GMT Lines: 23 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!newscore.univie.ac.at!howland.erols.net!vixen.cso.uiuc.edu!uchinews!not-for-mail Eric Smith wrote: > If sync(2) doesn't execute synchronously, what mechanism are you > claiming that imposes the constraint "it can't invoke sync(2) until > the first one has finished"? The code for update() (available in Lions' Commentary on Unix), which sync() calls, begins with updlock++; and ends with updlock = 0; This means that a call to sync() could check whether another sync() is already in progress and could wait to return until it finishes. Unfortunately, this isn't what actually happens. In fact, if updlock is set, update() just returns immediately rather than doing anything at all. So much for the utility of a second sync. eric ###### Newsgroups: alt.folklore.computers Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <19891.990512@nstl.nnov.ru> <7hd4lg$5a8$1@eve.enteract.com> Organization: Wizvax Communications, LLC From: multics@wizvax.wizvax.net (Richard Shetron) NNTP-Posting-Host: 199.181.141.5 Message-ID: <373b386b.0@news.wizvax.net> Date: 13 May 1999 16:39:07 -0500 X-Trace: 13 May 1999 16:39:07 -0500, 199.181.141.5 Lines: 25 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.belnet.be!newspump.monmouth.com!newspeer.monmouth.com!newsfeed.wizvax.net!news.wizvax.net!wizvax.wizvax.net!multics In article , Peter Seebach wrote: >In article <7hd4lg$5a8$1@eve.enteract.com>, >David Scheidt wrote: >>Roman Belenov wrote: >> >>: I've heard that when the second sync command exits, the data will be >>: flushed. Isn't it true, at least on some systems ? >> >>I was taught that sync(8) wrote all buffers that had been scheduled for a >>write, and scheduled all dirty buffers for writing. By doing it twice, you >>guaranteed that all dirty buffers were written to disk. > >I was told that you did it three times because the time it took to type >this command three times on a slow console was long enough for all the >writes to actually happen. > >-s >-- >Copyright 1999, All rights reserved. Peter Seebach / seebs@plethora.net I was told twice for that reason. twice was long enough that by the time the operator finished typing the second, the first would have finished so quick operators wouldn't remove power before the writes finished. ###### Newsgroups: alt.folklore.computers From: mbg@world.std.com (Megan) Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Message-ID: Date: Sun, 16 May 1999 14:12:34 GMT References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <19891.990512@nstl.nnov.ru> <7hd4lg$5a8$1@eve.enteract.com> <373b386b.0@news.wizvax.net> Organization: The World Public Access UNIX, Brookline, MA Lines: 26 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.maxwell.syr.edu!korova.insync.net!uunet!ffx.uu.net!world!mbg multics@wizvax.wizvax.net (Richard Shetron) writes: >>I was told that you did it three times because the time it took to type >>this command three times on a slow console was long enough for all the >>writes to actually happen. Which is strange, since I learned to do: # sync; sync; sync; halt all on one line... per the directions for some version of Ultrix Megan Gentry Former RT-11 Developer +--------------------------------+-------------------------------------+ | Megan Gentry, EMT/B, PP-ASEL | Internet (work): gentry!zk3.dec.com | | Unix Support Engineering Group | (home): mbg!world.std.com | | Compaq Computer Corporation | addresses need '@' in place of '!' | | 110 Spitbrook Rd. ZK03-2/T43 | URL: http://world.std.com/~mbg/ | | Nashua, NH 03062 | "pdp-11 programmer - some assembler | | (603) 884 1055 | required." - mbg | +--------------------------------+-------------------------------------+ ###### From: fishbowl@fotd.hosting.netcom.com Newsgroups: alt.folklore.computers Subject: Re: Re[2]: why sync twice?" (was Re: PDP-11 emulation and Unix v7) Date: 17 May 1999 16:35:50 -0500 Organization: Disorganization of Nonmembers Lines: 17 Message-ID: <7hq23m$4ke$1@fotd.hosting.netcom.com> References: <874sljx82q.fsf@slip-32-100-202-102.ma.us.ibm.net> <7hd4lg$5a8$1@eve.enteract.com> <373b386b.0@news.wizvax.net> Reply-To: "J.L.M." NNTP-Posting-Host: fit.hosting.netcom.com X-NETCOM-Date: Mon May 17 2:36:54 PM PDT 1999 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news.maxwell.syr.edu!ix.netcom.com!not-for-mail In article <373b386b.0@news.wizvax.net>, >I was told twice for that reason. twice was long enough that by the time >the operator finished typing the second, the first would have finished >so quick operators wouldn't remove power before the writes finished. I wasn't taught that it had anything to do with time, but simply that the first sync had to return, so the second one could run, so that you were guaranteed that the first one had run before shutting down. Like, it would have been okay to have *any* command in place of the second sync, e.g., sync;echo;reboot -- James http://ssdd.conservatory.com