Boost logo

Boost Users :

From: svanechel (svanechel_at_[hidden])
Date: 2002-02-25 05:12:32


[...]

> First, note that this scheme is very prone to starvation problems.
> If an operation "type" acquires the "lock" and there are several
> threads that will also acquire this same "type" in a loop, it may
> very well be that the "lock" is never relinquished for the
> other "types" to acquire it. RW locks are a little tricky to
> implement because of this issue.
>

Can you elaborate a bit more on that one, help me to understand. Is
there any way out of this problem? How can I prevent it?

[...]
>
> You didn't use boost::condition incorrectly, you used the
> scoped_lock<> incorrectly. Fixing this, though, still leaves you
> with a questionable synchronization scheme that's prone to
starvation.
>

Odly enough I alway use scoped_lock they way it is intended to be
used. I got a confused when reading through the documentation of
boost::condition and how condition::wait affects the lock. Thanks to
your comments I got it working and it behaves as I expect it would. I
would surely appreciate if you (or someone else) could futher clarify
the starvation problem.

Sven


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net