[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Client-side support for Cyrus SASL

From: John Szakmeister <john_at_szakmeister.net>
Date: 2006-06-22 10:17:58 CEST

----- Vlad Georgescu <vgeorgescu@gmail.com> wrote:
[snip]
> I just realized APR has an atomic compare-and-swap function. So
> something along the lines of:
>
> static volatile apr_uint32_t init_started = 0, init_finished = 0;
>
> if (! apr_atomic_cas32(&init_started, 1, 0))
> {
> /* do initialization stuff */
> init_finished = 1;
> }
> else
> while (! init_finished)
> ;
>
> .. should do the trick.

I haven't been following your patches much, so I apologize if this has already been addressed. The while() statement is a busy wait, and generally isn't very processor friendly. I believe this code is really to protect only the multithreaded case, so a call to apr_thread_yield() might be a good thing in the while() loop. That'll at least give up execution time on that thread so that other things can happen (it's a little more friendly to the CPU).

-John

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jun 22 10:18:56 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.