Virtual and Physical address mapping in 32 bit Windows

0

Correct me I am wrong.

Q1) My understanding is that in 32 bit mode we get 4GB virtual address space. Is this because 32 bit Windows can only support 4 GB physical RAM.?

Q2) Every process get its own private 4 GB address space. 2GB user mode and 2GB kernel. Does the process maps its entire code to user mode and the OS components needed for that process to communicate with processor to execute the code are loaded in kernel mode.?

Q3) If a process is getting its own private 4GB space. If I load 3 process, a total of 12 GB address space. Will I have performance issue as I have only 4 GB RAM.?

But as virtual address is designed to fulfill the need of process in case of less RAM. SO my real question, when a process(single process application) loads does it maps it entire code to the 4GB virtual address regardless the application is currently executing only a certain part of entire code.

What I understand is that when a process is started, all its code is loaded in virtual address space of 2GB user mode and rest 2GB it loads OS kernel files. Now using page tables the virtual address is mapped to Physical address in RAM and disk.Is all the 4GB virtual address will be mapped to 4GB Physical RAM, and rest to the page file.? If I refuse to use page file, does that mean that only 1 process with 4GB virtual address can run on 32bit 4GB OS.?

============================================================================= Thank you for the previous answers.

I am still bit confused about how the User and Kernel address space is divided.

1)Is Kernel address space of 2 GB is shared by all process because it is system wide and loaded at boot time.? or Does every process get a 2GB of kernel address space.? 2) I read some badly written application can consume all of it's address space.? Does that mean there is no room for other applications to run now on a 4GB machine.? 3)If a Kernel address space is shared by all process, does it ever run out of address space or it never does because(I think) the kernel address remains fixed based on OS architecture and shared by all process. 4)By using USERVA switch, the Kernel address is reduced to 1 GB just for application with Large address aware. Why is doesn't do it do for all process if the kernel address space if 2GB(which I think) is shared among all process.? 5)How exactly we differentiate b/w virtual memory and virtual address sace.? If a application need 5GB memory as per devloper will it not run on 32 bit machine with 2GB address(Is it ok to say virtual memory of process = virtual address space of process?)

Aman Yadav

Posted 2018-07-30T14:45:26.963

Reputation: 31

most of this was answered on your previous question Memory management in 32-bit Windows. 3 processes' virtual addresses don't add up to 12GB, since they're not linearly mapped, otherwise tons of memory would be wasted when a process uses only 10MB of RAM but consumes the whole 4GB address chunk. If you open task manager you'll see that there are thousands of processes, does that mean the computer needs TBs of RAM?

– phuclv – 2018-07-30T15:48:23.930

Answers

0

Correct me I am wrong.

Gladly. Are you ready?


Q1) My understanding is that in 32 bit mode we get 4GB virtual address space.

Correct.

Is this because 32 bit Windows can only support 4 GB physical RAM.?

No, the size of virtual memory is independent of the size of physical or installed memory.
These quantities are the same only because they both use values (for addresses) that are 32 bits wide. A processor could be designed to have a virtual address size that is different from its physical address size. IIRC that has been done back when hardware dimensions and costs were much greater than today.


Q2) Every process get its own private 4 GB address space.

Yes, a virtual address space.

2GB user mode and 2GB kernel.

No, "user mode" relates to the operational state of the CPU, i.e. CPU modes. Memory does not have a "user mode" (nor "kernel mode").
The virtual memory is divided into user space and kernel space.

Does the process maps its entire code to user mode and the OS cmponents needed for that process to communicate with processor to execute the code are loaded in kernel mode.?

This question can only make sense if "mode" is replaced with "space".

The kernel is loaded into physical memory during boot.
The execution of the kernel is what controls the system, e.g. process startup and management.
The kernel is mapped into the virtual address space of every process. That is why a portion of the process's virtual memory is "kernel space".

The program code and (shared) libraries are mapped to the virtual memory in user space.

The OS does not "communicate with processor" (nor does any process).
The processor/CPU executes instructions. There is no "communication" with the CPU.
A process is a conceptualized job or task that is allocated resources such as memory (both virtual and physical), and scheduled CPU time.
The only interaction between a process and the processor/CPU is the execution of instructions for that process. The interaction between the kernel and the processor/CPU is the execution of instructions for that kernel, and the routing of exceptions and interrupts.


Q3) If a process is getting its own private 4GB space.

There is no "if". Each process gets 4GB of virtual memory.

If I load 3 process, a total of 12 GB address space. Will I have performance issue as I have only 4 GB RAM.?

Not likely at all, as typical processes rarely use all of their virtual memory. And even if they did there's backing store (e.g. the paging file or swap space) to handle situations when there is less physical memory than virtual address space (which is the original reason for using virtual memory).


But as virtual address is designed to fulfill the need of process in case of less RAM.

You probably mean virtual memory, not "virtual address".

SO my real question, when a process(single process application) loads does it maps it entire code to the 4GB virtual address regardless the application is currently executing only a certain part of entire code.

(Why isn't your "real question" given a number?)
I don't have a definitive answer, but would expect that it would load the entire program, in order to perform any relocations, as well as resolve any external linking (e.g. to libraries).
Whatever is loaded has to mapped, i.e. allocated physical memory.

What I understand is that when a process is started, all its code is loaded in virtual address space of 2GB user mode and rest 2GB it loads OS kernel files.

Again you misuse "user mode".
Loading the kernel code is performed at boot time, not when a process is started.

Now using page tables the virtual address is mapped to Physical address in RAM and disk.Is all the 4GB virtual address will be mapped to 4GB Physical RAM, and rest to the page file.?

No, page tables only map virtual to physical memory (in units of pages). There is no mapping to "disk". That sounds like a common misconception of how the page file and virtual memory works.
The page file is a backing store. It temporarily holds contents of the virtual memory pages that cannot be memory resident (i.e. allocated physical memory).

If I refuse to use page file, does that mean that only 1 process with 4GB virtual address can run on 32bit 4GB OS.?

No, because typically a process does not use its entire virtual address space, so it does not require 4GB of physical memory.
I've seen more than two dozen processes executing on a 32-bit Linux system with only 512MB of install RAM and no swap file.

sawdust

Posted 2018-07-30T14:45:26.963

Reputation: 14 697

0

Q1 : No, it's because a 32-bit register can only hold 4GB unique addresses.

Q2 : Incorrect, there is no division of the user memory into user and kernel. The kernel is not in the process address space.

Q3 : Yes, Windows will swap out as needed the oldest-referenced memory pages.

Real question : Yes, a process cannot start without the mapping to swap space of its entire memory, so it can be swapped out at any moment, fully or partially.

For the rest, I suggest that you do some reading first in Wikipedia :

harrymc

Posted 2018-07-30T14:45:26.963

Reputation: 306 093