加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – msgsnd()线程和/或进程安全吗?

发布时间:2020-12-14 00:33:03 所属栏目:Linux 来源:网络整理
导读:如果两个pthreads在“相同”时间调用msgsnd()函数,将消息发送到同一消息队列会发生什么? 如果两个进程相同怎么办?它们是线程还是进程是否重要? 特别感兴趣的Linux 2.6.15-2.5#1 SMP PREEMPT Tue Sep 19 10:56:25 CDT 2006 x86_64 x86_64 x86_64 GNU / Lin
如果两个pthreads在“相同”时间调用msgsnd()函数,将消息发送到同一消息队列会发生什么?

如果两个进程相同怎么办?它们是线程还是进程是否重要?

特别感兴趣的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

解决方法

man page for pthreads告诉你你想知道什么:

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是POSIX定义的函数之一,不排除在此要求之外.它是两个线程还是两个进程并不重要.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读