Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
Max, thanks heaps for the blog, you pointed me to. Been reading it for last half-a-week, very clear and informative! –  Bob Jan 12 '13 at 18:33
add comment

“Own virtual address space” actually means the opposite of what you say: it means that the address 11111111 points to a different location in physical memory in every process. If virtual addresses corresponded to the same physical address in different processes, then the processes would share an address space. In fact, some of the address space is shared between several processes (for example, after fork, almost all pages are shared between the parent and the child). This corresponds to your “case 2” picture. Linux and Windows are not different in this respect.

Linux can actually run (in a degraded mode, which among others doesn't support fork) on some small embedded devices that have no MMU, only an MPU (memory protection unit). On such devices, there are no virtual address spaces (case 2), but there is still separation between processes, because each process has its own set of permissions over the memory pages.

share|improve this answer
    
A nice article about MMU, thanks, Gilles. –  Bob Jan 12 '13 at 18:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.