views:

256

answers:

1

What happens if two pthreads are calling the msgsnd() function at the "same" time, posting message to the same message queue ?

What if two processes do the same ? Does it matter if they are threads or processes ?

Specifically interested for Linux 2.6.15-2.5 #1 SMP PREEMPT Tue Sep 19 10:56:25 CDT 2006 x86_64 x86_64 x86_64 GNU/Linux

+3  A: 

The man page for pthreads tells you want you want to know:

A thread-safe function is one that can be safely (i.e., it will deliver the same results regardless of whether it is) called from multiple threads at the same time.

POSIX.1-2001 and POSIX.1-2008 require that all functions specified in the standard shall be thread-safe...

msgsnd is amoung the functions defined by POSIX, and is not excluded from this requirement. It doesn't matter if it is two threads or two processes.

Chris Arguin