I wonder why (on an SP machine) you don't just disable interrupts for a few instructions and give yourself an atomic dec?
On Wed, Aug 12, 2009 at 9:30 AM, Jamie Lokier <ja...@shareable.org> wrote: > Michael Schnell wrote: > > >> Seemingly the best instruction to handle these bits is "atomic compare > > >> and exchange" (e.g. provided by the X86 CPU). > > > > > > It's actually not the best, because when it returns "did not match" > > > you have to loop and try again. > > > > The supposedly "best" user space implementation for the X86 I found (in > > "Futexes are Tricky") uses both "atomic_compare_and_exchange" and > > "atomic_exchange" for the lock part and "atomic_dec" for the unlock part. > > That's right. It's possible to use atomic_compare_and_exchange for > unlock; it's correct. But you get that extra bit of spinning with SMP, > so atomic_dec is better. > > -- Jamie > > _______________________________________________ > uClinux-dev mailing list > uClinux-dev@uclinux.org > http://mailman.uclinux.org/mailman/listinfo/uclinux-dev > This message was resent by uclinux-dev@uclinux.org > To unsubscribe see: > http://mailman.uclinux.org/mailman/options/uclinux-dev >
_______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev