0
votes

Normally, the process memory map consists of stack, text, data+bss and heap.

The memory address is independent to other processes except text section.

My question is about in text section, is there only child process could share

the same text section with its parent process? or other processes could share it too.

======================================================================

@avd: yes, refer to the wikipedia

http://en.wikipedia.org/wiki/Process_isolation

"Process isolation can be implemented by with virtual address space, where process A's address space is different from process B's address space - preventing A to write into B."

This is what I mean to each process has its own memory map.

However, when I read the OS book, it mentions that the text section could be shared. So I am not very clear with this or probably I misunderstood that part of the book.

====================================================================== Extra information:

http://www.hep.wisc.edu/~pinghc/Process_Memory.htm

Processes share the text segment if a second copy of the program is to be executed concurrently. In this setting, the system references the previously loaded text segment with the pointer rather than reloading a duplicated. If needed, shared text, which is the default when using the C/C++ compiler, can be turned off by using the -N option on the compile time.

1
Could you elaborate on what you mean by "The memory address is independent to other processes except text section." ?Alexander Dzyoba

1 Answers

1
votes

Every process has it's very own virtual addresses. That virtual address is not shared with anybody including child process. But these virtual addresses are translated or, in other words, mapped to physical addresses by OS kernel and MMU.

The thing is that virtual addresses from different address spaces can point to the same physical addresses! For example, when process forked, it gets its own virtual address space, but unless this child process is not changing (writing) to it's memory it shares memory with parent process for reading. When child process will try to modify some memory kernel will create separate own copy of particular page for child process and it will not be shared anymore (until child process forked itself). This is known as Copy on Write (CoW).

So the real thing is that text section could be shared by mapping different virtual pages to the same physical pages (called frames).