Kernel Page Global Directory (PGD) of Page table of Process created in Linux Kernel

Kernel Page Global Directory (PGD) of User process created

在早期版本:

在fork一个进程的时候,必须建立进程自己的内核页目录项(内核页目录项要与用户空间
的页目录放在同一个物理地址连续的页面上,所以不能共享,但所有进程的内核页表与进
程0共享)
3G用户,页目录中一项映射4M的空间(一项页目录1024项页表,每项页表对应1个页面4K
),即:
#define PGDIR_SHIFT 22
#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
>>> sys_fork->do_fork->copy_mm->mm_init->pgd_alloc->get_pgd_slow
#if CONFIG_X86_PAE
。。。。。。。。。。。。。
#else
extern __inline__ pgd_t *get_pgd_slow(void)
{
>>> 分配页目录表(包含1024项页目录),即为一个进程分配的页目录可以映射的空间为
1024*4M=4G
 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
 if (pgd) {
>>> #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
>>> TASK_SIZE为3G大小,USER_PTRS_PER_PGD为用户空间对应的页目录项数目(
3G/4M=768)
>>> 将用户空间的页目录项清空
  memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
>>> 将内核页目录表(swapper_pg_dir)的第768项到1023项拷贝到进程的页目录表的第
768项到1023项中
  memcpy(pgd + USER_PTRS_PER_PGD, swapper_pg_dir + USER_PTRS_PER_PGD, 
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
 }
 return pgd;
}
#endif

比較後來的版本:

pgd_t *pgd_alloc(struct mm_struct *mm)  -> 
 pgd_ctor(mm, pgd); //关键代码,将指向内核空间的页目录项拷贝到新分配的pgd对应的项目中。
->
    clone_pgd_range(pgd + KERNEL_PGD_BOUNDARY, //item points to the kernel space
             swapper_pg_dir + KERNEL_PGD_BOUNDARY, KERNEL_PGD_PTRS);

ref. 

[1] http://biancheng.dnbcw.info/linux/321897.html

[2] http://m.blog.csdn.net/blog/SunnyBeiKe/6898253

转载于:https://www.cnblogs.com/bittorrent/p/3833610.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/273671.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

POI 导出文件以文件流形式返回

POI工具类 import java.io.UnsupportedEncodingException; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFRow; import o…

Json串和java对象进行转时

json-lib-xxx.jarezmorph-xxx.jar //>依赖包 JsonConfig config new JsonConfig();//有选择性的过滤掉一些属性值 JSONUtils.getMorpherRegistry().registerMorpher( new DateMorpher(new String[] { "yyyy-MM-dd" }));//注册一个json转为java.util.date的日期格…

Mybatis Integer类型参数值为0时判断为空、空字符串不通过

根据状态查询是&#xff0c;由于status是Integer类型&#xff0c;所以当前状态为0时&#xff0c;变成了查询了所有的状态信息。 <if test"requestParam.status ! null and requestParam.status ! ">and s.status #{requestParam.status} </if> 原因&a…

BZOJ 3391: [Usaco2004 Dec]Tree Cutting网络破坏(搜索)

这道直接遍历一遍求出每个点的子节点数目就行了 CODE&#xff1a;#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;#define maxn 50010int b[maxn],q[maxn],id[maxn],ans[maxn];bool cmp(int x,int y){re…

Fast Matrix Operations

uva11992:http://uva.onlinejudge.org/index.php?optioncom_onlinejudge&Itemid8&pageshow_problem&problem3143 题意&#xff1a;给你n*m的矩阵初始化的时候矩阵里面的元素全部是0&#xff0c;对于这个矩阵有3中操作。 1 x1 y1 x2 y2 v 把&#xff08;x1 y1 x2…

linux ll命令无效

1.编辑~/.bashc vim ~/.bashc 若vi/vim命令无效&#xff0c;参考 bash: vi: command not found/bash: vim: command not found 2.重新执行刚修改的初始化文件 source ~/.bashc

jquery不同版本冲突导致低版本功能不能用

oConflict() 方法让渡变量 $ 的 jQuery 控制权。 该方法释放 jQuery 对 $ 变量的控制。 使用方法&#xff1a; var jq $.noConflict();//转换控制权 jq(document).ready(function () { jq("#outside").click(function () {你的操作...... }); }); });转载于:https:/…

struts2+jquery 实现ajax登陆

一、新建一个web项目&#xff1a;test,配置好struts2的环境(详细配置见&#xff1a;http://www.cnblogs.com/wuweidu/p/3841297.html) 导入Jquery的js文件到项目 二、在com.action包下&#xff0c;新建一个loginAction.java loginAction.java的代码如下 package com.action;imp…

hdu 2026 首字母变大写

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid2026 题目大意&#xff1a;将一个英文句子&#xff0c;每个单词第一个首字母变大写。 1 #include <stdio.h>2 int main (void)3 {4 int i;5 char ch[100];6 while(gets(ch))7 {8 for (i0; c…

Docker Kafka 单机版安装

一、安装 下载library/zookeeper并运行 docker run --name zookeeper -d -p 2181:2181 -v /etc/localtime:/etc/localtime library/zookeeper 测试zookeeper端口是否通wget IP:2181 下载wurstmeister/kafka并运行 docker run -d --name kafka -p 9092:9092 --link zookeeper…

HDU1429胜利大逃亡(续)HDU 1885 Key Task BFS+状态压缩+水

HDU1429 只有10把钥匙 1<<10足够了 标记用三维数组 用Linux好不习惯 继续克服&#xff5e; #include <stdio.h> #include <string.h> #include <stdlib.h> #include <limits.h> #include <malloc.h> #include <ctype.h> #include &l…

Docker 安装nginx,并挂载文件

创建挂载所需目录&#xff1a; mkdir /test/server/nginx/{conf,logs,html,conf.d} /test/server/nginx/conf创建nginx.conf文件&#xff0c;并编辑: user nginx; worker_processes 1;error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid;events {wor…

http解码-5

http://www.freebuf.com/articles/web/18084.html (1) 在 前端安全技术中常见的编码绕过技术利用的就是不同系统间的编码位宽(addslashes()楼哦的那个)&#xff0c;不同编码的解码顺序(htmlParserjavascriptParser的解码顺序)&#xff0c;不同的解码规则(unicode->ascii转换…

IllegalArgumentException:argument type mismatch

Exception nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property id of class com.wzq.test.demo.entity.Fee with value 1211518556674199553Cause:java.lang.IllegalArgumentException: argument type mismatch 场景: 添加不传ID使…

hadoop家族的各个成员

这篇文章不提原理&#xff0c;讲讲hadoop及其周边项目的作用。 hadoop这个词已经流行好多年了&#xff0c;一提到大数据就会想到hadoop&#xff0c;那么hadoop的作用是什么呢&#xff1f; 官方定义&#xff1a;hadoop是一个开发和执行处理大规模数据的软件平台。核心词语是平台…

ArrayList 源码分析

介绍 ArrayList 是一个数组队列&#xff0c;相当于 动态数组。与Java中的数组相比&#xff0c;它的容量能动态增长。 结构 ArrayList继承于AbstractList&#xff0c;实现了List, RandomAccess, Cloneable, java.io.Serializable这些接口。如下图&#xff1a; public class Arra…

Poj 1556 The Doors 计算几何+最短路

其实本题非常的无脑&#xff0c;无脑拍完1A&#xff0c;写到blog里只因为TM无脑拍也拍了很久啊 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #include <string> #include <iostr…

String equals()方法 源码分析

public boolean equals(Object anObject) {// :比较的引用类型&#xff0c;比较的是地址值是否相同if (this anObject) { //地址值相等&#xff0c;返回truereturn true;}// instanceOf判断一个对象是不是某个类型的实例if (anObject instanceof String) {String anotherStrin…

Google,真的要离我们而去吗?

Google,真的要离我们而去吗&#xff1f; 好怀念&#xff0c;真正要解决问题&#xff0c;还得搜google!转载于:https://www.cnblogs.com/fuyujian/p/3852444.html

Oracle 位图索引

内容简介: 1.位图索引 1.1位图索引使用注意事项; 1.2 使用位图索引; 1.3 位图索引对DML操作的影响; 2.位图连接索引 2.1 明确需求后使用位图索引; 2.1创建位图连接索引的注意事项: 1.位图索引: 1.1位图索引使用注意事项: ❏ 一般适用于低基数列; ❏ 适合数据仓库; ❏ 对于启用位…