虚拟内存分页和分段哪个更好?

发布于 2024-11-11 13:52:36 字数 125 浏览 4 评论 0原文

大多数操作系统使用虚拟内存分页。这是为什么呢?为什么不使用分段呢?仅仅是因为硬件问题吗?在某些情况下,一个比另一个更好吗?基本上,如果您必须选择其中一种,您会选择使用哪一种,为什么?

为了便于讨论,我们假设它是 x86。

Most OSes use paging for virtual memory. Why is this? Why not use segmentation? Is it just because of a hardware issue? Is one better than the other in certain cases? Basically, if you had to choose one over the other, which one would you want to use and why?

Let's assume it's an x86 for argument's sake.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤千羽 2024-11-18 13:52:36

取自:galvin 的《操作系统概念》中的

问题之一。

分段允许进程的物理地址空间是非
连续的。分页是另一种提供此功能的内存管理方案
优势。然而,分页避免了外部碎片和压缩的需要,而分段则不然。

分割问题:
问题的出现是因为,当代码片段
或者主存中的数据需要被换出,必须找到空间
在后备存储上。后备存储也有同样的碎片问题
但访问速度要慢得多,因此不可能进行压缩。

分页通过以下方式解决这个问题:

实现分页的基本方法是将物理内存分成固定大小的块(称为帧),并将逻辑内存分成
相同大小的块称为页。后备存储被分为固定大小的块,这些块的大小与内存帧或多个帧的簇的大小相同。

由于页面-框架-后备存储都被划分为相同的大小,因此不会导致外部碎片。但可能存在内部碎片。
因此必须正确选择页面大小

操作系统概念

Taken from :operating systems concepts by galvin

one of the issues..

Segmentation permits the physical address space of a process to be non-
contiguous. Paging is another memory-management scheme that offers this
advantage. However, paging avoids external fragmentation and the need for compaction, whereas segmentation does not.

Segmentaion problem:
The problem arises because, when code fragments
or data residing in main memory need to be swapped out, space must be found
on the backing store. The backing store has the same fragmentation problems
but access is much slower, so compaction is impossible.

Paging solves it by:

The basic method for implementing paging involves breaking physical memory into fixed-sized blocks called frames and breaking logical memory into
blocks of the same size called pages.The backing store is divided into fixed-sized blocks that are the same size as the memory frames or clusters of multiple frames.

Since pages-frames-The backing store all are divided into same size so it doesn't lead to external fragmentation. But may have internal fragmentation.
So pagesize must be chosen correctly

Operating Systems concepts

屌丝范 2024-11-18 13:52:36

Windows 和 Linux 等操作系统结合使用分段分页。进程的虚拟内存首先被划分为段,然后每个段由很多页组成。操作系统首先进入特定的段,然后在该段中找到特定的页面来访问地址

OS like windows and Linux use a combination of both segmentation and paging. The virtual memory of a process is first divided into segments and then each segment consists of a lot of pages. The OS first goes to the specific segment and in that segment it then locates the particular page to access an address

徒留西风 2024-11-18 13:52:36

请注意,单地址空间操作系统有时会使用分段来隔离进程。

Note, that Single-Address-Space Operating Systems sometimes use segmentation to isolate processes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文