Misleading explanation of Virtual Memory in TLDP

kernelvirtual-memory

I'm completely confused about explanation of virtual memory in TLDP:

http://www.tldp.org/LDP/tlk/kernel/processes.html#tthFtNtAAB

They say:

Each individual process runs in its own virtual address space and is not capable of interacting with another process except through secure, kernel managed mechanisms.

"Own virtual address space" for me reads as own 4Gb RAM in 32-bit mode: 0000:0000 – FFFF:FFFF. But they didn't mean that, right? If two processes point to virtual address 1111:1111, they mean the same physical address, so the same 4 Gb virtual address space is shared by all processes?

Besides, I've read about Windows here, that they really have individual virtual address spaces for each process, separate 2Gb RAM for user mode and shared 2Gb for kernel mode, so 2 different processes can both point to 1111:1111, which maps to different physical memory. Do they? 🙂

UPDATE: illustrations to my question. Which of the pictures is right for Linux:

Case 1:
enter image description here

Case 2
enter image description here

Best Answer

Linux as well as Windows, work pretty much the same here. Every process gets it's own "virtual" address space. This doesn't mean that the memory is actually physically available (obviously most 32bit computers never had enough memory), that's, why it's virtual.

Also the addresses used there don't correspond to the physical addresses. Thereby physical memory segment at AAAA:0000 could correspond to 9128:2af2, the point is you don't have to care. All an application is concerned with is where the thing of interest resides in it's own memory segment. And yes that also means that two applications can point to the same address in their own view of the memory and get different things.

There are also a lot of interesting things that could be mapped into there other than an actual physical memory page of the process, for example addresses belonging to devices (think video card), dynamically linked libraries or memory that's shared between processes (that's part of what's meant by "secure, kernel managed mechanisms").

Let me recommend you a textbook like Tanenbaum, Operating systems, if you want to delve a little deeper into virtual memory and process address space layout or if you can't get a hold of one easily http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory also makes a good read.

Related Question