Subject: Re: ingres and atomicity
From: David Laight <email@example.com>
Date: 06/15/2005 07:50:28
On Tue, Jun 14, 2005 at 09:07:43PM -0400, der Mouse wrote:
> There is a good deal of research among OS theorists on implementing
> locking without hardware-assisted locking primitives. I once did a
> little reading and thought about it and convinced myself that with some
> fairly weak assumptions (basically, that you have a data type holding
> at least one bit of information which can be read and written such that
> reads and writes appear to occur atomically in some order), it was
> possible to construct locking among semi-arbitrary numbers of
> cooperating accessors.
There is standard algorithm for it (Knuth will have a fancy name, I wrote
it once when I needed it!).
However some architectures (eg sparc) do not give you the required
sequencing of reads and writes - so any such attempt is doomed to failure.
I did once try to write a 'self-locking' counter using an atomic exchange
instruction, but found that the 3-way race stopped you knowing when it was
David Laight: firstname.lastname@example.org