在Linux中动态库是否共享全局变量 [英] does dynamic library shared global variable in linux

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

问题描述

我们知道,Linux调用ldconfig加载所有*.so库,然后链接使用共享库的应用程序.但是,我很困惑在这种情况下全局变量是如何工作的.由于在所有这些应用程序中共享库只有一个副本,因此它们共享共享库中的全局变量吗?如果是,那么它们如何同步?

As we know, linux call ldconfig to load all *.so libraries and then link the applications who use the shared library. However, I am confused how the global variable is working in this case. Since there is only one copy of shared library across all these application, do they share the global variables in the shared library? If yes, then how they synchronize?

谢谢

推荐答案

否,它不是共享的-库的代码/文本部分是共享的-数据部分对于使用该库的每个进程都是唯一的

No it is not shared - the code/text section of the library is shared - the data portion is unique to each process that uses the library

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

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