In a 32-bit system is the 4GB virtual address space for the whole OS or is it for individual process?
Each process has its own 4GB virtual address space, 2GB of which is for kernel space. In 32-bit Windows you can use
LARGEADDRESSAWARE along with
/3GB boot option to reduce the kernel space to 1GB
The OS will get a wider address bus with PAE so it can actually address more than 4GB of RAM.
If it is for the whole OS, then does the OS fools every process that it has its own 4GB of address space?
There's no fooling here. Virtual address != physical address. Every process always has its own 4GB address space regardless of the amount of physical RAM so that it cannot mess up other processes' data. Even if you have only 128MB of RAM you still have a 4GB address space. That's because pointers in 32-bit programs are always 32-bit wide. The address space is not only used for RAM but also for MMIO devices and the process can also map a file directly into its address space
If the system has more than 4GB of RAM then the process can use AWE to map higher addresses to a 4GB window so that it can access all the available memory. Or it can also create multiple processes like Adobe Premiere CS4 in order to utilize more than a single process' memory limit
When a process is started does it utilize all the virtual address space? Is it what we call committing or reserving virtual address?
The process has 2-4GB of address space but of course it depends on the process to decide how much memory it wants. If a process requested for more memory than available but didn't actually write to that area then it doesn't actually consume any memory. That's called over committing and is allowed in Linux but Windows doesn't allow you to allocate more than total RAM + pagefile available
How can we can find how much virtual address space is required by a process? What if a process requires more virtual address than 3 GB (extended user mode system).
The virtual address space is always 2/3/4 GB, you can't have more than that unless you change to an architecture with a more-than-32-bit virtual address. Requiring more than 3GB of RAM is a different issue. In that case there are several solutions
- Run the process in 64-bit Windows with
LARGEADDRESSAWARE, in that case it can access 4GB of memory
- Uses more than one process like the Premiere CS4 example above
- Use AWE as mentioned above
- Rewrite the algorithm so that it uses less memory, in case you have the source code
- Use 64-bit version of the program
If I am running 3 process on 32 bit windows which are designed with requirements 1 GB RAM each. Will there be memory allocation issue on a 2GB RAM system
There will usually be no issue because some of that can be moved to the page file. But of course it'll be a lot slower
If not, how does Windows achieve this? Does all the virtual address space of a process is allocated a physical address in physical memory or is it a lazy allocation where the mapping is only done when that virtual address is accessed?
The whole virtual address is not mapped linearly as a huge chunk into the physical address space. Memory is mapped in pages, so there will be a lot of undefined addresses in a process' address space like this
Moreover some physical pages will appear in multiple virtual address spaces so that processes can share their data. Some shared pages that are marked read-only will also automatically be cloned when is written to for memory saving. That's called copy-on-write
You need to read about virtual memory first