I think that they might override each other's data. I understand that two same virtual address spaces can be mapped to physical memory.
2 Answers
A. Most multiprocessing systems support the creation of shared memory where the block of physical memory can be mapped to multiple processes. Usually, the mapping can be to different virtual addresses.
B. All virtual memory systems share the same physical memory. However, the same page of physical memory cannot be mapped to multiple processes at the same time in user mode.
c. The kernel mode address space is usually the same for all processes. The operating system maintains that area of memory to prevent overwriting.

- 20,574
- 3
- 26
- 62
-
okay, and where the data of previous process is saved to , before there is a context switch by the kernel ? – Sharon182 May 12 '14 at 08:16
-
1. If the data is read only, it can just be discard. This is usually loaded from the executable image. 2) If the data is read/write it gets written to the page file. – user3344003 May 12 '14 at 16:52
-
but after it gets written to a page file , the second process (after context switch) can have an access to that page and override that data. Am i missing something ? – Sharon182 May 13 '14 at 07:31
-
It could have access to the page in physical memory; not the copy of page in the page file. – user3344003 May 13 '14 at 18:45
The question is not quite clear.
Assuming standard hardware, a virtual address space is determined by its page translation table. Thus if there are two translation tables, and they have entries with the same physical page number, then you have pages in both virtual spaces using the same physical page.
If the above situation holds for all entries in the translation tables you get two address spaces mapped to the same physical range.
The question is why would one want that.
If you want two different processes to actually work in this configuration, then they can't run in parallel (i.e., on two CPUs). Worse, before, say, proccess1 is scheduled one must make sure the contents of process1 memory are in place. This might require copying out process2 memory contents (to different memory addresses, disk, or whatever) and copying the contents of process1 memory back in.

- 323
- 1
- 5
-
-
Maybe you mean the following. It is common in nowadays OSes to map the kernel as part of a process address space. Hence this part of the virtual address space is identical across all processes. Similar thing happen if you run the same exe file (Windows) or do a fork (Unices). In this the code sections are also mapped to the same physical addresses. – Morass May 14 '14 at 12:02