This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Methods for "signalling" other threads?


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






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]