Synchronizing Threads: newbie question

I have a situation in QNX 6.1 where I am attempting to synchronize a single
thread with incoming data from two threads. The two threads that generate
data are interrupt driven and timing is critical. I want to awaken the
receiving thread whenever an event is generated by either of the two
interrupt threads. The receiving thread is timing the rate at which the
other two threads awaken it.

I don’t see a way to have a thread block on either of two events, so what
I’ve done is the following with a single mutex and single condvar shared
between the interrupt threads.

pseudo code of receiving thread:

while 1
mutex_lock
while no_data1 and no_data2
condvar_wait
if data_1
do data_1 stuff
if data_2
do data_2 stuff
condvar_signal
mutex_unlock
end while

Thanks in advance,

Jason Farque

Jason Farque wrote:

I have a situation in QNX 6.1 where I am attempting to synchronize a single
thread with incoming data from two threads. The two threads that generate
data are interrupt driven and timing is critical. I want to awaken the
receiving thread whenever an event is generated by either of the two
interrupt threads. The receiving thread is timing the rate at which the
other two threads awaken it.

I don’t see a way to have a thread block on either of two events, so what
I’ve done is the following with a single mutex and single condvar shared
between the interrupt threads.

There is a simple way to block on either of two events in this case;
simply emit different pulses from the two “interrupt” threads, and have
the “receive” thread do a MsgReceive.