OperatingSystemsCh7Memory Managementfrom a Programmer's Perspective1
Operating Systems Ch7 Memory Management from a Programmer’s Perspective 1
Why weneed memory management. The running program code requires memory- Because the CPU needs to fetch the instructions fromthe memoryforexecution We must keep several processes in memory-Improveboth CPUutilization and responsivenessMultiprogrammingIt is required to efficientlymanagethememory2
Why we need memory management • The running program code requires memory – Because the CPU needs to fetch the instructions from the memory for execution • We must keep several processes in memory – Improve both CPU utilization and responsiveness – Multiprogramming 2 It is required to efficiently manage the memory
TopicsinCh7Fromaprogrammer's perspective:user-spacememory managementWhat is the address space of a process?Howare the program code and data stored in memory?Howtoallocate/freememory (malloc()+free())?How much memory can be used in a program?What are segmentation and segmentation fault?From the kernel's perspective:Howto managethe memoryWhat is virtual memory?How to realize address mapping (paging)?Howto support very large programs (demand paging)?How to do page replacement?Whatis TLB?What is memory-mapped file?3
Topics in Ch7 3 What is the address space of a process? How are the program code and data stored in memory? How to allocate/free memory (malloc() + free())? How much memory can be used in a program? What are segmentation and segmentation fault? From a programmer’s perspective: user-space memory management What is virtual memory? How to realize address mapping (paging)? How to support very large programs (demand paging)? How to do page replacement? What is TLB? What is memory-mapped file? From the kernel’s perspective: How to manage the memory
Part 1:User-space memoryLocal variableDo you rememberthis?Contentof aprocess(inuser-spacememory)Dynamically-allocatedmemoryHowdoes each part usethe memory?Fromaprogrammer'sperspectiveGlobal variableLet's forgetabout thekernel for amoment.We are goingto explore theCode +user-spacememoryfirst.constantsProcess
4 Part 1: User-space memory Global variable Local variable Dynamically-allocated memory Code + constants Process Do you remember this? - Content of a process (in user-space memory) How does each part use the memory? - From a programmer’s perspective Let’s forget about the kernel for a moment. We are going to explore the user-space memory first
User-space memory management. Address space;Code & constantsData segment;Stack;Heap;Segmentation fault5
5 User-space memory management - Address space; - Code & constants; - Data segment; - Stack; - Heap; - Segmentation fault;