问题描述
如果两个pthread在相同"时间调用msgsnd()函数并将消息发布到同一消息队列中会发生什么?
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 ?
对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
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
推荐答案
pthread的手册页告诉您您想了解的内容:
The man page for pthreads tells you what you want to know:
POSIX.1-2001和POSIX.1-2008要求标准中指定的所有功能都必须是线程安全的...
POSIX.1-2001 and POSIX.1-2008 require that all functions specified in the standard shall be thread-safe...
msgsnd
是POSIX定义的功能之一,不排除在此要求之外.是两个线程还是两个进程都没关系.
msgsnd
is among the functions defined by POSIX, and is not excluded from this requirement. It doesn't matter if it is two threads or two processes.
这篇关于msgsnd()是线程安全和/或进程安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!