九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

CCH09_Memory Management(操作系統(tǒng))

上傳人:hjk****65 文檔編號:247455370 上傳時(shí)間:2024-10-18 格式:PPT 頁數(shù):77 大小:1.92MB
收藏 版權(quán)申訴 舉報(bào) 下載
CCH09_Memory Management(操作系統(tǒng))_第1頁
第1頁 / 共77頁
CCH09_Memory Management(操作系統(tǒng))_第2頁
第2頁 / 共77頁
CCH09_Memory Management(操作系統(tǒng))_第3頁
第3頁 / 共77頁

下載文檔到電腦,查找使用更方便

15 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《CCH09_Memory Management(操作系統(tǒng))》由會員分享,可在線閱讀,更多相關(guān)《CCH09_Memory Management(操作系統(tǒng))(77頁珍藏版)》請?jiān)谘b配圖網(wǎng)上搜索。

1、,單擊此處編輯母版標(biāo)題樣式,單擊此處編輯母版文本樣式,第二級,*,Module 9: Memory Management,Background(,背景),Logical versus Physical Address Space(,邏輯與物理地址空間),Contiguous Allocation(,連續(xù)分配),Paging(,分頁),Segmentation(,分段),Segmentation with Paging(,段頁式),Swapping (,交換),存儲層次結(jié)構(gòu),Background,Background,Program must be brought into memory and

2、 placed within a process for it to be executed.(,程序必需放入一個(gè)進(jìn)程,并且送入內(nèi)存才能被執(zhí)行),Input queue, collection of processes on the disk that are waiting to be brought into memory for execution.(,輸入隊(duì)列 磁盤上等待進(jìn)入內(nèi)存并執(zhí)行的進(jìn)程的集合),User programs go through several steps before being executed. (,用戶程序在執(zhí)行之前必需經(jīng)歷很多步驟),Background,

3、源程序,編譯,目標(biāo)模塊,庫,.,鏈接,程序,裝入模塊,裝入,程序,內(nèi)存,Logical vs. Physical Address Space,重定位,The concept of a logical,address space,that is bound to a separate,physical,address space,is central to proper memory management.,(,邏輯地址空間的概念同物理地址空間相關(guān)聯(lián),它是正確內(nèi)存管理的中心。),Logical address, generated by the CPU; also referred to as,

4、virtual address,.(,邏輯地址由,CPU,產(chǎn)生;也叫做虛擬空間。),Physical address, address seen by the memory unit.(,物理地址內(nèi)存設(shè)備所讀入的地址),Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme.,(

5、,邏輯和物理地址在編譯時(shí)期和裝入時(shí)期的地址綁定策略是相同的,而在執(zhí)行時(shí)間的地址綁定策略是不同的。),Binding of Instructions and Data to Memory,Compile time,(,編譯時(shí)期):,If memory location known a priori, absolute code can be generated; must recompile code if starting location changes.(,如果內(nèi)存位置已知,可生成絕對代碼;如果開始位置改變,需要重新編譯代碼),Load time,(,裝入時(shí)期):,Must generat

6、e,relocatable,code if memory location is not known at compile time.(,如果存儲位置在編譯時(shí)不知道,則必須生成可重定位代碼),Execution time,(,執(zhí)行時(shí)期):,Binding delayed until run time if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g.,base,and,limit regi

7、sters,). (,如果進(jìn)程在執(zhí)行時(shí)可以在內(nèi)存中移動(dòng),則地址綁定要延遲到運(yùn)行時(shí)。需要硬件對地址映射的支持,例如基址和限長寄存器),Address binding of instructions and data to memory addresses canhappen at three different stages.(,指令和數(shù)據(jù)綁定到內(nèi)存地址可以在三個(gè)不同的階段發(fā)生。),地址,重定位,將程序裝入到與其地址空間不一致的物理空間,所引起的一系列地址變換過程。,靜態(tài)地址重定位,在裝入一個(gè)作業(yè)時(shí),把作業(yè)中的指令地址全部轉(zhuǎn)換為絕對地址,在作業(yè)執(zhí)行過程中就無須再進(jìn)行地址轉(zhuǎn)換工作,。,動(dòng)態(tài)地址重定

8、位:動(dòng)態(tài)地址重地位是在程序執(zhí)行過程中,在,CPU,訪問內(nèi)存之前,將要訪問的程序或數(shù)據(jù)地址轉(zhuǎn)換成內(nèi)存地址. 動(dòng)態(tài)重定位依靠硬件地址變換機(jī)構(gòu)完成。,Memory-Management Unit (,MMU,),Hardware device that maps virtual to physical address.(,硬件把虛擬地址映射到物理地址),In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is s

9、ent to memory.(,在,MMU,策略中,基址寄存器中的值在其送入內(nèi)存的時(shí)候被加入到用戶進(jìn)程所產(chǎn)生的每個(gè)地址中。),The user program deals with,logical,addresses; it never sees the,real,physical addresses.(,用戶程序所對應(yīng)到的是邏輯地址,物理地址對它從來都不可見。),Memory-Management Unit (,MMU,),Overlays,Keep in memory only those instructions and data that are needed at any given

10、 time.(,只是在內(nèi)存中保留那些在特定時(shí)間所需要的指令和數(shù)據(jù)),Needed when process is larger than amount of memory allocated to it.(,當(dāng)進(jìn)程比所分配的內(nèi)存大時(shí),覆蓋是必需的),Implemented by user, no special support needed from operating system, programming design of overlay structure is complex.(,由用戶執(zhí)行,不需要操作系統(tǒng)的特別支持,覆蓋結(jié)構(gòu)的程序設(shè)計(jì)很復(fù)雜。),要求用戶清楚地了解程序的結(jié)構(gòu),并指定

11、各程序段調(diào)入內(nèi)存的先后次序,它是一種早期的主存擴(kuò)充的方式,Overlays,Dynamic Loading,Routine is not loaded until it is called.(,例程在調(diào)用之前并不執(zhí)行),Better memory-space utilization; unused routine is never loaded.(,更好的內(nèi)存空間利用率;沒有被使用的例程不被載入。),Useful when large amounts of code are needed to handle infrequently occurring cases.(,當(dāng)需要大量的代碼來處理不

12、經(jīng)常發(fā)生的事情時(shí)是非常有用的。),No special support from the operating system is required implemented through program design.(,不需要操作系統(tǒng)的特別支持,通過程序設(shè)計(jì)實(shí)現(xiàn)),Dynamic Linking,Linking postponed until execution time.(,鏈接被推遲到執(zhí)行時(shí)期),Small piece of code,stub, used to locate the appropriate memory-resident library routine.(,小的代碼片

13、- 存根,用來定位合適的保留在內(nèi)存中的庫程序。),Stub replaces itself with the address of the routine, and executes the routine.(,存根用例程地址來替換自己,以及執(zhí)行例程。),Operating system needed to check if routine is in processes memory address.(,操作系統(tǒng)需要檢查例程是否在進(jìn)程的內(nèi)存空間),Swapping,A process can be,swapped,temporarily out of memory to a,backing

14、store, and then brought back into memory for continued execution.(,一個(gè)進(jìn)程可以暫時(shí)被交換到內(nèi)存外的一個(gè)備份區(qū),隨后可以被換回內(nèi)存繼續(xù)執(zhí)行。),Backing store fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images.(,備份區(qū)是一個(gè)固定的足夠大的可以容納所有用戶內(nèi)存映像的拷貝;可以提供對這些內(nèi)存映像的直接存取。),

15、由操作系統(tǒng)控制,利用外存空間(進(jìn)程交換區(qū)),通過對進(jìn)程實(shí)體的整體交換,來滿足用戶進(jìn)程的內(nèi)存需要。它的主要特點(diǎn)是打破了進(jìn)程運(yùn)行的駐留性,Swapping,Roll out, roll in swapping variant used for priority-based scheduling algorithms; lower-priority process is swapped out so higher-priority process can be loaded and executed.,(,滾入,滾出交換由于基于優(yōu)先級的算法而不同,低優(yōu)先級的進(jìn)程被換出,這樣高優(yōu)先級的進(jìn)程可以被裝入和

16、執(zhí)行。),Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped.,(,交換時(shí)間的主要部分是轉(zhuǎn)移時(shí)間,總的轉(zhuǎn)移時(shí)間直接同交換的內(nèi)存的數(shù)量成比例。),Modified versions of swapping are found on many systems, i.e., UNIX and Microsoft Windows.,(,在許多系統(tǒng)如:,UNIX,Windows,中,可以找到一些被修正過的交換措施。),S

17、chematic View of Swapping,Contiguous Allocation,Main memory usually divided into two partitions:(,主存通常被分為兩部分),Resident operating system, usually held in low memory with interrupt vector.(,為操作系統(tǒng)保留的部分,通常用中斷矢量保存在內(nèi)存低端。),User processes then held in high memory.(,用戶進(jìn)程保存在內(nèi)存高端。),Contiguous Allocation,連續(xù)分配方式

18、:為一個(gè)程序分配一段連續(xù)的內(nèi)存空間,主要有:,單獨(dú)分區(qū)管理方式;,多分區(qū)管理方式,是一種可用于多道程序的較簡單的存儲管理方式,又分為,:,固定分區(qū)方式,可變分區(qū)方式,Single-partition allocation(,單獨(dú)分區(qū)分配),Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data.,(,基址寄存器策略由來保護(hù)用戶進(jìn)程(同其他進(jìn)程和改變的操作系統(tǒng)代碼和數(shù)據(jù)分開。),Relocation reg

19、ister contains value of smallest physical address; limit register contains range of logical addresses each logical address must be less than the limit register. (,基址寄存器包含最小物理地址的值;限長寄存器包含邏輯地址的范圍,每個(gè)邏輯地址必需比限長寄存器的值小。),Contiguous Allocation,固定分區(qū)(,Fixed Partitioning),分配,固定式分區(qū)是在,作業(yè)裝入之前,,內(nèi)存就被劃分成若干個(gè)固定大小的連續(xù)分區(qū)

20、。,劃分工作可以由系統(tǒng)管理員完成,也可以由操作系統(tǒng)實(shí)現(xiàn)。,一旦劃分完成,在系統(tǒng)運(yùn)行期間不再重新劃分,即分區(qū)的個(gè)數(shù)不可變,分區(qū)的大小不可變,所以,固定式分區(qū)又稱為,靜態(tài)分區(qū)。,劃分分區(qū)的方法如下:,分區(qū)大小相等,:只適用于多個(gè)相同程序的并發(fā)執(zhí)行(處理多個(gè)類型相同的對象),缺乏靈活性。,分區(qū)大小不等,:多個(gè)小分區(qū)、適量的中等分區(qū)、少量的大分區(qū)。根據(jù)程序的大小,分配當(dāng)前空閑的、適當(dāng)大小的分區(qū)。,固定分區(qū)(大小相同,),固定分區(qū)(多種大小),固定分區(qū),(,Fixed Partitioning,),分配,一般將內(nèi)存的用戶區(qū)域劃分成大小不等的分區(qū),可適應(yīng)不同大小的作業(yè)的需要,系統(tǒng)有一張,分區(qū)說明表,,每個(gè)

21、表目說明一個(gè)分區(qū)的大小、起始地址和是否已分配的使用標(biāo)志,分區(qū)說明表和內(nèi)存分配圖如下所示。,區(qū)號,大小,起址,標(biāo)志,1,16K,20K,已分配,2,32K,36K,已分配,3,64K,68K,已分配,4,124K,132K,未分配,分區(qū)說明表,內(nèi)存分配圖,固定分區(qū)分配,優(yōu)點(diǎn):易于實(shí)現(xiàn),開銷小。,缺點(diǎn):,分區(qū)大小固定,:,內(nèi)碎片,分區(qū)總數(shù)固定,:,限制并發(fā)執(zhí)行的進(jìn)程數(shù)目。,采用的數(shù)據(jù)結(jié)構(gòu):分區(qū)表記錄分區(qū)的大小和使用情況,Contiguous Allocation (Cont.),Multiple-partition allocation(,多分區(qū)分配),Hole, block of availab

22、le memory; holes of various size are scattered throughout memory.(,分區(qū)可用的內(nèi)存塊,不同大小的分區(qū)分布在整個(gè)內(nèi)存中。),When a process arrives, it is allocated memory from a hole large enough to accommodate it.(,當(dāng)一個(gè)進(jìn)程到來的時(shí)候,它將從一個(gè)足夠容納它分區(qū)中分配內(nèi)存。),Operating system maintains information about(,操作系統(tǒng)包含以下信息),:,a) allocated partitions

23、 (,分配的分區(qū)),b) free partitions (hole)(,空的分區(qū)),OS,process 5,process 8,process 2,OS,process 5,process 2,OS,process 5,process 2,OS,process 5,process 9,process 2,process 9,process 10,空閑分區(qū)的管理,序號,大小,起址,狀態(tài),1,48K,116K,空閑,2,252K,260K,空閑,3,-,-,空表目,4,-,-,空表目,5,-,-,空表目,空閑分區(qū)表,N,個(gè)字節(jié),可 用,前向,指針,后向,指針,空閑分區(qū)鏈,Contiguous

24、Allocation (Cont.),Dynamic Storage-Allocation Problem,First-fit(,首先適應(yīng)):,Allocate the,first,hole that is big enough.(,分配最先找到的合適的分區(qū)。),Best-fit,(最佳適應(yīng)):,Allocate the,smallest,hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. (,搜索整個(gè)序列,找到適合條件的最小

25、的分區(qū)進(jìn)行分配。),Worst-fit(,最差適應(yīng)):,Allocate the,largest,hole; must also search,entier,list. Produces the largest leftover hole.(,搜索整個(gè)序列,尋找最大的分區(qū)進(jìn)行分配。),How to satisfy a request of size,n,from a list of free holes.,(,怎樣從一個(gè)空的分區(qū)序列中滿足一個(gè)申請需要。),First-fit and best-fit better than worst-fit in terms of speed and sto

26、rage utilization.(,在速度和存儲的利用上,首先適應(yīng)和最佳適應(yīng)要比最差適應(yīng)好。),首次適應(yīng)算法(,First Fit),從空閑分區(qū)表的第一個(gè)表目開始查找,把找到的第一個(gè)滿足要求的空閑區(qū)分配給作業(yè),目的在于,減少查找時(shí)間,。通常將空閑分區(qū)表(空閑區(qū)鏈)中的,空閑分區(qū)要按地址由低到高進(jìn)行排序。,特點(diǎn):,分配和釋放的時(shí)間性能較好,較大的空閑分區(qū)可以被保留在內(nèi)存高端。,隨著低端分區(qū)不斷劃分而產(chǎn)生較多小分區(qū),每次分配時(shí)查找時(shí)間開銷會增大。,在系統(tǒng)不斷地分配和回收中,必定會出現(xiàn)一些不連續(xù)的小的空閑區(qū),稱為外碎片。雖然可能所有碎片的總和超過某一個(gè)作業(yè)的要求,但是由于不連續(xù)而無法分配。,最佳適

27、應(yīng)算法(,Best Fit),從全部空閑區(qū)中找出能滿足作業(yè)要求的、且最小的空閑分區(qū),.,能使碎片盡量小,為提高查找效率,空閑分區(qū)表(空閑區(qū)鏈)中的,空閑分區(qū)要按從小到大進(jìn)行排序,,自表頭開始查找到第一個(gè)滿足要求的自由分區(qū)分配,特點(diǎn):,從個(gè)別來看,外碎片較小,但從整體來看,會形成較多無法利用的碎片。,較大的空閑分區(qū)可以被保留。,Contiguous Allocation (Cont.),Fragmentation,External fragmentation(,外碎片) ,total memory space exists to satisfy a request, but it is not

28、contiguous.(,整個(gè)內(nèi)存空間用來滿足一個(gè)請求,但它不是連續(xù)的。),Internal fragmentation(,內(nèi)碎片) ,allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.(,分配的內(nèi)存可能比申請的內(nèi)存大一點(diǎn),這兩者之間的差別是內(nèi)部不被使用的簇),緊縮,Reduce external fragmentation by compaction(,通過壓縮來減少外

29、碎片),Shuffle memory contents to place all free memory together in one large block.(,把一些小的空閑內(nèi)存結(jié)合成一個(gè)大的塊。),Compaction is possible,only,if relocation is dynamic, and is done at execution time.(,只有重置是動(dòng)態(tài)的時(shí)候,才有可能進(jìn)行壓縮,壓縮在執(zhí)行時(shí)期進(jìn)行),I/O,problem(I,/O,問題),Latch job in memory while it is involved in I/O.(,當(dāng),I/O,的時(shí)候

30、,把工作鎖定在內(nèi)存中。),Do I/O only into OS buffers.(,只對操作系統(tǒng)的緩沖區(qū)進(jìn)行,I/O。),Fragmentation,實(shí)現(xiàn)緊湊的技術(shù)必須獲得硬件支持。,只有具有動(dòng)態(tài)重定位硬件機(jī)構(gòu)的計(jì)算機(jī)系統(tǒng),才有可能采用動(dòng)態(tài)重定位可變分區(qū)管理技術(shù),,系統(tǒng)的硬件包括重定位寄存器和加法器。,Paging,分頁存儲管理是解決存儲碎片的一種方法。,Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is ava

31、ilable.(,進(jìn)程的邏輯地址空間可能是不連續(xù)的,如果有可用的物理內(nèi)存,它將分給進(jìn)程。),Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8192 bytes).(,把物理內(nèi)存分成大小固定的塊。),Divide logical memory into blocks of same size called pages.(,把邏輯內(nèi)存也分為固定大小的塊,叫做頁。),Keep track of all free frames.(,保留一個(gè)頁

32、的記錄。),To run a program of size n pages, need to find,n,free frames and load program.(,運(yùn)行一個(gè)有,N,頁大小的程序,需要找到,N,個(gè)空的頁框讀入程序。),Set up a page table to translate logical to physical addresses. (,建立一個(gè)頁表,把邏輯地址轉(zhuǎn)換為物理地址。),Internal fragmentation.(,內(nèi)碎片。),Address Translation Scheme,Address generated by CPU is divide

33、d into(CPU,產(chǎn)生的地址被分為):,Page number,(p),(,頁號),used as an index into a,page,table,which contains base address of each page in physical memory.(,它包含每個(gè)頁在物理內(nèi)存中的基址,用來作為頁表的索引。),Page offset,(d),(,偏移),combined with base address to define the physical memory address that is sent to the memory unit.(,同基址相結(jié)合,用來確

34、定送入內(nèi)存設(shè)備的物理內(nèi)存地址。),For given logical address space 2m and page size 2n,page number,page offset,p,d,m - n,n,Address Translation Architecture,地址結(jié)構(gòu),圖中的地址長度為32位,允許地址空間的大小最多為1,M,個(gè)頁。,P = A/L,(,整除),W=A MOD L,(,取余),程序經(jīng)過編譯鏈接后形成邏輯地址,對某特定機(jī)器其地址結(jié)構(gòu)是一定的。若給定一個(gè)邏輯地址為,A(,十進(jìn)制,),,頁面大小為,L,,則頁號,P,和頁內(nèi)地址,W,可按下式求得:,Paging Exam

35、ple,Paging Example,Implementation of Page Table,Page table is kept in main memory.(,頁表被保存在主存中),Page-table,base register (,PTBR) points to the page table.(,頁表基址寄存器指向頁表),Page-table length register,(PRLR) indicates size of the page table.(,頁表限長寄存器表明頁表的長度),In this scheme every data/instruction access re

36、quires two memory accesses. One for the page table and one for the data/instruction.(,在這個(gè)機(jī)制中,每一次的數(shù)據(jù)/指令存取需要兩次內(nèi)存存取,一次是存取頁表,一次是存取數(shù)據(jù)),The two memory access problem can be solved by the use of a special fast-lookup hardware cache called,associative registers,or,translation look-aside buffers,(,TLBs,). (,

37、通過一個(gè)聯(lián)想寄存器,可以解決兩次存取的問題),Implementation of Page Table,Associative Register,Associative registers parallel search (,聯(lián)想寄存器并行查找),Address translation (A, A)(,地址轉(zhuǎn)換),If A is in associative register, get frame # out. (,如果,A,在聯(lián)想寄存器中,把頁框#取出來。),Otherwise get frame # from page table in memory.(,否則從內(nèi)存中的頁表中取出頁框#。)

38、,Page,#,Frame #,Effective Access Time,Associative Lookup =, time unit(,聯(lián)想寄存器的查找需要時(shí)間,),Assume memory cycle time is 1 microsecond(,假設(shè)內(nèi)存一次存取要1微秒),Hit ration percentage of times that a page number is found in the associative registers; ration related to number of associative registers.(,命中率在聯(lián)想寄存器中找到頁號的比

39、率,比率與聯(lián)想寄存器的大小有關(guān)。),Hit ratio = ,Effective Access Time (EAT)(,有效存取時(shí)間),EAT = (1 +,) + (2 + )(1 ),= 2 + ,Effective Access Time,例如,假設(shè)檢索聯(lián)想存儲器的時(shí)間為20,ns,,訪問內(nèi)存的時(shí)間為100,ns,,訪問聯(lián)想存儲器的命中率為85%,則,CPU,存取一個(gè)數(shù)據(jù)的平均時(shí)間,:,T=0.85*120+0.15*220=135ns,,訪問時(shí)間只增加35%。如果不引入聯(lián)想存儲器,其訪問將延長一倍(達(dá)200,ns)。,頁式地址變換,虛地址(邏輯地址、程序地址)以十六進(jìn)制、八進(jìn)制、二進(jìn)制

40、的形式給出,將虛地址轉(zhuǎn)換成二進(jìn)制的數(shù);,按頁的大小分離出頁號和位移量(低位部分是位移量,高位部分是頁號),虛地址以十進(jìn)制數(shù)給出,頁號虛地址頁大小,位移量虛地址,mod,頁大小,以頁號查頁表,得到對應(yīng)頁裝入內(nèi)存的塊號,內(nèi)存地址塊號頁大小位移量,舉例,例1:有一系統(tǒng)采用頁式存儲管理,有一作業(yè)大小是8,KB,,頁大小為2,KB,,依次裝入內(nèi)存的第7、9、,A、5,塊,試將虛地址0,AFEH,1ADDH,轉(zhuǎn)換成內(nèi)存地址。,虛地址0,AFEH,0000 1,010 1111 1110,P1,W010 1111 1110,MR0100 1,010 1111 11104AFEH,虛地址1,ADDH,0001

41、 1,010 1101,1101,P3,W010 1101,1101,MR,0010 1,010 1101 1101,2ADDH,Memory Protection,Memory protection implemented by associating protection bit with each frame.(,內(nèi)存的保護(hù)由與每個(gè)頁框相連的保護(hù)位來執(zhí)行。),Valid-invalid,bit attached to each entry in the page table(,有效-無效位附在頁表的每個(gè)表項(xiàng)中):,“,valid” indicates that the associate

42、d page is in the process logical address space, and is thus a legal page.(,“,有效,”,表明相關(guān)的頁在進(jìn)程的邏輯地址空間,以及是一個(gè)合法的頁。),“,invalid” indicates that the page is not in the process logical address space.(,“,無效,”,表明頁不在進(jìn)程的邏輯地址空間中。),Memory Protection,Two-Level Page-Table Scheme,將頁表進(jìn)行分頁,。每個(gè)頁面的大小與內(nèi)存物理塊的大小相同,并為它們進(jìn)行編號,

43、可以離散地將各個(gè)頁面分別存放在不同的物理塊中,為此再建立一張頁表,稱為外層頁表(頁表目錄),即第一級頁表,其中的每個(gè)表目是存放某個(gè)頁表的物理地址。第二級才是頁表(其中每個(gè)物理塊上的頁表叫做頁表分頁),其中的每個(gè)表目所存放的才是頁的物理塊號,。,Two-Level Page-Table Scheme,Two-Level Paging Example,A logical address (on 32-bit machine with 4K page size) is divided into(,一個(gè)邏輯地址被分為):,a page number consisting of 20 bits.(,一個(gè)

44、20位的頁號。),a page offset consisting of 12 bits.(,一個(gè)12位的偏移。),Since the page table is paged, the page number is further divided into(,頁表頁被分為):,a 10-bit page number. (,一個(gè)10位的頁號。),a 10-bit page offset.(,一個(gè)10位的偏移。),Thus, a logical address is as follows(,因此,一個(gè)邏輯地址表示如下):,where,p,i,is an index into the outer

45、page table, and,p,2,is the displacement within the page of the outer page table.,page number,page offset,p,i,p,2,d,10,10,12,Address-Translation Scheme,Address-translation scheme for a two-level 32-bit paging architecture(,一個(gè)兩級32位分頁結(jié)構(gòu)的地址轉(zhuǎn)換機(jī)制),Multilevel Paging and Performance,Since each level is stor

46、ed as a separate table in memory, covering a logical address to a physical one may take four memory accesses.(,由于每一級都分開的以表的形式存儲在內(nèi)存中,把一個(gè)邏輯地址轉(zhuǎn)換為一個(gè)物理地址可能要進(jìn)行4次內(nèi)存存取。),Even though time needed for one memory access is quintupled, caching permits performance to remain reasonable.(,盡管每次內(nèi)存存取的時(shí)間是很大的,高速緩存使執(zhí)行的時(shí)間

47、還是可以接受的。),Cache hit rate of 98 percent yields(,如果緩存的命中率有98%)則:,effective access time = 0.98 x 120 + 0.02 x 520,= 128 nanoseconds.which is only a 28 percent slowdown in memory access time.(,這只把內(nèi)存存取時(shí)間降低了28%。),Inverted Page Table,One entry for each real page of memory.(,一個(gè)內(nèi)存中頁的表項(xiàng)。),Entry consists of th

48、e virtual address of the page stored in that real memory location, with information about the process that owns that page.(,表項(xiàng)包含真正內(nèi)存地址的頁的虛擬地址,它包括擁有這個(gè)頁的進(jìn)程的信息。),Decreases memory needed to store each page table, but increases time needed to search the table when a page reference occurs.,(,減少內(nèi)存需要儲存每個(gè)頁表,

49、但是當(dāng)訪問一個(gè)頁時(shí),尋找頁表需要增加時(shí)間。),Use hash table to limit the search to one or at most a few page-table entries.(,使用哈希表來減少搜索。),Inverted Page Table Architecture,Shared Pages,Shared code(,共享代碼),One copy of read-only (reentrant) code shared among processes (i.e., text editors, compilers, window systems).(,一個(gè)只讀(可再

50、入)代碼可由進(jìn)程共享。),Shared code must appear in same location in the logical address space of all processes.(,共享代碼出現(xiàn)在所有進(jìn)程的邏輯地址空間的相同位置。),Private code and data (,私有代碼和數(shù)據(jù)),Each process keeps a separate copy of the code and data.(,每個(gè)進(jìn)程保留一個(gè)代碼和數(shù)據(jù)的私有拷貝。),The pages for the private code and data can appear anywhere

51、in the logical address space.(,私有代碼和數(shù)據(jù)的頁可以出現(xiàn)在邏輯地址空間的任何地方。),Shared Pages Example,Segmentation,Memory-management scheme that supports user view of memory. (,內(nèi)存管理機(jī)制支持用戶觀點(diǎn)的內(nèi)存。),A program is a collection of segments. A segment is a logical unit such as(,一個(gè)程序是一些段的集合,一個(gè)段是一個(gè)邏輯單位,如:):,main program,procedure,

52、function,local variables, global variables,common block,stack,symbol table, arrays,Logical View of Segmentation,1,4,2,3,user space,physical memory space,Segmentation Hardware,Segmentation Architecture,Logical address consists of a two,tuple,(,一個(gè)邏輯地址是兩個(gè)向量的集合):,Segment table,maps two-dimensional physi

53、cal addresses; each table entry has(,段表 - 映射二維物理地址,每個(gè)表項(xiàng)包括):,base,contains the starting physical address where the segments reside in memory.(,基址 - 包括內(nèi)存中段物理地址的起始地址。),limit, specifies the length of the segment.(,限長 - 指定段的長度。),Segment-table base register (STBR),points to the segment tables location in

54、memory.(,段表基址寄存器指向段表在內(nèi)存中的地址。),Segment-table length register (STLR),indicates number of segments used by a program;(,段表限長寄存器表明被一個(gè)程序所使用的段的數(shù)目。),segment number,s,is legal if,s, STLR.,Segmentation Architecture (Cont.),Relocation.(,重定位),dynamic(,動(dòng)態(tài)),by segment table (,由段表來執(zhí)行),Sharing.(,共享),shared segments

55、(,共享的段),same segment number (,同樣的段號),Allocation.(,分配),first fit/best fit(,首先/最佳適配),external fragmentation(,外碎片),Segmentation Architecture (Cont.),Protection. With each entry in segment table associate(,保護(hù),每個(gè)段表的表項(xiàng)有):,validation bit(,有效位) = 0,illegal segment,read/write/execute privileges(,讀/寫/執(zhí)行權(quán)利),Pr

56、otection bits associated with segments; code sharing occurs at segment level.(,保護(hù)位同段相聯(lián)系,在段的級別進(jìn)行代碼共享。),Since segments vary in length, memory allocation is a dynamic storage-allocation problem.(,由于段的各個(gè)長度不同,內(nèi)存分配是一個(gè)動(dòng)態(tài)存儲-分配問題。),A segmentation example is shown in the following diagram,(,下面的是一個(gè)段的例子),Segmen

57、tation with Paging Intel 386,As shown in the following diagram, the Intel 386 uses segmentation with paging for memory management with a two-level paging scheme.(,如下圖所示,,Intel 386,使用段頁結(jié)合來進(jìn)行二級分頁的內(nèi)存管理。),Comparing Memory-Management Strategies,Hardware support(,硬件支持),Performance(,執(zhí)行),Fragmentation(,碎片),

58、Relocation(,重定位),Sharing (,共享),Protection(,保護(hù)),Swapping (,交換),(1),存儲分配和回收:是存儲管理的主要內(nèi)容。討論其算法和相應(yīng)的數(shù)據(jù)結(jié)構(gòu)。,(2),地址變換:可執(zhí)行文件生成中的鏈接技術(shù)、程序加載時(shí)的重定位技術(shù),進(jìn)程運(yùn)行時(shí)硬件和軟件的地址變換技術(shù)和機(jī)構(gòu)。,(3),存儲共享和保護(hù):代碼和數(shù)據(jù)共享,對地址空間的訪問權(quán)限(讀、寫、執(zhí)行)。,(4),存儲器擴(kuò)充:它涉及存儲器的邏輯組織和物理組織,;,存儲管理的功能,由應(yīng)用程序控制:覆蓋;,由,OS,控制:交換(整個(gè)進(jìn)程空間),請求調(diào)入和預(yù)調(diào)入(部分進(jìn)程空間),8.3 Example: The I

59、ntel Pentium,Supports both segmentation and segmentation with paging,CPU generates logical address,Given to,segmentation unit,Which produces linear addresses,Linear address given to,paging unit,Which generates physical address in main memory,Segmentation and Paging units form the equivalent of MMU,L

60、ogical to Physical Address Translation in Pentium,每個(gè)進(jìn)程最多有16,K,個(gè)段,每個(gè)段最長達(dá)4,GB,,頁大小為,4,KB。,邏輯地址為(,selector, offset),,其中,selector,為16位,包括13位的段號、1位指出是,GDT,還是,LDT,中的段,2位作為保護(hù)位。,進(jìn)程的邏輯地址空間分為兩部分,:,第一部分,:8K,個(gè)私有段,其信息放在,LDT,中,;,第二部分,: 8K,個(gè)共享段,其信息放在,GDT,中,;,GDT:Global Descriptor Table,共享段表。,LDT:Local Descriptor T

61、able,私有段表,Segmentation with Paging Pentium,物理地址為32位,采用兩級分頁,每一級為10位,頁內(nèi)偏移為12位,物理地址的形成,:,段寄存器指向相應(yīng)的段表得到該段的基址,基址與,offset,相加形成一個(gè)線性地址,.,該線性地址被分為兩個(gè),10,位的頁號和一個(gè),12,位的偏移量,兩個(gè),10,位的頁號經(jīng)兩級頁表可以得到該頁的起始地址,該起始地址與偏移量相拼接,得到物理地址,.,為了提高物理內(nèi)存的使用效率,其頁表可以交換到磁盤上,.,Segmentation with Paging Pentium,Intel Pentium Segmentation,Pentium Paging Architecture,Example : Linear Address in Linux,Broken into four parts,The number of bits in each part of the linear address varies according to the architecture,Three-level Paging in Linux,

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!