操作系统内核为自己使用虚拟内存?

发布于 2024-08-30 08:29:08 字数 44 浏览 2 评论 0原文

操作系统内核是否使用虚拟内存或者操作系统内核的某些部分可以驻留在硬盘中吗?

Does OS kernel use Virtual memory or Can some part of the OS kernel reside in Hard Disk?

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

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

发布评论

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

评论(3

顾北清歌寒 2024-09-06 08:29:08

“使用虚拟内存”是一种模糊的说法。从广义上解释,答案是肯定的。虚拟内存是操作系统的基本组成部分,用于保护一个进程免受另一个进程的影响,并使进程产生一种错觉,即它们拥有计算机的整个内存。关于虚拟内存的维基百科文章是关于其工作原理的一个很好的参考。 (尽管公平地说,Linux 可以在没有虚拟内存的情况下进行配置,并且还有其他不使用虚拟内存的自定义或实时系统。)

现在,如果您询问操作系统是否会分页的更详细问题如果没有保存内核数据结构的内存,我只能回答Linux内核没有。如今内存已经足够大了,通过调出内核数据结构获得的额外内存并不能证明增加的复杂性或页面错误的成本是合理的。

"Using virtual memory" is kind of a vague statement. Broadly interpreted, the answer is yes. Virtual memory is a fundamental part of operating systems for protecting one process from another and giving processes the illusion that they have the computer's entire memory to themselves. The Wikipedia article on virtual memory is a good reference for how this works. (Although to be fair, Linux can be configured without virtual memory, and there are other custom or real-time systems that don't use it.)

Now, if you're asking the more detailed question of whether an operating system will page out memory that holds kernel data structures, I can only answer that the Linux kernel doesn't. Memory is large enough these days the extra memory gained by paging out kernel data structures doesn't justify the added complexity or the cost of a page fault.

凶凌 2024-09-06 08:29:08

NT 内核和设备驱动程序使用虚拟内存来存储可以安全地分页到存储的数据结构和对象。例如,驱动程序可以像用户模式程序一样请求虚拟内存。

然而,内核具有以下数据和代码:1) 出于效率原因,必须始终保留在内存中 2) 必须保留在内存中,因为无法处理页面错误。一个典型的例子是进入ISR(中断服务例程)(例如页面错误处理代码本身)。这种类型的代码和数据始终保存在物理内存中,在 NT 内核上称为非分页池。

后者并不意味着直接引用非分页内存地址。它们总是由内核内存管理器转换为物理地址(反之亦然)。

我认为(我听取更正)唯一在没有虚拟映射的情况下使用的物理地址是系统启动时的第一个1MB(在WinNT中,NTLDR / NTDETECT.COM阶段,直到激活保护模式)。

NT kernels and device drivers use virtual memory for data structures and objects that can be safely paged out to storage. For example, a driver can request virtual memory as a usermode program does.

However, the kernel has data and code that: 1) must be kept always in memory for efficiency reasons 2) must be kept in memory because a page fault cannot be serviced. A typical example is entering ISRs (interrupt service routine) (such as the page fault handling code itself). Code and data of this type is kept on physical memory always, and it's called nonpaged pool on NT kernels.

The latter does not means that nonpaged memory addresses are referenced directly. They are always translated to physical addresses (and viceversa) by the kernel memory manager.

I think (i listen for corrections) the only physical addresses used without virtual mapping is the first 1MB when the system boots up (in WinNT, the NTLDR / NTDETECT.COM phase until protected mode is activated).

时光倒影 2024-09-06 08:29:08

哪个操作系统内核?

有些操作系统内核使用虚拟内存,有些则不使用。许多现代操作系统甚至不再有虚拟内存。 (仅 C、C++ 或类似的指针不安全语言需要 VM,但当今使用的大多数语言和平台都是指针安全的(例如 JavaScript、Python、Ruby、PHP、Perl、Java、CLI 减去不安全) ),所以真的不再需要虚拟机了。)

Which OS Kernel?

Some OS Kernels use Virtual Memory, some don't. Many modern Operating Systems don't even have Virtual Memory anymore. (VM is only required for C, C++ or similar pointer-unsafe languages, but the majority of languages and platforms in use today are pointer-safe (e.g. JavaScript, Python, Ruby, PHP, Perl, Java, CLI minus unsafe), so there's really no need for VM anymore.)

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