OS 的内存管理

Memory management by OS

我正在尝试了解 OS 的内存管理。 到目前为止我的理解是,在 32 位系统中,每个进程在虚拟地址 space 中分配了一个 space 的 4gb [2gb user + 2gb kernel]。 让我感到困惑的是,这个 4gb space 对每个进程都是唯一的。如果我说 3 个进程 p1、p2、p3 运行 我需要 12 GB 的 space 硬盘吗?

此外,如果说我在 32 位系统上有 2gb ram,它将如何处理需要 4gb 的进程?[通过分页文件]?

[2gb user + 2gb kernel]

这是OS的约束。在没有启用 PAE 的 x86 32 位系统上,虚拟地址 space 是 4 GiB(注意 GB usually denotes 1000 MB 而 GiB 代表 1024 MiB)。

What confuses me is that is this 4gb space unique for every process .

是的,每个进程都有自己的 4 GiB 虚拟地址 space。

if I have say 3 processes p1 ,p2 ,p3 running would I need 12 gb of space on the hard disk ?

没有。对于三个进程,它们最多可以占用 12 GiB 的存储空间。是主存储还是辅助存储留给内核(当然首选主存储)。因此,如果所有这些进程确实占用了 4 GiB 的全部范围,则您需要主内存大小 + 一些辅助存储 space 至少为 12 GiB 才能包含所有三个进程,这不太可能发生。

Also if say I have 2gb ram on a 32 bit system ,how will it manage to handle a process which needs 4gb ?[through the paging file ] ?

是的,在某种程度上。你的意思是正确的,但 "paging file" 只是一个实现细节。它由 Windows 使用,但 Linux 使用单独的交换分区。因此,从技术上讲,"secondary storage (a HDD, for example) is needed to store the remaining 2 GiB of the process" 是正确的。