Re: Re: [PATCH] Fix the atomic compare and swap

"Carlos O'Donell" <[email protected]>
Newsgroups gmane.linux.ports.hppa
Message-ID <[email protected]>
On 5/21/07, John David Anglin <[email protected]> wrote:
> In the linuxthread case, user spinlock code would typically spin a
> few times and then call nanosleep.  If this fails a few times, the code
> calls sched_yield.  From a performance standpoint, I don't think it helps
> to waste time in the loop itself.

Yielding the cpu is intended to allow the other threads to make
progress on this or other cpus. It would be wasetful to busy wait your
entire time slice on your cpu, while another thread on another cpu is
doing an LWS CAS.

> On the otherhand, the atomic operations on the gateway page are short,
> and processes on the gateway page are never supposed to be scheduled
> off or sent signals.  So, I think a contended lock is only possible
> with a SMP kernel.

That is correct. A contended lock is only possible on SMP. This issue
only arose when we started using LWS CAS on the 64-bit SMP systems
available as debian build servers. A UP kernel never retruns EAGAIN.

> > I hadn't considered this code would be an external API, but I guess it
> > is... so these defines should probably go away and the constants
> > merged into the code?
>
> Yah, this just occurred to me.  It would be nice if the code could
> use EAGAIN from errno.h but I can see that that's a bit tricky.
> Possibly, a macro argument would work.

I don't want to be at the *whim* of users who might redefine EAGAIN. I
think the value should be fixed and immutable.

Comments?

Cheers,
Carlos.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.