New version page

UNO CSCI 4500 - Memory Management

Upgrade to remove ads
Upgrade to remove ads
Unformatted text preview:

© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 1CSCI 4500/8506Operating SystemsModule 10Memory Management – Part 2Updated: August 5, 2009© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 2In This Module…We conclude our study of memory management by considering how toreduce fragmentation,eliminate the need for contiguous memory, andremove the physical memory size limit on programs.We will first consider overlays, a semi-automatic technique for managing the residence of program modules.Most of this module, however, will focus on virtual memory, both paged and segmented, and some related theoretical results.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 3Q.How can we remove, or at least reduce, the relationship between program size and physical memory size?A.A variety of techniques have been proposed to solve this problem. We’ll look at overlays, paged virtual memory, and segmented virtual memory.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 4Overlays (Fotheringham, 1961)Rather than load an entire program into memory at once, we can divide it into those modules that are always required and those that are required only at certain times during program execution.Many program modules do not all need to be in memory at the same time. Thus we can develop a scheme that loads only those that are currently needed, leaving those that aren’t needed at the current time on secondary storage (disk).© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 5A Sample Programf1(){f1a();f1b();}f2() { … }main(){f1();f2();}mainf1 f2f1a f1bWe only need f1 or f2 in memory at any time. Likewise, only f1a orf1b need be in memory when f1 is executing.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 6Overlay ImplementationSeveral overlay implementations have been used in different systems. There are basically two schemes:Require the application to explicitly make system calls to bring the needed modules into memory before they are referenced.Allow the system (through the linker) to transparently modify the program to perform the necessary loading of overlay modules.In both schemes, the user must identify module dependencies, essentially a tree similar to that shown in the sample program just examined.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 7Problems With the Previous SchemesUsing fixed-sized partitions is wasteful and inefficient.Using variable-sized partitions, small holes are created. These small holes cannot be used for loading programs. Compaction, and the associated wasted time, must then be used.All schemes require the use of contiguous memory.Programs larger than the available physical memory cannot be run (except with overlays).Creating overlays is time consuming and potentially error-prone. The result will not necessarily be optimal for every situation. Modules may be loaded and unloaded unnecessarily, depending on the memory resources available when the program is executed.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 8A Memory “Wish List”Eliminate the need for contiguous memory for every process.Eliminate, or at least greatly reduce, the amount of memory wasted through internal and external fragmentation.Allow arbitrary program sizes without undue regard for the size of primary memory.Eliminate the need to manually determine program overlay structure.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 9Eliminating the Need for Contiguous MemoryIf a program isn’t stored in contiguous memory locations, then it must obviously be stored piecewise in several smaller pieces. Without loss of generality, we may assume each of these smaller pieces is contiguous.There are two basic approaches to this problem.In paged systems, each of the smaller pieces is exactly the same size, which is independent of the program characteristics. Paged systems are very common.In segmented systems, the smaller pieces are variable sized, and correspond to the functional modules of the program. Pure segmented systems are uncommon.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 10Addresses and Address SpacesA program has virtual addresses starting with 0, and it executes in a virtual address space, the set of all possible virtual addresses. Virtual addresses are what a program generates when it executes.Physical addresses are those corresponding to possible physical, or real, memory locations. Much of an operating system operates without the memory management features we’re considering, and thus uses physical addresses only. The physical address spaceis the set of all possible physical addresses.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 11Address and Memory Space SizesThe term virtual or physical address space refers to the set of all logically possible virtual or physical addresses, and depends only on the format of addresses (that is, the number of bits it contains).The term memory space refers to the set of all possible physical addresses for a real system, and depends on the amount of installed memory.For example, many modern processors support 64-bit addresses, but it’s unlikely any real system will have 264bytes of physical memory.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 12Address and Memory Space SizesWhile uncommon, it is not impossible for the size of the virtual address space to be different than the size of the physical address space. That is, there may be more or fewer bits in a virtual address than there are bits in the a physical address.As noted in the last slide, it is very common for the size of the virtual and physical address spaces to exceed the size of the memory space.© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 13Memory Terminology SummaryCPUMemory Management Unit (MMU)Physical (Real) MemoryVirtual Addresses (from Virtual Address Space)Physical Addresses (from Physical Address Space)Set of all actual addresses forms the Memory Space© 2008 Stanley A. Wileman, Jr. Operating Systems Slide 14Paged Memory ManagementTo use paged memory management:Divide the virtual address space used by a program into fixed sized pieces, each of which is called page. The size of each page is (somewhat obviously) called the page size.Divide the computer’s physical address space into page frames, each of which is the same size as a page.Put each page of the virtual address space into a previously unused page frame.Since any page frame can hold any page, there are no unusable


View Full Document
Download Memory Management
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Memory Management and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Memory Management 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?