by mm_freak on Fri Dec 16, 2005 7:36 am
Talking about Intel architectures, Linux, Windows and most other operating systems running in protected mode use virtual memory. This doesn't have to do with swap, though swapping is part of it.
Virtual memory means that programs cannot reference memory in an absolute way. They have no knowledge of the underlying memory structure, so in fact, you could run them from a tape device as the random access memory (it would be painfully slow and loud, but it would work). Instead of an absolute partition of the real physical memory they get what is called an own address space. In other words: they intentionally have their own, virtual memory.
The advantage is that the operating system can move RAM portions freely in memory and also save (swap) them elsewhere for later retrieval, while not changing the virtual address of those memory portions. It also prevents inter-process memory fiddling by design, because other processes are beyond the own address space.
Both in Windows and Linux there is something called an offset from the NULL address. So most Windows programs' address space will actually start at something like 0x400000. This causes programs dereferencing the NULL address to cause a memory protection fault. In Linux there is no default offset, so the operating system chooses one, which never is NULL, so NULL dereferences cause programs to crash by protection fault (called segmentation fault in Linux), too. All this is intentional, because NULL pointer dereferences are always indicating program bugs.
I'm x^10 + x^8 + x^5 + x^4 + x^3 + 1, so don't mess with me!