This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] PPC atomic.h add compare_exchange_val forms
- From: "Steve Munroe" <sjmunroe at us dot ibm dot com>
- To: "Kevin B. Hendricks" <kevin dot hendricks at sympatico dot ca>
- Cc: libc-alpha <libc-alpha at sources dot redhat dot com>
- Date: Tue, 15 Apr 2003 13:23:56 -0500
- Subject: Re: [PATCH] PPC atomic.h add compare_exchange_val forms
Kevin B. Hendricks writes:
> To be completely safe on ppc should all atomic types actually fill
> the entire cache line size of the cpu to prevent two separate atomic
> types from falling into the same cache line.
>
> If two threads ever compete for them neither may ever get the
> reservation clearly without the other one clearing it first and we
> could end up with some sort of strange live-lock situation?
As stated in my previous response there is a danger of "Live Lock" when
multiple locks share a "reservation unit" (for example a cache line).
So it is a good idea to avoid arrays of locks. But including a single lock
as a field in a larger structure is usually OK. Padding locks out to cache
line size is problematic since you don't know the cache line size at
compile time.