lkml.org 
[lkml]   [2005]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
> Now my point about using LL/SC is that:
>
> 1,C,A cmpxchg(0,1) [failed]
> 1,C,A cmpxchg(1,3) [success]
> 3,C,A ...
>
> Can be turned into:
>
> 1,C,A x = LL()
> 1,C,A x |= 2;
> 1,C,A SC(3) [success]
> 3,C,A ...

... which can be turned back into

1,C,A x = load()
1,C,A x' = x | 2;
1,C,A cmpxchg(x,x') [success]
3,C,A ...

which will fail and retry in exactly the same contention cases as the
LL/SC. The only thing that LL gives you that's nice is a hint that
an SC is due very soon and so resisting a cache eviction for a couple
of cycles might be a good idea.

The reason that we tend to do the former is optimism that the lock
won't be held. If that's a bad assumption, make it more pessimistic.

LL/SC can detect double changes during the critical section, but it's
very similar in expressive power to load + CMPXCHG.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-16 13:52    [W:0.035 / U:0.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site