内核内存地址空间

内核内存地址空间

问题描述:

我已经读到,在具有4GB系统内存的32位系统上,将2GB分配给用户模式,将2GB分配给内核模式.但是,如果我有一个拥有512 MB内存的系统,是否可以将其划分为256 MB的用户空间和256 MB的内核地址空间?

I've read that, on a 32-bit system with 4GB system memory, 2GB is allocated to user mode and 2GB allocated to kernel mode. But, If I had a system with 512 MB of memory, would it be partitioned as 256 MB to user and 256 MB to kernel address space?

您正在混淆物理和虚拟内存. 2GB已分配给用户/系统,但它是虚拟内存.说它们没有分配而是构成一个寻址空间,这是更正确的说法.最初,此空间完全不绑定到物理内存.当应用程序实际需要内存时(首次启动时),将分配物理内存,并将地址空间中的某些地址映射到该内存.当分配了内存但未使用足够长时间或PC的物理内存不足时,可以将数据转储到交换文件中,并保留在那里直到请求.该映射对于应用程序是透明的,并且不知道当前数据在哪里:片上还是HDD上.因此,地址空间总是以相同的方式拆分.

You are confusing physical and virtual memory. 2GB is allocated to user/system, but it is virtual memory. It is even more correct to say that they are not rather allocated but they constitute an addressing space. Initially this space is not bound to physical memory at all. When application actually needs memory (first time is at start up) physical memory is allocated and some addresses from address space are mapped to it. When memory is allocated but not used long enough or PC is running out of physical memory data can be dumped in swap file, and stay there until requested. This mapping is transparent for application and it has no idea where data currently is: on chip or on HDD. So the address space is always splitted the same way.