Skip to content

跨进程shm存放rw_lock/spin_lock是否安全 #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sixsixQAQ opened this issue Apr 15, 2025 · 1 comment
Open

跨进程shm存放rw_lock/spin_lock是否安全 #143

sixsixQAQ opened this issue Apr 15, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@sixsixQAQ
Copy link

sixsixQAQ commented Apr 15, 2025

看到rw_lock和spin_lock好像可以直接放到共享内存shm中,用来同步不同进程的访问。

比较担心不同进程(32位/64位)中rw_lock和spin_lock 的结构体对齐/布局不一致,以及版本兼容问题。

希望可以提供例子,或者更多文档描述。

@sixsixQAQ sixsixQAQ changed the title 不同进程shm中用rw_lock和spin_lock是否安全 跨进程shm存放rw_lock/spin_lock是否安全 Apr 15, 2025
@mutouyun
Copy link
Owner

rw_lock和spin_lock不能混用。目前代码里32位/64位混用确实会出问题,之前疏忽了,内部字段改为uint32_t会更好些。我提个pr吧。
参考:https://www.reddit.com/r/cprogramming/comments/uja192/size_of_unsigned_long_on_32bit_and_64bit_system/

@mutouyun mutouyun added the bug Something isn't working label Apr 20, 2025
mutouyun added a commit that referenced this issue Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants