Reputation: 1
I know for DLL, the executable is shared among processes. But for a user defined program, let's call it "test", when I run "test" on two terminals. Is the program executable going to be shared for these two processes, or does each one get a separate copy? Thanks.
Upvotes: 0
Views: 1356
Reputation: 2776
The Text Section is shared (the code), the heap is not shared.
Whatever is loaded from disk, will share the disk cache.
@alvits is right in saying the heap will be duplicated on fork but it is done with Copy On Write (COW), meaning it is duplicated when needed, if data does not change, it does not occupy new memory.
This answer is similar: how is a shared library file called by two different processes in Linux?
Upvotes: 0
Reputation: 3141
First the file is copied to kernel's page cache. When it is in already, then the second run will use this cached one. One cache per one file.
Upvotes: 1