[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: Vlad Georgescu <vgeorgescu_at_gmail.com>
Date: 2006-06-22 15:03:58 CEST

On 6/22/06, John Szakmeister <john@szakmeister.net> wrote:
>
> ----- 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

That was just a quick and dirty example, I didn't actually implement
it that way. I just adapted the stuff I found in
subversion/libsvn_fs_base/bdb/env.c: svn_fs_bdb__init, which was
similar to what I needed. The problem you described was solved by
calling apr_sleep() in the while loop.

-- 
Vlad
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jun 22 15:05:12 2006

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