Re: Inter Thread Coomunication

From: Clemens Ladisch
Date: Wed Dec 02 2009 - 07:37:03 EST


Mai Daftedar wrote:
> I have a question to ask I have two threads that have
> messages(Structure with data) that should be passed between them.
> After some googling I learnt that using queues and pipes are expensive
> (effieciency wise) and that I should just pass in the parameters and
> use mutex to protect shared data...

What is expensive is not necessarily the copying of the data into and
out of the pipe (this depends on the amount of data), but the system
calls necessary for this. If your threads use mutexes to wait for the
data, you have system calls anyway (actually going to sleep and waking
up cannot be handled in userspace), so there might not be any difference
one way or the other. The only way to find out is to test both
mechanisms.


HTH
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/