c++ - sem_post(sem_t * sem) 和 sem_wait(sem_t * sem) 周围是否存在完整的内存屏障?

标签 c++ c linux

在 linux 代码中, 我记得听说 mutex_lock() 周围有一个完整的内存屏障。 我想确定它是否也在 sem_xxx 附近。

最佳答案

权威答案在这里:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11

Applications shall ensure that access to any memory location by more than one thread of control (threads or processes) is restricted such that no thread of control can read or modify a memory location while another thread of control may be modifying it. Such access is restricted using functions that synchronize thread execution and also synchronize memory with respect to other threads. The following functions synchronize memory with respect to other threads: ...

sem_waitsem_post 在列表中,所以它们是完整的内存屏障。

关于c++ - sem_post(sem_t * sem) 和 sem_wait(sem_t * sem) 周围是否存在完整的内存屏障?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16431679/

相关文章:

c++ - 如何重写控制台项目中的一行文本?由 小码哥发布于

c - 我想知道 c while 谓词中发生了什么?

c++ - VS2017 - 如何为远程调试配置项目

linux - 如何在 64 位 mac 上从源代码安装 tcpslice,为 fedora 发布?

c++ - 专门化模板类的模板化成员

c++ - 如何在具有 8 位成员的队列中前进并将对组合成 16 位值

c++ - 如何创建用于 QML 的通用对象模型?

c++ - emacs、etags 和使用 emacs 作为 IDE

c - 为什么调用 exit 函数会创建一个新的基本 block

mysql - 如何将 time_t 字段存储到 MySQL 日期时间?