1 / 14

Memory Management

Memory Management. Chapter 7. Memory Management. Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory as possible should be able to run a program whose size is larger than the available real memory.

sagira
Download Presentation

Memory Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Memory Management Chapter 7

  2. Memory Management • Subdividing memory to accommodate multiple processes • Memory needs to be allocated efficiently to pack as many processes into memory as possible • should be able to run a program whose size is larger than the available real memory

  3. Memory Management Requirements • Relocation • Programmer (or the compiler) does not know where the program will be placed in memory when it is executed • While the program is executing, it may be swapped to disk and returned to main memory at a different location (relocated) • Memory references in the code must be translated to actual physical memory addresses

  4. Memory Management Requirements • Protection • Processes should not be able to reference memory locations in another process without permission • Impossible to check absolute addresses in programs since the program could be relocated. Therefore, • Must be checked at runtime • Operating system cannot anticipate all of the memory references a program will make • Sharing • Allow several processes to access the same portion of memory • Better to allow each process access to the same copy of the program (for read) rather than have their own separate copy

  5. Fixed Partitioning • Memory is divided into equal-sized partitions which are assigned to processes on demand • or unequal-sized partitions • Memory use is inefficient. Any program, no matter how small, occupies an entire partition. internal fragmentation

  6. Memory Assignment for Fixed Partitioning • Equal-size partitions:no strategy is needed; it does not matter • Unequal-size partitions • assign each process to the smallest partition within which it will fit. This way, we can minimize the wasted memory within a partition • Use one queue for each partition or a single queue for all

  7. Dynamic Partitioning • Processes are allocated exactly as much memory as required • Eventually holes will start appearing in the memory. This is called external fragmentation • Must use compaction to shift processes so they are contiguous and all free memory is in one block

  8. Memory Allocation Strategies forDynamic Partitioning Three popular strategies: • First-fit • Fastest • May have many processes loaded in the front end of memory that must be searched over when trying to find a free block • Best-fit • Chooses the block that is closest in size to the request • Worst performer overall • Since smallest block is found for a process external fragments are smallest. Memory compaction must be done more often • Next-fit • Similar to first fit but starts to search for free blocks beyond the last allocated block • Results in an even distribution of the free blocks throughout the memory

  9. Memory Configuration Before and After Allocation of a 16 Mbyte Block

  10. **here Buddy System • Entire space available is treated as a single block of 2U • If a request of size s is such that 2U-1 < s ≤ 2U, entire block of 2U is allocated • Otherwise block is split into two equal buddies • Splitting continues until smallest block greater than or equal to s is generated

  11. Paging • Partition memory into small equal-size chunks called frames • Divide each process into the same size chunks called pages • Operating system maintains a page table for each process • contains the frame location for each page in the process Pages of process A

  12. Page Tables 4 5 6

More Related