Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!nuug!ifi!steinar From: steinar@ifi.uio.no (Steinar Kj{rnsr|d) Newsgroups: comp.unix.internals Subject: What does sync() _really_ do? Message-ID: Date: 13 Dec 90 11:31:07 GMT Sender: steinar@ifi.uio.no (Steinar Kj{rnsr|d) Organization: Dept. of Informatics, University in Oslo, Norway Lines: 47 Nntp-Posting-Host: fram.ifi.uio.no Originator: steinar@fram.ifi.uio.no The above subject and imposed question may seem trivial, but I have so far failed to find the answer (I browsed through the 4.3 book by McKusick, Karels and Quarterman, references to pertinent pages here are welcome). The question arised when a disk vendor presented results from a benchmark which purpose was to measure read/write transfer rates for his drive. His scenario was this: - a stand alone BSD (SunOS 4.0.3 I think) box in single user mode - no other disk activity in the system The test program looked something like this: - - sync(); sync(); sync(); - Both read and write of the file use normal IO (asynchronous) operations which therefore involves the buffer cache. The disk vendor's assumption is that the three sync() calls will guarantee that the read pass of the test will read data off the media, not from the buffer cache, while I say that although the sync() calls force dirty pages in the buffer cache to be written to the disk, you have no guarantee that those pages also will be wiped out from the cache. I find this especially true since there are no other disk activity in the system at the time when the test is running. What would be the purpose of really clearing the cache when you have nothing to replace the cleared pages with? Who are right? +==================================================================+ ! ! ! Steinar Kjaernsroed, ! ! Dpt. of Informatics, ! ! University of Oslo, ! ! P.O.Box 1080, Blindern, ! ! 0316, Oslo 3, ! ! NORWAY ! ! ! ! Phone: 047+2+453460 (work), ! ! Email: steinar@ifi.uio.no (Internet) ! ! ..!mcsun!ifi!steinar (UUCP) ! ! ! +==================================================================+