msgsnd()是线程安全和/或进程安全的吗? [英] Is msgsnd() thread- and/or process-safe?

查看:188
本文介绍了msgsnd()是线程安全和/或进程安全的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果两个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

推荐答案

The man page for pthreads tells you what 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和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()是线程安全和/或进程安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆