This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Condition Variables recap
- To: "Trenton D. Adams" <tadams at extremeeng dot com>
- Subject: Re: [ECOS] Condition Variables recap
- From: Jonathan Larmour <jlarmour at redhat dot com>
- Date: Tue, 24 Jul 2001 22:07:49 +0100
- Cc: 'eCos mailing list' <ecos-discuss at sources dot redhat dot com>
- Organization: Red Hat UK Ltd.
- References: <003b01c11482$a7880da0$090110ac@TRENT>
"Trenton D. Adams" wrote:
>
> > > WHY DO WE REQUIRE THE WHILE LOOP? ANY WAY THE
> > > CYG_COND_WAIT CANNOT PROCEED BEFORE IT OBTAINS THE
> > > MUTEX AND BROADCAST FROM THE PRODUCER AND OTHER
> > > THREADS?
> >
> > Two threads waiting on the condition may be woken up. They won't run
> at
> > the
> > same time since only one can have the mutex locked, but when the
> second
> > one
> > runs, the condition will not be true any more.
> >
>
> Does this mean that during cyg_cond_wait () an internal variable is set
> to FALSE?
No, the state of the condition variable doesn't necessarily reflect the
_actual_ state of the condition, that's why you have to retest.
> If so, then the next thread to continue inside it's
> cyg_cond_wait () will simply return because the condition variable is no
> longer valid?
It will lock the mutex though - as all cyg_cond_wait()'s must do on return,
so it won't block immediately.
> > > ALSO COULD ANYONE EXPLAIN - WHAT IS THE VARIABLE IN
> > > THE WHILE LOOP. WHAT DOES IT TEST?
> >
> > The condition you are waiting for...
> >
>
> The condition_not_true statement must contain a variable that I make for
> testing whether the loop should continue or not, and I would set this
> variable to true after one of the consumer threads finished using the
> resource! Correct?
Generally the condition is more like "is there data available to read" and
so on.
Jifl
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions http://www.redhat-techworld.com/