是共享库/ DLL中的全局变量,跨进程共享 [英] Is global variable in a shared library / dll, shared across process
问题描述
我不清楚共享库中的全局数据是否在整个过程中共享。如果是那么我需要使用信号量来进行同步。据了解,全局变量是数据段的一部分,因此我想了解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屋!