View Single Post
  #4   (View Single Post)  
Old 9th July 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

@OP, Let's expand on this concept... each process has access to it's own "virtual" address space, 4GB on a 32bit architecture.

When a program "allocates" memory, i.e: malloc(3), it's actually requesting that "x" amount of memory be mapped into it's address space. (Because, most of it is empty space, i.e: unmapped..).

Now, allocated memory doesn't always need to stay in RAM, The kernel is free to "relocate" it into the swap space on your hard drive.

If the program attempts to access the memory that was swapped, a "page fault" occurs, causing the kernel to halt the process, and reload the data back into RAM.

The benefits of this are clear...
Reply With Quote