Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiprocessing Memory Management

Similar presentations

Presentation on theme: "Multiprocessing Memory Management"— Presentation transcript:

1 Multiprocessing Memory Management
Partitioning Relocation Fragmentation 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 Fragmentation Free A Finishes D starts Free B Finishes E starts
Process A Process B Process C Free 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 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 C D B A_1 C A_2 D A_rest

9 Fragmentation Problem of piecewise storage: slow access
More general solution: Rearrange memory content from time to time B C D 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 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: = address in page table last 12 bit: = 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:

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

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 =111111 =000100 =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 00 0 01 1 00 1 10 1 11 1 00 0 01 0 00 1 10 1 11 1 You request address: This results a page miss Assume page 13 (01) is the least used 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

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.

Download ppt "Multiprocessing Memory Management"

Similar presentations

Ads by Google