亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1026 | 回復(fù): 0
打印 上一主題 下一主題

Linux執(zhí)行以及虛擬內(nèi)存之用 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2008-12-11 22:52 |只看該作者 |倒序?yàn)g覽
這篇文章轉(zhuǎn)自陳莉君老師的博客
http://www.lupaworld.com/26540/viewspace-117191.html
[color="navy"]說明,本篇是英文翻譯。
[color="navy"]在我閱讀學(xué)生們翻譯的文章時,問題多多。在此,我翻譯一段比較獨(dú)立又較為有用的段落,以供大家參考。
-----------------------------------------------------------------------------------
[color="sienna"]Linux Execution and Virtual Memory Utilization

Linux執(zhí)行以及虛擬內(nèi)存之用

[color="sienna"]When Linux boots, it starts with the MMU disabled, so initially it deals only with physical
memory. The kernel image is copied
to physical address 0x8000 in DRAM and executed. First a master page
table is created and placed just before the kernel, which describes all
available DRAM. The MMU is then switched on, mapping all of DRAM to
virtual address 0xC0000000. The kernel reserves 64K of virtual memory
for the interrupt handler code (usually at the very top of virtual
memory), and sets up all the mappings for the hardware registers (UART,
USB, LCD, GPIO, etc). Once kernel space is established and all drivers
are initialized, the linux kernel moves on to establishing user space.
This involves reading in the file system and actually executing
processes.
file:///C:/DOCUME%7E1/ljy/LOCALS%7E1/Temp/moz-screenshot-1.jpg

file:///C:/DOCUME%7E1/ljy/LOCALS%7E1/Temp/moz-screenshot.jpg
當(dāng)Linux啟動時,是以MMU禁用來開啟它的旅途的,因此,它起初只關(guān)注物理內(nèi)存。內(nèi)核映像(kernel
image)被拷貝到DRAM的物理地址 0x8000處,并得到執(zhí)行權(quán)。第一個主頁表( master page
table)從而誕生,并緊挨著內(nèi)核映像存放,這個頁表是對全部可用DRAM的描述。此后,MMU被啟用,從而把全部DRAM映射到從
0xC0000000開始的虛地址。內(nèi)核為中斷處理程序保留64K虛擬內(nèi)存(通常在虛擬內(nèi)存的頂端),然后為所有的硬件寄存器(UART, USB,
LCD, GPIO,
etc)建立映射。一旦內(nèi)核空間建立起來,并且所有的驅(qū)動程序都被初始化,則Linux內(nèi)核轉(zhuǎn)向建立用戶空間。這涉及到在文件系統(tǒng)中讀取并實(shí)際執(zhí)行進(jìn)程。

[color="sienna"]Each process that runs on the system does so in its own memory “context”. Each context
has its virtual memory space
established and maintained by the kernel using a separate page table.
So each process can “see” the entire user space, but its underlying
physical memory is different from the other processes. Multiple
processes and their contexts are run in time slices. This means that
each process executes for a time, then is halted, and execution is
passed to the next process in a rotating queue. The act of passing
execution is called “context switching” and its frequency varies,
depending on the kernel configuration and the current system load.

運(yùn)行在系統(tǒng)中的每個進(jìn)程都的確在它自己的內(nèi)存“上下文”中執(zhí)行。每個上下文都有自己的虛擬內(nèi)存空間,這一空間的建立和維護(hù)
是內(nèi)核通過獨(dú)立的頁表進(jìn)行的。因此,每個進(jìn)程可以“看到”整個用戶空間,但是,其對應(yīng)的物理內(nèi)存互不重疊。多個進(jìn)程及其上下文以時間片輪流執(zhí)行。這就意味
著,每個進(jìn)程執(zhí)行一段時間,然后停下來,從而把執(zhí)行權(quán)傳遞給輪流隊(duì)列中的下一進(jìn)程。傳遞執(zhí)行權(quán)的行為就是所謂的“上下文切換”,傳遞的頻率隨內(nèi)核的配置及
當(dāng)前負(fù)載而變化。

[color="sienna"]Each context includes the mappings for both user and kernel space because each new
page table is initialized with the
master page table contents. So, code executing in kernel space has full
access to the entire memory map for the current process. Switching back
and forth between kernel and user space execution does not require a
page table swap.

每個上下文既包含用戶空間的映射,也包含內(nèi)核空間的映射,這是因?yàn)椋總新的頁表都是用主頁表內(nèi)容進(jìn)行初始化的。因此,對當(dāng)前進(jìn)程而言,在內(nèi)核空間執(zhí)行的代碼具有對整個內(nèi)存映射訪問的權(quán)利。在內(nèi)核空間和用戶空間之間來回切換根本無需切換頁表。

[color="sienna"]When a process is executed, the kernel creates a new context, and maps just enough
physical memory to copy the
executable image into DRAM (starting at least a page above virtual
address 0, because 0 is reserved for faults). The executable is broken
into the same sections as the kernel: code and data (uninitialized
global data, zero-initialized global data). Once the kernel schedules
the process for execution, it sets the stack to grow down from the top
of user space, and the heap to grow up from the end of the executable
image. This way the chances of the two spaces colliding is minimized.
Any dynamic libraries the process pulls in are placed at virtual
address 0x40000000.

當(dāng)一個進(jìn)程執(zhí)行時,內(nèi)核創(chuàng)建新的上下文,并為把可執(zhí)行映像拷貝到DRAM僅映射足夠用的物理內(nèi)存(從虛地址0之上的某個地
址開始一個頁,因?yàn)?地址留作存放出錯信息)。可執(zhí)行映像如內(nèi)核一樣也被劃分為兩部分:代碼和數(shù)據(jù)(未初始化數(shù)據(jù)和初始化為0的全局?jǐn)?shù)據(jù))。一旦內(nèi)核調(diào)度
進(jìn)程執(zhí)行,它就設(shè)置棧和堆,前者從用戶空間的頂部向下增長,后者從可執(zhí)行映像的尾部向上增長。以這種方式,兩個空間沖突的機(jī)會就大大減少。進(jìn)程調(diào)用的動態(tài)
庫都存放在 0x40000000開始的地址處。

[color="sienna"]The kernel reserves virtual memory whenever a process or driver requests it, but it doesn’t
actually map in the underlying
physical memory until the memory is accessed (copy-on-write). So, the
physical DRAM is used only when it absolutely has to be, and the kernel
controls the allocation through a global memory management scheme.
Ideally, the kernel tries to allocate contiguous blocks of physical
memory as contiguous memory is most likely to evenly fill physically
tagged caches. Thus, the kernel organizes memory to grow inward from
the ends of physical memory, maximizing contiguous memory in the
middle. The physical memory map is described in detail in the next
section.

只要進(jìn)程或驅(qū)動程序請求內(nèi)存,內(nèi)核就留出虛擬內(nèi)存來,但,并不實(shí)際映射到真正的物理內(nèi)存,直到要訪問相應(yīng)的內(nèi)存時才進(jìn)行映
射(寫時復(fù)制)。因此,只有在萬不得已時才用到物理DRAM,內(nèi)核通過全局內(nèi)存管理模式控制分配。理想的情況下,內(nèi)核盡量分配連續(xù)的物理塊,這是因?yàn)檫B續(xù)
內(nèi)存很可能均勻地填充物理上緊挨的高速緩存。因此,內(nèi)核對內(nèi)存的組織采用從物理內(nèi)存的末端向內(nèi)方向增長,以圖在中間最大化連續(xù)內(nèi)存。物理內(nèi)存的映射在下一
部分將詳細(xì)給予描述。
               
               
               

本文來自ChinaUnix博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u1/50916/showart_1714598.html
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP