是共享库/ DLL中的全局变量,跨进程共享 [英] Is global variable in a shared library / dll, shared across process

查看:155
本文介绍了是共享库/ DLL中的全局变量,跨进程共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个共享库(.so)和dll。我有一个在多个线程中更新的全局变量。所以我有互斥锁用于同步。



我不清楚共享库中的全局数据是否在整个过程中共享。如果是那么我需要使用信号量来进行同步。据了解,全局变量是数据段的一部分,因此我想了解dll如何管理跨进程的全局数据。任何信息w.r.t. dll格式和段将是有帮助的。



谢谢。

解决方案

默认情况下,不会,跨进程共享全局变量。



但是,您可以使用数据段(data_seg)来跨进程共享全局变量。有关MSDN的更多信息,请参见如何我可以使用应用程序或其他DLL共享我的DLL中的数据吗?


I am developing a shared library(.so) and dll. I have a global variable which is updated in multiple threads. So I have mutex lock for synchronization.

I am not clear whether global data in shared library is shared across process. If it is then I need to use semaphores for synchronization. As I understand global variables are part of data segment so I wanted to understand how dll manages the global data across processes. Any information w.r.t. dll format and segment will be helpful.

Thanks.

解决方案

By default, no, global variables are not shared across processes.

However, you can use a data segment (data_seg) in order to share global variables across processes. You can find more information on MSDN in the article titled "How do I share data in my DLL with an application or with other DLLs?"

这篇关于是共享库/ DLL中的全局变量,跨进程共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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