Boost logo

Boost :

Subject: Re: [boost] [fiber] new version in vault
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2009-11-30 12:48:21


Helge Bahmann wrote:
> why would you ever want to use a mutex that does not properly inform the
> system scheduler until when the calling thread should be suspended (in
> case of contention) for "true" inter-thread (or even inter-process)
> coordination?

When you believe that the probability of contention is very small, and
you care only about average and not worst-case performance, and you
wish to avoid the overhead (e.g. time or code or data size) of
"properly informing" the system scheduler.

Earlier in this thread, Stefan Strasser wrote:
> a mutex template with a parameter on what to do to waste some time (this_fiber::yield,
> this_thread::yield, spinning...) could clean this up

Yes. I implemented something like this that could either spin, or call
sched_yield, or (on Linux) call futex_wait. It's basically a
Futex-based mutex that implements the other behaviours by replacing the
futex with something trivial. See
http://svn.chezphil.org/libpbe/trunk/include/Mutex.hh and Futex.hh,
Yield.hh, Spin.hh in the same directory. I've discussed the relative
performance of these things on this list in the past.

Regards, Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk