caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Best way to synchronize OS processes?
Date: Tue, 11 May 2004 19:10:44 +0100	[thread overview]
Message-ID: <20040511181044.GA13360@redhat.com> (raw)
In-Reply-To: <40A115E3.1060400@frotz.com>

On Tue, May 11, 2004 at 11:05:23AM -0700, Ranjan Bagchi wrote:
> Hi --
> 
> I'm writing some code which will end up executing concurrently on 
> several OS processes.  I'd like to serialize access to some specific OS 
> resources (for instance, writing to a single file).  The Unix module 
> doesn't appear to offer anything like a critical section or an OS 
> mutex.  Is there a preferred way to do this? 

What about Unix.lockf?

Rich.

val lockf : file_descr -> lock_command -> int -> unit
(** [lockf fd cmd size] puts a lock on a region of the file opened
   as [fd]. The region starts at the current read/write position for
   [fd] (as set by {!Unix.lseek}), and extends [size] bytes forward if
   [size] is positive, [size] bytes backwards if [size] is negative,
   or to the end of the file if [size] is zero.
   A write lock (set with [F_LOCK] or [F_TLOCK]) prevents any other
   process from acquiring a read or write lock on the region.
   A read lock (set with [F_RLOCK] or [F_TRLOCK]) prevents any other
   process from acquiring a write lock on the region, but lets
   other processes acquire read locks on it. *)

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
If I have not seen as far as others, it is because I have been
standing in the footprints of giants.  -- from Usenet

-------------------
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


  parent reply	other threads:[~2004-05-11 18:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11 18:05 Ranjan Bagchi
2004-05-11 18:09 ` Shawn Wagner
2004-05-11 18:24   ` Ranjan Bagchi
2004-05-12  7:01     ` Jean-Christophe Filliatre
2004-05-12 16:35     ` Ranjan Bagchi
2004-05-12 11:27   ` Alex Baretta
2004-05-12 11:46     ` Ville-Pertti Keinonen
2004-05-12 13:16       ` Olivier Andrieu
2004-05-12 12:53     ` Gerd Stolpmann
2004-05-11 18:10 ` Richard Jones [this message]
2004-05-12 16:52 ` Shawn Wagner

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=20040511181044.GA13360@redhat.com \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    /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).