Quote:
Originally Posted by
sluge
Okay, let's start from the beginning:
When I run a process, it reserves some memory and use a subset of reserved memory.
So far, so correct. If more memory is requested than the system has then some pages are temporarily put into a part of the disk set aside - memory got "swapped out". There are are two strategies to do this, though:
When the program starts it justs requests the amount of memry it needs. It doesn't care if the kernel can meet these demands or not. If eventually the program has to be swapped out the kernel does so, but the program doesn't care. This is called "lazy" swap allocation and because swapping should happen only very rarely it has the advantag of being fast - the program doesn't bother to prepare for the rather unlikely occasion of being swapped.
Another strategy is this: when a program starts if anticipates the possibility of being swapped out. Therefore it makes the kernel allocate the space in the swap area it might need to be swapped out at start. Once it really gets swapped out it uses this space. This is called "early" swap allocation.
The advantage of this is that the swap space can hardly become overtaxed. This is why in previous times, when memory was scarce and swapping was quite usual, this was a sound strategy. But today swapping is rarely done and allocating space in swap one probably never needs anyway is just a waste of time.
For instance the AIX (IBMs UNIX) kernel used early swap allocation until version 4.3.3 (around 2001), then switched to lazy swap allocation with version 5L.
I hope this helps.
bakunin