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.pswp.cn/news/273671.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/273671.shtml
英文地址,請注明出處:http://en.pswp.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位圖索引使用注意事項: ? 一般適用于低基數列; ? 適合數據倉庫; ? 對于啟用位…