From: Vandana on
Hello,

Can I use pthread_cond_wait & pthread_signal for IPC?

I am using fork to create 2 process. Can I use pthread_cond_wait &
pthread_signal to stall one of the process until the condition is set
by the other?

Thanks,
Vandana
From: David Schwartz on
On Apr 4, 12:24 pm, Vandana <nair...(a)gmail.com> wrote:
> Hello,
>
>    Can I use pthread_cond_wait & pthread_signal for IPC?
>
> I am using fork to create 2 process. Can I use pthread_cond_wait &
> pthread_signal to stall one of the process until the condition is set
> by the other?

Yes, just don't forget these things:

1) The mutex and condition variable must be set up in shared memory.

2) The mutex and condition variable must be set process shared when
they are initialized.

3) You must implement the condition that will be set yourself.
Functions like "pthread_cond_wait" are, despite their name, *not*
conditional waits. They are unconditional waits *for* a condition -- a
condition that you must implement.

DS