Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation

linux
2005-12-16T18:03:25Z

> Which would be totally pointless.
>
> If you have LL/SC, then the odds are you _don't_ have CMPXCHG, and that
> CMPXCHG is implemented using LL/SC, so what you end up with is:

Ah, you're not quite understanding what I wrote, but I see the confusion.

I took "turned into" to mean "ported to an architecture with the
other primitive", and intended it that when I said "turned back".
That's obviously pointless if you're emulating one with the other.

The point I was making is that, for any LL/SC sequence, there is an
exactly analagous LD/CMPXCHG version, so you never have to have more
CMPXCHGs than SCs.

This was an attempt to disprove your claim that LL/SC was better by more
than a very small factor.

It it possible to optimize for the contention-free case and do away
with the initial load, at the expense of an additional CMPXCHG in the
failure case.