[SOLVED] When page's retrieved from swap, how does its application know new virtual a
During runtime when a program asks for a memory block (say, by malloc()), its provided with a block of virtual addresses, say 0x10000000 to 0x1000A00 (for 32 bit). During the execution, other processes are incorporated into the main memory and pages 0x10000000-0x100000A0 are paged out. After some time, the program requests the page 0x10000000. Its incorporated back into the main memory (at the cost of some other page) but its assigned a new virtual address, but the program is oblivious of the new virtual address assigned to it and references the it using 0x10000000. How is this problem resolved ? Does it proceed in any other way ?
Isn't virtual memory infinite (all processes can be assigned 2GiB)
Thanks. All this time, by page I was understanding the pages in the virtual memory table, though the pages in the memory were meant.
So, I get these things :
1. Any process larger than 2GiB can't be accommodated since each process is given only 2GiB virtual addresses.
2. If the swap space as well as the main memory gets filled up, the kernel gives an error saying "Virtual memory is low" (Actually, shouldn't it say that "swap is too small" as virtual memory is infinite)
3. The reason swap space is maintained is that if a page fault occurs, the page is first located in the swap space as compared to searching the entire hard disk. If its not found there, then the remaining hard disk is checked. This checking, though occurs just for the first time when the process is being loaded, because otherwise, the only reason for the page to be not present in either the swap or the main memory is that it has ended or the process has been killed.
4. Even when a process swaps out of the memory, the page table for that process does keep some info about where that page is in the swap
5. I take it that "increasing virtual memory" is actually a misnomer because virtual memory is infinite. What is meant is increasing the swap space.
Am I right?