gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:52:54 27 4
gpt4 key购买 nike

在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com