Click here to Skip to main content
15,913,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to understand the process address space.

We know that each process in a 32-bit OS has a a 4GB block of memory addresses also called as the virtual address space. A portion of the virtual address space must be reserved to the kernel for OS interactions. So this address space is divided into user space(2/3 GB) and kernel space(2/1 GB).

Suppose I have two applications running on my system, 1) notepad.exe 2) word.exe
This means that for both notepad.exe and word.exe 4 gb space each will be allocated.
My understanig is that both notepad.exe and word.exe will have seperate 2 gb of user space each and seperate 2 gb of system space each.
Is my understanding correct?

Now in site http://msdn.microsoft.com/en-us/library/windows/hardware/hh439648(v=vs.85).aspx it is written that "Each user-mode process has its own private virtual address space, but all code that runs in kernel mode shares a single virtual address space called system space. ".

I am not able to get the statement "all code that runs in kernel mode shares a single virtual address space called system space".

With respect to above example does this means that both notepad.exe and word.exe will have seperate 2 gb of user space each. But both will share 2 gb of system space?


Pls clarify my doubt.
Posted

I only have an understanding from WinCE programming but yes in essence your correct in that the processes share the same piece of kernel memory.
However this part of the address space is not normally accessible by the process and so cannot be addressed in the same way as other parts of the process space because you should get an access violation if you try to read or write from or to it.

This is why you have to be very careful when giving a piece of code Kernel level access, usually very low level code such as drivers might have access.
Or remote debugging tools might as it is sometimes useful to look into the kernel area for a list of the running processes and the stack of the processes.

But as a general rule Kernel access should be restricted as much as possible in my view.
 
Share this answer
 
The statement

"all code that runs in kernel mode shares a single virtual address space called system space"


is clear to me: there is ONE kernel virtual address space in the system.

Please note that just the virtual address space of each process is 4GB, not the allocated memory.

 
Share this answer
 
Comments
rupeshkp728 14-Nov-11 5:07am    
So this means that both notepad.exe and word.exe will have seperate 2 gb of user space each. But both will share 2 gb of system space?
CPallini 14-Nov-11 5:29am    
System space is ONE, hence it is shared.
rupeshkp728 14-Nov-11 5:42am    
Thanks for the clarification.
CPallini 14-Nov-11 5:53am    
You are welcome.
'Virtual address' means that the addresses you can use in your program are not actual physical addresses, but have to be translated to the real address. This is the task of the MMU. The MMU originally started out as an additional chip on the motherboard, but was integrated into the CPU some time in the nineties. Among other things, the MMU takes care of paging, and emulating the allocation of big continuous chunks of memory even when the physical memory is too fragmented to find a sufficiently large space.

The system space is the part of the physical memory that system DLLs and the like are loaded into. To save space, all process will share this system space, and therefore the MMU will map the accesses of all processes to system functions into this physical space. The addresses of these system functions may still appear different if viewed from the virtual address space of different processes, but the resulting physical addresses the MMU determines will be the same for all processes.
 
Share this answer
 
Comments
rupeshkp728 14-Nov-11 15:44pm    
Thanks Stefan your well explained note clears it all.
 
Share this answer
 
System space of a process contains various data structures such as HANDLE table, PAGE Table etc which are process specific.THIS SPACE CANNOT BE SHARED




But the CODE (and not data) accessed by various processes will be shared (i.e. in case of same DLL loaded by various processes)
 
Share this answer
 
v2
Comments
rupeshkp728 14-Nov-11 5:42am    
Thanks Prafulla for the reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900