处理地址空间 [英] Proces Address Space

查看:73
本文介绍了处理地址空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解进程地址空间.

我们知道32位操作系统中的每个进程都有一个4GB的内存地址块,也称为虚拟地址空间.虚拟地址空间的一部分必须保留给内核以用于OS交互.因此,此地址空间分为用户空间(2/3 GB)和内核空间(2/1 GB).

假设我的系统上运行了两个应用程序,1)notepad.exe 2)word.exe
这意味着将为notepad.exe和word.exe分别分配4 GB的空间.
我的理解是,notepad.exe和word.exe都将分别具有2 gb的用户空间和2 gb的系统空间.
我的理解正确吗?

现在在站点http://msdn.microsoft.com/zh-cn/library/windows/hardware/hh439648(v=vs.85).aspx中,写道:每个用户模式进程都有其自己的专用虚拟地址空间,但是所有在内核模式下运行的代码都共享一个称为系统空间的虚拟地址空间..

我无法获得在内核模式下运行的所有代码共享一个称为系统空间的虚拟地址空间"的声明.

对于上述示例,这是否意味着notepad.exe和word.exe都将分别具有2 gb的用户空间.但是两者都会共享2 GB的系统空间吗?


请澄清我的疑问.

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.

推荐答案

我仅对WinCE编程有所了解,但实际上是对的,因为进程共享相同的内核内存.
但是,进程通常无法访问该地址空间的一部分,因此无法以与进程空间的其他部分相同的方式进行寻址,因为如果尝试对其进行读写,则应该会遇到访问冲突. br/>
这就是为什么在给予一段代码内核级访问时必须非常小心的原因,通常是非常低级的代码(例如驱动程序)可能具有访问权限.
或者使用远程调试工具,因为有时在内核区域中查找正在运行的进程和进程堆栈的列表会很有用.

但作为一般规则,在我看来,应尽可能限制对内核的访问.
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.


语句

The statement

>所有在内核模式下运行的代码共享一个称为系统空间的虚拟地址空间"
"all code that runs in kernel mode shares a single virtual address space called system space"



我很清楚:系统中只有一个内核虚拟地址空间.

请注意,每个进程的虚拟地址空间仅为4GB,而不是分配的内存.



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.


虚拟地址"表示您可以在其中使用的地址您的程序不是实际的物理地址,但是必须转换为真实的地址.这是MMU的任务. MMU最初是作为主板上的附加芯片开始的,但到了90年代,它才集成到CPU中.其中,MMU负责分页,并模拟连续的大块内存的分配,即使物理内存过于分散而无法找到足够大的空间也是如此.

系统空间是物理内存的一部分,系统DLL等已加载到该空间中.为了节省空间,所有进程将共享该系统空间,因此MMU将所有进程对系统功能的访问映射到该物理空间.如果从不同进程的虚拟地址空间来看,这些系统功能的地址可能仍显示为不同,但是MMU确定的结果物理地址对于所有进程都是相同的.
''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.


这篇关于处理地址空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆