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 に答える