Re: multiple threads consuming same list?
- From: Szabolcs Ferenczi <szabolcs.ferenczi@xxxxxxxxx>
- Date: Wed, 13 Jun 2007 07:10:48 -0000
On Jun 13, 1:10 am, Steve Watt <steve.removet...@xxxxxxxx> wrote:
So, after 20 items, the producer will block on the condition variable
waiting for space in the buffer. 20 consumers will be scheduled to
run, but will most likely not have progressed beyond re-locking the
buffer mutex. So 30 consumers are still waiting for the condition to
be signalled with "not empty", and the producer is waiting on the same
condition, but for "not full" to be signalled. You're now in an area
where you must use cv_broadcast rather than cv_signal.
Ok. Now you have rung the bell. The point is that I thought it was a
monitor built from mutex and condition variable. It is not a monitor
since the semantics of the condition variable is not like what is
defined for the monitors.
In my interpretation the situation can occur because a signal on the
condition variable does not guarantee that the signalled thread re-
gains access to the shared data structure _before_ any other threads
that would just enter the `monitor' via the mutex. If the awakened
thread is delayed for some longer time after waking up from a
condition wait, other threads can gain access to the same shared data
in the meantime. This is the point the test should exercise, which is
not trivial how to do. Now I have some idea how to do it.
Thanks,
Szabolcs
.
- References:
- multiple threads consuming same list?
- From: Ricky Nelson
- Re: multiple threads consuming same list?
- From: Torsten Robitzki
- Re: multiple threads consuming same list?
- From: Steve Watt
- Re: multiple threads consuming same list?
- From: Szabolcs Ferenczi
- Re: multiple threads consuming same list?
- From: Steve Watt
- multiple threads consuming same list?
- Prev by Date: Re: Question about x86 memory model
- Next by Date: Re: Create a thread not in runnable state in POSIX thread
- Previous by thread: Re: multiple threads consuming same list?
- Next by thread: Re: multiple threads consuming same list?
- Index(es):
Relevant Pages
|