0

Expert C ProgrammingP101一书中,有一段话:

For example, if you have eight XViewTM applications running, only one copy of the XView library text segment has to be mapped into memory. The first process's mmap [1] call will result in the kernel mapping the shared object into memory. The next seven process mmaps will cause the kernel to share the existing mapping in each process. Each of the eight processes will share one copy of the XView library in memory. If the library were statically linked, there would be eight individual copies consuming more physical memory and causing more paging.

由于 mmap 只返回内存的指针,我想知道如何使用变量或调用库中定义的方法?

4

1 回答 1

1

这是描述系统自动使用的机制。除了将您的程序与共享库链接以利用此共享之外,您无需执行任何操作。您当然不需要调用mmap()自己,或者弄清楚如何以某种特殊方式调用函数。

于 2012-12-10T10:31:28.963 回答