中国高校课件下载中心 》 教学资源 》 大学文库

《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 7 Memory Management part2

文档信息
资源类别:文库
文档格式:PDF
文档页数:125
文件大小:2.47MB
团购合买:点击进入团购
内容简介
《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 7 Memory Management part2
刷新页面文档预览

OperatingSystemsCh7, part 2Memory Management from the Kernel's Perspective:Virtual Memory Support1

Operating Systems Ch7, part 2 Memory Management from the Kernel’s Perspective: Virtual Memory Support 1

MemorymanagementHowto use the addresses to accessthe memory device?Local variableHowdomultipleprocess sharetheDynamically-allocatedsamephysicalmemorydevice?memoryHowto supportlargeprocess?Global variableHow does the CPU read what it wantsfromthememorydevice?Code +constantsProcessThekernel andthehardware are doinglots of managements.2

2 Memory management Global variable Local variable Dynamically-allocated memory Code + constants Process How to use the addresses to access the memory device? How do multiple process share the same physical memory device? How to support large process? How does the CPU read what it wants from the memory device? . The kernel and the hardware are doing lots of managements

Memory Management- Virtual memory;MMU implementation &pagingsDemand pagingPage replacement algorithmsAllocation of frames;(intel)Core"i73

3 Memory Management - Virtual memory; - MMU implementation & paging; - Demand paging; - Page replacement algorithms; - Allocation of frames;

CPU working-illustration thatyoumay know. Let's review the“fetch-decode-execute" cycle!memory busThisinstruction says(intel)"Movethe memoryCorei7valuein0x12345678totheregisterEAX".PCOXABCDEF00OXABCDEF00instructionmov0x12345678%EAXEAX0x000000000x12345678The integervalue:an integer0x0000000A4

CPU working – illustration that you may know • Let’s review the “fetch-decode-execute” cycle! 4 PC 0xABCDEF00 instruction memory bus EAX 0x00000000 0xABCDEF00 0x12345678 an integer mov 0x12345678 %EAX This instruction says: “Move the memory value in 0x12345678 to the register EAX”. The integer value: 0x0000000A

CPU working-illustration that you mayknow Let's review the “fetch-decode-execute" cycle!CPU decodesmemory busThis instruction says(intel)"Move the memoryCore"i7valuein0x12345678tothe register EAX".PCOXABCDEF00OXABCDEF00instructiormOv0x12345678%EAXEAX0X0000000A0x12345678The integer value:an integer0x0000000AHowtousetheaddresses?5

CPU working – illustration that you may know • Let’s review the “fetch-decode-execute” cycle! 5 PC 0xABCDEF00 instruction memory bus EAX 0x00000000 0xABCDEF00 0x12345678 an integer mov 0x12345678 %EAX 0x0000000A 1 3 2 CPU decodes This instruction says: “Move the memory value in 0x12345678 to the register EAX”. The integer value: 0x0000000A How to use the addresses?

"You've been living in a dream world, Neo'int main(void)($./same_addrint pid;PID 1234:0xbfe85e0c.pid=fork();PID1235:0xbfe85e0cprintf("pID%d:%p.ln"getpid(),&pid)$if(pid)Wait(NULL);return e;Can you guess the result?- Two different processes, the same variable name,carry different values-Usethesameaddress!(What? How COME?!)Well, what is the meaning of a memory address?!-Logical address:virtual memory-Address translationneeded (logical/virtual->physical)-Why we use virtual memory??6

“You’ve been living in a dream world, Neo” • Can you guess the result? – Two different processes, the same variable name, carry different values – Use the same address! (What? How COME?!) • Well, what is the meaning of a memory address?! – Logical address: virtual memory – Address translation needed (logical/virtual->physical) – Why we use virtual memory?? 6 int main(void) { int pid; pid = fork(); printf("PID %d: %p.\n", getpid(), &pid); if(pid) wait(NULL); return 0; } $ ./same_addr PID 1234: 0xbfe85e0c. PID 1235: 0xbfe85e0c. $ _

CPU working ... contiguous allocation? Each process is contained in a single section of memProcessCHoleProcessBHoleProcessA

CPU working . contiguous allocation? • Each process is contained in a single section of mem 7 Process A Process B Process C Hole Hole

CPU working ... contiguous allocation?. Problem #1..We also know that a process' memoryProcessCcan grow.HoleSo, does a process always have aProcessBchance to grow to reach its need?Holememory growthe.g., because of brk() callsProcessA8

CPU working . contiguous allocation? • Problem #1. 8 Process A Process B Process C Hole Hole memory growth e.g., because of brk() calls We also know that a process’ memory can grow. So, does a process always have a chance to grow to reach its need?

CPU working ... contiguous allocation?Problem #2..We are not talking about theprogram's size, but the process' size!What theCPU (or OS)can do is toWhatif wehaveaprocessgive up running ...that is larger that thephysical memory?So, we need to have the CPU designthat can understand processes so that:(1)theaddressspace isnolongerrequiredtobecontiguous.(2)itallowsaprocesstohaveasizebeyond the physical memory9

CPU working . contiguous allocation? • Problem #2. 9 Process A Process B Process C Hole Hole We are not talking about the program’s size, but the process’ size! What if we have a process that is larger that the physical memory? What the CPU (or OS) can do is to give up running . (1) the address space is no longer required to be contiguous. So, we need to have the CPU design that can understand processes so that: (2) it allows a process to have a size beyond the physical memory

Virtual memorysupportinmodernCPUs. The new design of the CPU includes a new module:the memory management unit (MMU)- MMU is designed to perform address translation.-TheMMUisanon-CPUdevicePhysical(inte)MemoryCore2ExrtrenMMUProgramMemoryMemoryBusANeWCPUAprocess'memoryisnolongercontiguousProgramCode10

Virtual memory support in modern CPUs • The new design of the CPU includes a new module: the memory management unit (MMU). – MMU is designed to perform address translation. – The MMU is an on-CPU device. 10

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档