The ROMIO implementation of the MPI-IO standard provides a portable infrastructure
for use on top of a variety of underlying storage targets. These targets vary widely
in their capabilities, and in some cases additional effort is needed within ROMIO to
support all MPI-IO semantics. Two aspects of the interface that can be problematic
to implement are MPI-IO atomic mode and the shared file pointer
access routines. Atomic mode requires enforcing strict consistency semantics, and
shared file pointer routines require communication and coordination in order to
atomically update a shared resource. For some file systems, native locks may be used
to implement these features, but not all file systems have lock support. In this
work, we describe algorithms for implementing efficient mutex locks using MPI-1 and
the one-sided capabilities from MPI-2. We then show how these algorithms may be used
to implement both MPI-IO atomic mode and shared file pointer methods for ROMIO
without requiring any features from the underlying file system. We show that these
algorithms can outperform traditional file system lock approaches. Because of the
portable nature of these algorithms, they are likely useful in a variety of
situations where distributed locking or coordination is needed in the MPI-2 environment.