Re: The condition variable test
- From: Szabolcs Ferenczi <szabolcs.ferenczi@xxxxxxxxx>
- Date: Sun, 20 Apr 2008 15:22:13 -0700 (PDT)
On Apr 20, 10:50 pm, Markus Elfring <Markus.Elfr...@xxxxxx> wrote:
The main issue what you should understand is that the wait operation
of the condition variable can return right after the moment you call it.
Advanced synchronisation programmers are used to the wait loop for the handling
of spurious wakeups.
They simply have to use wait loop, they have no other choice, and not
only because the spurious wakeups. They have to use waiting loops
because what they are waiting for is the boolean expression to become
true and not any signal on the condition variable. So simple is that.
Besides, they must comply to the condition variable test too.
Higher level software libraries can make this
implementation detail easier and safer for monitors.
No question they can. However, they must themselves comply to the
test.
The message here is again that you cannot use the condition variable
so that you signal an event from one thread and await the signal in
another thread. You can use a semaphore that way but not any condition
variable.
Do not forget, the condition variable is not designed for that.
I would prefer further clarification from your view what can not be done by the
functions "pthread_cond_signal" or "pthread_cond_broadcast" in comparison to the
function "sem_post".
I am afraid I have clarified clear enough. You must try to follow.
Anyway, you can find a clear example about what cannot be done here:
http://groups.google.com/group/comp.programming.threads/msg/fc06ff81b98a9823
It is just surprising how many of you support the wrong usage and
attack me who highlights the problem. It is also amazing that you are
not able to follow simple working examples.
Best Regards,
Szabolcs
.
- Follow-Ups:
- Re: The condition variable test
- From: Markus Elfring
- Re: The condition variable test
- From: Chris Thomasson
- Re: The condition variable test
- References:
- The condition variable test
- From: Szabolcs Ferenczi
- Re: The condition variable test
- From: Markus Elfring
- Re: The condition variable test
- From: Szabolcs Ferenczi
- Re: The condition variable test
- From: David Schwartz
- Re: The condition variable test
- From: Szabolcs Ferenczi
- Re: The condition variable test
- From: Markus Elfring
- Re: The condition variable test
- From: Szabolcs Ferenczi
- Re: The condition variable test
- From: Markus Elfring
- The condition variable test
- Prev by Date: Re: The condition variable test
- Next by Date: Re: creating process
- Previous by thread: Re: The condition variable test
- Next by thread: Re: The condition variable test
- Index(es):
Relevant Pages
|