-1

In a 32-bit system is the 4GB virtual address space for the whole OS or is it for individual process?

If it is for the whole OS, then does the OS fools every process that it has its own 4GB of address space?

When a process is started does it utilize all the virtual address space? Is it what we call committing or reserving virtual address?

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).

2
  • 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. 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?
    – Aman Yadav
    Commented Jul 26, 2018 at 2:45
  • 2
    Please do not expand on your questions in comments; edit your question to make it clearer and more complete. Commented Jul 26, 2018 at 2:52

3 Answers 3

1

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

pagetable

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

0

A 4 gigabyte virtual address space is created per process, which is shared between the OS and the process. The OS decides the boundary (which is fixed for all processes).
The OS exists in every virtual address space.
IOW the "process [does have] its own 4GB of address space" but has to share it with the OS, and cannot read, write, or execute the part of virtual memory owned by the kernel.

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. If not, how does windows achieve this.?

A user process does not have the privilege of requiring physical memory that remains resident (i.e. cannot be swapped out).
Since virtual memory schemes use swapping (with a page file or swap space on a mass storage device), typically there are no issues running multiple processes of 4 GB virtual address space with physical memory less than than the virtual size.

It is possible to create an out-of-memory (aka OOM) condition if processes create large memory demands and there is not enough physical memory and swap space.

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?

There is never a requirement that an entire program must be allocated physical memory and loaded into memory.
The mapping of physical memory for a process is based on need.
A process only needs to be memory resident when it is actually being executed, and at a minimum regardless of its size, only the one page of code that is currently referenced by the program counter register and any pages of data references have to be actually resident.

So yes there is a "lazy allocation where the mapping is only done when that virtual address is accessed", aka demand paging.

0

No, there is no fooling, you have 4GB of RAM max for the whole OS.

You can enable PAE, which sometimes, if it works, allow Windows to recognize more than 4GB. Still nowhere near as much as a 64-bit OS.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .