Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Olivier Andrieu <andrieu@i...>
Subject: Re: [Caml-list] Best way to synchronize OS processes?
 Ville-Pertti Keinonen [Wed, 12 May 2004]:
 > 
 > On May 12, 2004, at 2:27 PM, Alex Baretta wrote:
 > 
 > > 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.
 > 
 > Actually flock is non-POSIX (it's BSD) and is missing from some 
 > reasonably modern systems.
 > 
 > It's entirely possible to lock the entire file using the fcntl used by 
 > Unix.lockf, making it equivalent to flock.  

They are not *exactly* equivalent: flock does not work on NFS
filesystems whereas fnctl does, and they have different behaviour with
exec or dup I believe.

 > The problem is that the OCaml Unix module doesn't allow the
 > l_whence parameter to be set, which is a serious omission.

Well, it follows the lockf API, which starts the lock at the current
file position. You could use lseek to reposition it but this may confuse
a Pervasives channel buffering this file.

By the way, lockf can block, waiting for a lock. Shouldn't there be
some enter_blocking_section()/leave_blocking_section() somewhere ?

-- 
   Olivier

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