如何使用c ++在ubuntu中共享内存 [英] how to share memory in ubuntu using c++

查看:162
本文介绍了如何使用c ++在ubuntu中共享内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c ++在

how to share memory in ubuntu using c++

推荐答案

您可以使用POSIX共享内存对象(shm *)。请从这里开始: http://man7.org/linux/man-pages/man7/shm_overview。 7.html [ ^ ]。



对你来说是个好消息:Ubuntu并不特别针对Linux。另请参阅:

http://en.wikipedia.org/wiki/POSIX [ ^ ]。



-SA
You can use POSIX shared memory objects (shm*). Please start here: http://man7.org/linux/man-pages/man7/shm_overview.7.html[^].

Good news for you: nothing of this is specific to Ubuntu, and not even exclusively to Linux. Please see also:
http://en.wikipedia.org/wiki/POSIX[^].

—SA


这取决于您的需求。谢尔盖已经指出了如何在进程之间共享内存。

在另一种情况下,内存在同一进程的不同线程之间共享,你所要做的就是同步对它的访问(例如,参见在POSIX线程编程页面

Mutex变量
[ ^ ]。
It depends on your needs. Sergey already pointed out how to share memory between processes.
In another scenario, memory is shared between different threads of the same process and all you have to do is synchronize the access to it (see, for instance
"Mutex Variables" at POSIX Threads Programming page
[^].


这篇关于如何使用c ++在ubuntu中共享内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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