linux - 进程之间是如何共享代码段的?
高洛峰
高洛峰 2017-04-17 14:42:13
0
1
851

如果一个程序运行了两个实例,那么有两个进程,这两个进程应该共享代码吧。
但是网上虚拟地址空间的布局中,每个进程都有代码段。那么进程是怎么共享代码的?难道是后来产生的进程的代码段指向前面产生进程的代码段?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
巴扎黑

If a program runs two instances, unfortunately, the code of the two programs will not be shared, because the program code is loaded into the memory when the program is running. When the second program is started again, the system cannot The judgment will not determine whether the program is still the original program (if the program is updated or changed), so the program code will still be reloaded into another area of ​​memory.

The shared expression of

code should be in 链接库, especially in 动态链接库. Because the library is designed to be dynamically linked, the program can determine the memory address where the code is located after running, which allows multiple programs to call the same piece of code.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template