caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Lex Stein <stein@eecs.harvard.edu>
To: Bruno.Verlyck@inria.fr
Cc: andrieu@ijm.jussieu.fr, <mtucker@eecs.harvard.edu>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Sharing Files between OCaml and C
Date: Tue, 6 Aug 2002 14:50:44 -0400 (EDT)	[thread overview]
Message-ID: <Pine.BSF.4.44.0208061440360.38687-100000@bowser.eecs.harvard.edu> (raw)
In-Reply-To: <200208061401.g76E10K24093@waco.inria.fr>


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


  reply	other threads:[~2002-08-06 18:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05  9:26 [Caml-list] Matching when Nicolas Cannasse
2002-08-05  9:41 ` Luc Maranget
2002-08-05 16:13   ` John Max Skaller
2002-08-05 19:29     ` Luc Maranget
2002-08-05 20:16       ` [Caml-list] Sharing Files between OCaml and C Michael Tucker
2002-08-06 13:04         ` Olivier Andrieu
2002-08-06 14:01           ` Bruno.Verlyck
2002-08-06 18:50             ` Lex Stein [this message]
2002-08-07 11:40               ` Bruno.Verlyck
2002-08-05 13:05 ` [Caml-list] Matching when Pierre Weis
2002-08-05 15:50 ` John Max Skaller
2002-08-05 16:02 ` Remi VANICAT
2002-08-05 16:23   ` John Max Skaller
2002-08-05 18:25 ` Oleg
2002-08-06  6:37   ` Florian Hars

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.BSF.4.44.0208061440360.38687-100000@bowser.eecs.harvard.edu \
    --to=stein@eecs.harvard.edu \
    --cc=Bruno.Verlyck@inria.fr \
    --cc=andrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=mtucker@eecs.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).