From owner-freebsd-current Sun Sep 20 13:10:16 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA28585 for freebsd-current-outgoing; Sun, 20 Sep 1998 13:10:16 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA28521 for ; Sun, 20 Sep 1998 13:10:05 -0700 (PDT) (envelope-from tlambert@usr04.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id NAA03828; Sun, 20 Sep 1998 13:09:37 -0700 (MST) Received: from usr04.primenet.com(206.165.6.204) via SMTP by smtp01.primenet.com, id smtpd003812; Sun Sep 20 13:09:29 1998 Received: (from tlambert@localhost) by usr04.primenet.com (8.8.5/8.8.5) id NAA28679; Sun, 20 Sep 1998 13:09:27 -0700 (MST) From: Terry Lambert Message-Id: <199809202009.NAA28679@usr04.primenet.com> Subject: Re: pthreads and sync writes To: mal@algonet.se (Mats Lofkvist) Date: Sun, 20 Sep 1998 20:09:26 +0000 (GMT) Cc: freebsd-current@FreeBSD.ORG In-Reply-To: <199809201010.MAA21297@kairos> from "Mats Lofkvist" at Sep 20, 98 12:10:09 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Is it possible to do a sync write from a thread without blocking > the process completely? I have tried with open(O_FSYNC) and by > calling fsync() after writev(), but neither seem to make any other > thread runnable. The point of the system call is to block the caller until the caller is guaranteed that the cached contents of the file are the same as those on on disk (i.e., it flushes the write-through cache). This is a place where an async call gate would be useful. > Btw, O_FSYNC isn't documented in open.2. Then the man page is broken, since this has existed as an option to open(2) in UNIX for a very, very long time. > Fsync()ing also seems to be sligtly faster, is this an illusion or > is there a difference in the semantics? When you write to a file with O_FSYNC, the write does not return until the data has been committed. When you write to a file without O_FSYNC and subsequently call fsync(2) on the descriptors, all dirty buffers are written to disk. As a result, the second case will give better performance if your application is such that you can do multiple writes before calling fsync(2) without sacrificing data integrity in the process. What happens is, effectively, write-gathering. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message