I am reading < Windows via C/C++ > and here's some quotation.
When a process is created and given its address space, the bulk of this usable address space is free, or unallocated. To use portions of this address space, you must allocate regions within it by calling VirtualAlloc. The act of allocating a region is called reserving.
To use a reserved region of address space, you must allocate physical storage and then map this storage to the reserved region. This process is called committing physical storage.
After you have reserved a region, you need to commit physical storage to the region before you can access the memory addresses contained within it. The system allocates physical storage committed to a region from the system's paging file.
Here are a couple of questions:
Why do we need to follow the reserve-comit paradigm when using memory? i.e. Why do we need to follow this 2-step paradigm instead of allocating some physical memory directly and use it?
If the the physical storage committed to a region is allocated from the system's paging file, why do we need the RAM (sounds ridiculous)? In my opinion, an address space region should be mapped to RAM (through the paging mechanism), and the RAM pages should be backed by the paging file.
Maybe this question could be answered by explaing the following 2 aspects:
What does reserving do?
What does committing do?
Update - 1 2:48 PM 11/23/2010
It is the following quotation from < Windows via C/C++ 5th edition > that makes me puzzled.
...It is best to think of physical storage as data stored in a paging file on a disk drive. So when an application commits physical storage to a region of address space by calling the VirtualAlloc function, space is actually allocated from a file on the hard disk.
After you have reserved a region, you need to commit physical storage to the region before you can access the memory addresses contained within it. The system allocates physical storage committed to a region from the system's paging file.
So, where is the RAM? What if I configure my machine to have no page file?