Is global variable in a shared library / dll, shared across process

后端 未结 2 505
别那么骄傲
别那么骄傲 2020-12-16 01:48

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 clea

相关标签:
2条回答
  • 2020-12-16 02:24

    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?"

    0 讨论(0)
  • 2020-12-16 02:28

    Absolutely NO. Each process has its own virtual memory space and do not see memory of other processes. Two processes can even store different value at the same address, say 1000000 - because theirs virtual addresses "1000000" are mapped to different physical memory cells (for example to "2000000" for first process and to "3000000" for second. Shared dll does not change anything in this.

    0 讨论(0)
提交回复
热议问题