From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA23580; Tue, 6 Aug 2002 20:50:52 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA23744 for ; Tue, 6 Aug 2002 20:50:51 +0200 (MET DST) Received: from mail.eecs.harvard.edu (bowser.eecs.harvard.edu [140.247.60.24]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g76Ioj113978; Tue, 6 Aug 2002 20:50:46 +0200 (MET DST) Received: by mail.eecs.harvard.edu (Postfix, from userid 32018) id E9E7554C54A; Tue, 6 Aug 2002 14:50:44 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id E744454C634; Tue, 6 Aug 2002 14:50:44 -0400 (EDT) Date: Tue, 6 Aug 2002 14:50:44 -0400 (EDT) From: Lex Stein To: Bruno.Verlyck@inria.fr Cc: andrieu@ijm.jussieu.fr, , Subject: Re: [Caml-list] Sharing Files between OCaml and C In-Reply-To: <200208061401.g76E10K24093@waco.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On POSIX compliant systems, Dup() does not, in fact, create a new vnode for a file. It merely creates a new file descriptor table entry (in the process's in-kernel descriptor table) that points to exactly the same vnode. The two descriptors share the same buffered blocks in the global buffer cache. So if the C and Caml sides are sharing the same vnode, through dup'ed descriptors, it should be sufficient to flush once on either the Caml or C side. If however, the two references to the file are independently created using open, then the two descriptor table entries will point to *distinct* vnodes with independent buffering and duplicate flushing will be necessary (although one would have to be very careful not to overwrite changes made to the same block by the other side-- a motivator for using dup rather than open). Lex On Tue, 6 Aug 2002 Bruno.Verlyck@inria.fr wrote: > Yes, I think that's still the best method: > - get the descriptor with Unix.descr_of_in_channel or > Unix.descr_of_out_channel > - fdopen it on the C side > You might also want to call dup() on the fd so that your FILE* stream is still > working if the original caml channel is closed. > But of course you now have two concurrent buffering mechanisms, so flushing when > switching the writing side (C vs Caml) for out_channels is mandatory, and > seeking cautiously when switching the reading side (for in_channels) too. > > Bruno. > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners