1 / 22

Multiprocessing Memory Management

Multiprocessing Memory Management. Partitioning Relocation Fragmentation Relocation Virtual Memory Swapping. Partitioning. Every process including OS needs its own part of memory Memory partitioning: One partition per process static (fixed) vs. dynamic partitioning

xuefang-jun
Download Presentation

Multiprocessing 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. Multiprocessing Memory Management • Partitioning • Relocation • Fragmentation • Relocation • Virtual Memory • Swapping

  2. Partitioning • Every process including OS needs its own part of memory • Memory partitioning: One partition per process • static (fixed) vs. dynamic partitioning • static disadvantage: waste, large programs can’t run • Relocation: After assigning a partition to a process you have to adjust all addresses in the program • Security: Every process has only access to its own memory • Bounds register

  3. Fixed Partition Example

  4. Swapping • Example: multiprocessing environment and a round robin scheduling • 2 big processes to execute that need partition 3 • either only allow one of them in the ready queue • or whenever you start the next process you have to liberate partition 3 to make room for the next one • “Swapping”: moving of memory content from and to disk as processes switch • Can be very expensive

  5. Dynamic Partitioning • No fixed size partition • Before a process starts running it allocates as much memory as it needs • You waste less memory, instead of waiting for partition 3, the second big process can have a combination of 1 and 2. • Same problem with swapping as before if the total size of all processes is bigger than total memory • Additional Problem: Fragmentation

  6. Round Robin and Swapping

  7. Free Process C Process B Process A Fragmentation A Finishes D starts B Finishes E starts C Finishes F starts What about G? Free Process F Free Process E Free G Process D

  8. B C D Fragmentation continued • Happens in all forms of memory that you can alter (RAM, disk …) • Hard drive solution: instead of looking for a block that is big enough you start saving and if you run into some used part you leave a link to the next B A_1 C A_2 D A_rest

  9. B C D Fragmentation • Problem of piecewise storage: slow access • More general solution: Rearrange memory content from time to time B C D

  10. Virtual Memory • Motivation • More flexibility with memory partitioning • Independence of Physical memory size and address space • physical memory (RAM) can be smaller than the total memory requirement of a process • address space is limited (bus size and ISA) than physical memory • Address is not a real physical address but has to be translated

  11. VM Example: Less physical memory than needed • RAM: 32K with address size is 15 bit • Job needs 64 K (“virtual” address size is 16 bit) • You could store half in RAM and second half on hard drive • You need data from 0010000000000100 • Determine: Is this location in RAM or on hard drive? • If RAM: find corresponding physical address and read • If hard drive: Load other half into RAM (done by OS), find corresponding physical address and read

  12. VM: Technical Solution • Instead of taking half’s you make smaller slices called pages • Page table keeps track which page is in physical memory and where • OS loads and stores pages from disk into physical memory (RAM) if a page miss happens • Address translation in Memory Management Unit (MMU) • each virtual address gets translated into a physical one

  13. Memory access

  14. Page Table • Task: • Virtual address is: 0010000000000100 • How do you find correct entry in page table? • How do you find the correct corresponding address?

  15. Simple Address translation Some address size computation: • Virtual address size: 16 • Physical address size: 15 • Table size: 16 entries • address size for table = 4 • Page size: 4K • How many bit do you need to find something within the page: 12 • Number of pages in RAM: 8 • You need 3 bit to find page

  16. Example • Virtual Address: 0010000000000100 • Split address: • first 4 bit: 0010 = address in page table • last 12 bit: 000000000100 = page offset • Look up physical page address in page table at address 0010 (entry 2): 110 • Recombine physical page address and page offset to physical address: • 110000000000100

  17. More Examples 00 0 00 0 01 1 00 1 00 0 00 0 10 1 00 0 00 0 11 1 00 0 00 0 00 0 00 0 00 0 00 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 • Convert the following virtual addresses given the page table: 01101111 11000100 10010010 Questions: • How big is physical memory? • How big is a page? • How many pages are in physical memory?

  18. Solutions • 16 entries in page table = 4 bit of virtual address to locate page will be replaces by 2 bit (content of page table) • Physical address has 6 bit, size= 26 • virtual address was 8 bit of which 4 were for page table: 4 bit remaining for page offset • Page size = 16 • 4 pages in physical memory 01101111=111111 11000100=000100 10010010=100010

  19. Page replacement strategy • If process requests an address that is not in physical memory the present bit in page table is 0 • OS interrupt: read page that contains that address into physical memory and save one old page to disk • Very similar to cache • Objective: • Keep pages that are likely to be used again • Minimize computational overhead • Strategies: • Least recently used • Oldest

  20. What has to be done in case of page replacement? • Write old page from physical memory to disk • Load new page into physical memory • Update page table: • Set present bit of old page to 0 • Insert physical page address in table at position given by first 4 bits of virtual address

  21. Example of Table Update 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 00 0 00 0 01 1 00 1 00 0 00 0 10 1 00 0 00 0 11 1 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 01 0 00 1 00 0 00 0 10 1 00 0 00 0 11 1 00 0 00 0 01 0 00 0 00 0 00 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 You request address: 00110111 This results a page miss Assume page 13 (01) is the least used

  22. Virtual Memory Summary • Allow programs to run with some of their pages missing • Hardware generates an interrupt if page table entry is missing (add column(s)to page table for missing entry) • External page table used to locate page on disk • Page paged in, and instruction re-executed • Can now run programs larger than physical memory • Programmers (usually) do not need to know size of real memory.

More Related