public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Arash Partow <arash@partow.net>
To: pthreads-win32@sources.redhat.com
Subject: Re: Methods for "signalling" other threads?
Date: Tue, 25 Oct 2005 23:58:00 -0000	[thread overview]
Message-ID: <435EC68D.8040800@partow.net> (raw)
In-Reply-To: <20051025155621.14418.qmail@web53101.mail.yahoo.com>

Hi Mark,

I have a simple library that takes care of threaded producer consumer
oriented patterns. It lacks documentation, but the code itself is
pretty straight forward.

I think you would be most interested in the chain pattern, where you
would have one entity (threaded) or link in the chain so to speak
continually reading from the serial port (until some break condition
is met), that then dumps the data its read onto the prod-con link, the
next entity(also threaded) in the chain would try to reconstruct
frames from the data and the 3rd entity would process the frames and
do something useful. All these entities would be working
asynchronously and would only go to sleep when there was no more work
for them to be done. they would only wake up once there was some data
on link going into them.

A simple example would be the 2nd entity, the frame constructor, would
go into a conditional sleep when the data producer (the serial port
reader thread) was not getting anymore data off the serial port. The
3rd entity which would be the frame processor would go to sleep only
when it had finished processing all the outstanding frames created by
the frame constructor etc...


http://www.partow.net/programming/producerconsumer/index.html




Arash Partow
________________________________________________________
Be one who knows what they don't know,
Instead of being one who knows not what they don't know,
Thinking they know everything about all things.
http://www.partow.net



Mark Nowhere wrote:

>Hi,
>    Just a quick question. I have a serial
>reader/writer thread and an network reader/writer
>thread. Basically I want the serial thread to, once
>new data has come in from the COMM port signal the
>network thread in some way to get it to pick up the
>data and send it over the network. Just not sure what
>I should use to get this effect?
>
>Options I can see are:
>
>Semaphores
>or 
>pthread_cond_signal/pthread_cond_wait stuff
>or 
>something else :)
>
>Many thanks for any advice
>
>Mark
>
>
>  
>

      parent reply	other threads:[~2005-10-25 23:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-25 15:56 Mark Nowhere
2005-10-25 17:20 ` Ronny Pfannschmidt
2005-10-25 23:58 ` Arash Partow [this message]

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=435EC68D.8040800@partow.net \
    --to=arash@partow.net \
    --cc=pthreads-win32@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).