English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Best way to synchronize OS processes?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-12 (11:26)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Best way to synchronize OS processes?
Shawn Wagner wrote:
> 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?
> File locking with Unix.lockf?

I disagree. I faced the same problem and found that it cannot be easily 
solved with lockf. Unix.lockf locks specific regions in a file, whereas 
Ranjan seems to need the equivalent of a mutex, which should be 
implemented as a lock over the entire file. This is done by the flock 
primitive in Posix systems. Unluckily, flock has not been included in 
the Unix module.

I have written my own Flock module, which might be useful to Rajan. It 
supports locking Pervasive channels as well as locking the underlying 
file descriptors. I have sent it to Caml team as a contribution to the 
Unix module, but apparently it was not accepted.

I'm willing to send it to anyone requesting it. Note that it is released 
under the GPL--not the LGPL--so licensing issues might arise.


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