为什么内核映射到与进程相同的地址空间? [英] Why is kernel mapped to the same address space as processes?

查看:90
本文介绍了为什么内核映射到与进程相同的地址空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个要详细说明的问题:为什么据说内核在进程地址空间中?

This is a question to elaborate on this one: Why is kernel said to be in process address space?

这可能是一个愚蠢的问题,但在我脑海中却突然冒出.全部 有关进程地址空间和虚拟内存布局的文本 提到进程地址空间具有为内核保留的空间. 例如在32位系统上,进程地址空间为4GB,其中1 GB在Linux中是为内核保留的(其他OS上可能会有所不同).

This might be a silly question but it just popped up in my mind. All the text about process address space and virtual memory layout mentions that the process address space has space reserved for kernel. For e.g. on 32 bit systems the process address space is 4GB of which 1 GB is reserved for kernel in Linux (Might be different on other OS).

我只是想知道为什么据说内核在进程地址中 进程无法直接寻址内核时的空间.我们为什么不 说内核有一个不同于进程的独立地址空间, 为什么我们不能为内核本身使用不同的页表 与进程的页表分开吗?

I am just wondering why kernel is said to be in the process address space when a process cannot address the kernel directly. Why don't we say that the kernel has a separate address space than a process and why can't we have a different page table for kernel itself which is separate from the page tables of the processes?

我可以得到有关Linux(Debian或Ubuntu)特定操作系统的解释吗?

Can I get an explanation with respect to Linux (Debian or Ubuntu) specific operating system?

推荐答案

一个进程在这里拥有"整个虚拟地址空间,内核以及其中的用户部分.

A process "owns" the entire virtual address space here, the kernel and the user portions of it.

它不能窥视和戳内核代码和数据并不是由于地址空间不同,而是由于页表中设置的访问权限不同.内核页面的设置方式使常规应用程序无法访问它们.

Its inability to peek and poke the kernel code and data is not due to different address spaces, it's due to different access rights/permissions set in the page tables. Kernel pages are set up in such a way that regular applications can't access them.

但是,习惯上将一个整体的两个部分称为内核空间和用户空间,这可能会造成混淆.

It is, however, customary to refer to the two parts of one whole thing as the kernel space and the user space and that can be confusing.

这篇关于为什么内核映射到与进程相同的地址空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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