Linux内存映射的一个过程 [英] Linux Memory Map of a process

查看:69
本文介绍了Linux内存映射的一个过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对进程及其内部的linux内存映射感到非常困惑。一般来说,书籍或文章中提到的是在linux(4gb-地址空间)中,

3gb地址空间映射到进程的用户空间,1gb映射到进程的内核空间。



由于Linux中有虚拟内存支持,每个进程都有一个单独的4gb虚拟地址空间。通过分页,虚拟到物理地址转换发生在内存中访问和用户空间页面是可交换的,所以这里没有问题。



内核地址空间会发生什么,上述内容如何工作,当进程通过内核空间进入时系统调用。我的理解是内核页面是不可交换的,所以当不同的进程进入内核空间时,这里的工作方式如何。假设我的系统中有10个进程正在运行,当一个进程执行系统调用时,内核如何切换到相应进程的内核地址空间(因为如果我错了,内核内存不会改变 - 纠正我)以及它是如何返回的回到用户空间。



如果驱动程序也在内核空间中运行,以及特定的驱动程序代码如何映射到特定的内核地址空间(在1gb中)以及如果内核中存在页面错误会发生什么空格。



请提供有关此特定主题链接的任何文章。

I am very much confused of the linux memory map of a process and its internals. In general what is mentioned in books or articles is that in linux (4gb -address space),
3gb address spaces is mapped to userspace for a process and 1gb is mapped to kernelspace of a process.

Since virtual memory support is there in linux, each process will have a separate 4gb virtual address space.And through paging the virtual to physical address conversion takes place for a memory access and userspace pages are swappable so no problem here.

what happens for the kernel address space, how the above said things works, when a process enter the kernel space through system calls. My understanding is that kernel pages are non-swappable, so how things work here when different process enters the kernel space. Say i have 10 process running in my system , when one process executes a system call , how the kernel switches to the corresponding process's kernel address space(since kernel memory is not going to change-correct me if i am wrong) and how it return back to user space.

If drivers also running in kernel space and how particular driver code is mapped to particular kernel address space(with in 1gb) and what happens if there is page fault in kernel space.

Please provide any article on links on this particular topic.

推荐答案

只有一个内核地址空间,映射到所有进程的虚拟地址空间的顶部。根本就没有对应进程的内核地址空间或特定的内核地址空间。
There is only one kernel address space that's mapped into the top parts of the virtual address spaces of all processes. There's simply no such thing as "corresponding process's kernel address space" or "particular kernel address space".


这篇关于Linux内存映射的一个过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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