[Rd] File lock mechanisms in R

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jul 3 10:29:03 CEST 2007


On Mon, 2 Jul 2007, Henrik Bengtsson wrote:

> Hi,
>
> is there a (cross-platform) file-locking mechanism available in R (or
> via some package)?

I don't believe there really is a cross-platform file-locking mechanism 
available to any language.  File-locking is an OS feature, and the 
semantics differ.  For those unfamiliar with this, the Wikipedia article 
is a good start (but ignores the POSIX lockf interface).

> I am looking for a way to have one R session lock a file for
> read/write access, while being updated/modified by another R session.
> This will provide me with a-poor-mans parallelization method.  It is
> ok to have so called advisory looking (as in Unix), which are
> non-mandatory to follow.  If not available, I'll use lock files, but
> there are some potential problems in creating such in an atomic way.

Depends what you mean by 'atomic'.  In R, the only way to have 
non-interruptible operations is via .Call or similar: the evaluator is 
interruptible at all times so it seems that this issue applies equally to 
all file locking from R.

> Ideally I wish to have this working on all platforms.
>
> Cheers
>
> Henrik
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list