[Python-Dev] RE: [Thread-SIG] Re: marking shared-ness

Bill Tutt billtut@microsoft.com
Wed, 19 Apr 2000 14:28:12 -0700


> From: Christian Tismer [mailto:tismer@tismer.com]

> Are atomic decrements really so cheap, meaning "are they mapped
> to the atomic dec opcode"?
> Then this is all ok IMHO.
> 

On x86en they are mapped to an "atomic assembly fragment" i.e. params to
some registers and then stick in a "lock add" instruction or something.
(please forgive me if I've botched the details). So in that respect they are
cheap, its a hardware level feature. On the otherhand though, given the
effect that these instructions have on the CPU (its caches, buses, and so
forth) it is by for no means free. 

My recollection vaguely recalls someone saying that all the platforms NT has
supported so far has had at the minimum an InterlockedInc/Dec.
InterlockCompareExchange() is where I think not all of the Intel family
(386) and some of the other platforms may not have had the appropriate
instructions.

InterlockCompareExchange() is useful for creating your own spinlocks. The
GCC list might be a good place for enquiring about the feasability of
InterlockedInc/Dec on various platforms.

Bill