public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Trenton D. Adams" <tadams@extremeeng.com>
To: "'eCos mailing list'" <ecos-discuss@sources.redhat.com>
Subject: [ECOS] Condition Variables recap
Date: Mon, 23 Jul 2001 15:17:00 -0000	[thread overview]
Message-ID: <001401c113c5$4de7b380$090110ac@TRENT> (raw)

Ok, below I describe condition variables as far as I know them.  I'm not
actually using them yet, I'm just preparing to use them.  Please tell me
if I'm wrong somewhere.  If I'm not wrong, a simple "Sounds good" will
be sufficient! :)

Main Program
I initialize the condition variable and corresponding mutex before
starting my threads.

Producer Thread
I lock the mutex in my producer thread before starting or resuming the
consumer threads.
When data is ready, I call cyg_cond_broadcast ().

Consumer Thread
Each consumer thread starts in a loop and checks the condition variable
by calling cyg_cond_wait ().
They will either be suspended, or one will succeed.
After the producer thread calls cyg_cond_broadcast (), ONE consumer
thread will lock the mutex, and begin reading data.
Now this thread should call cyg_mutex_unlock () which will cause another
ONE thread to lock it.


Now I have a question.  What happens to the cyg_cond_wait () call in the
OTHER consumer threads when cyg_cond_broadcast () is called?  Do they
simply get suspended, after that other ONE consumer thread locks the
mutex, and until the mutex is available to ONE of them again?

Trenton D. Adams
Embedded Developer
Windows Developer
Extreme Engineering Ltd.
Calgary Alberta.



             reply	other threads:[~2001-07-23 15:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-23 15:17 Trenton D. Adams [this message]
2001-07-23 17:55 ` Jonathan Larmour
2001-07-24 12:38   ` Trenton D. Adams
2001-07-24 12:48     ` Jonathan Larmour
2001-07-24 13:00       ` Trenton D. Adams
2001-07-24 13:17         ` Jonathan Larmour
2001-07-24 13:53           ` Trenton D. Adams
2001-07-24 14:08             ` Jonathan Larmour
2001-08-29 13:47           ` Trenton D. Adams
2001-08-30  3:45             ` Nick Garnett
2001-07-24 12:50     ` Gary Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001401c113c5$4de7b380$090110ac@TRENT' \
    --to=tadams@extremeeng.com \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).