E N D
1. Memory Management-4 6th lecture
2. Review Relocatable dynamic partitions.
Bounds register and relocation register.
How often compaction can be done?
3. Exercise
4. MM: Recent Systems In earliest MM systems, contiguous memory blocks are needed to load the entire job.
The disadvantage will be eliminated in this chapter.
Paged memory allocation.
Demand paging memory allocation.
Segmented memory allocation.
Segmented/demand paged allocation.
5. Paged Memory Allocation Each job is divided into pages of equal size.
Disks are divided to sectors.
Memory is divided to page frames.
Page size = Sector size = Frame size
This means, one sector will hold one page of a job which fits into one frame of memory.
6. Paged Memory Allocation To execute a program:
Determining the number of program pages.
Locating enough memory frames in memory.
Loading ALL of the pages into frames.
Pages do not have to be loaded in adjacent memory blocks. i.e., each page can be stored in any available frame anywhere in memory.
7. Paged Memory Allocation Advantages:
Memory is used more efficiently (any frame can be used by any page of any job).
Compaction process is eliminated because there is no external fragmentation between page frame.
Disadvantages:
MM needs to keep track of frames, this will add more complexity to the OS.
Internal fragmentation is still a problem (but only in the last page of a job).
8. Example
9. Paged memory allocation How the MM keeps track of frames?
MM uses 3 tables:
Job Table (JT).
Page Map Table (PMT).
Memory Map Table (MMT).
JT: contains the size of each job and the location of the PMT of that job.
PMT: contains the page number and the corresponding frame address.
MMT: contains the location of each memory frame and its free/busy status.
10. Example
11. Paged memory allocation How to determine the location of a certain line?
Calculate the page #.
Calculate the displacement (offset) of the line.
The offset can be defined as how far a line is from the beginning of its page.
12. Paged memory allocation To find the address of a given line:
The line number is divided by the page size.
Keeping the remainder as an integer.
The resulting quotient is the page number.
The remainder is the displacement in that page.
Ex: If you know that the page size is 100, find the location of line 523.
Solution: 523/100 = 5(quotient), 23(remainder).
Then the line is located in page number 5 and 23 lines away from the beginning of that page.
13. Paged memory allocation This algorithm needs to be extended to find the exact location of the line in main memory.
This can be achieved by knowing the frame number that is corresponding to the requested page number via the PMT.
To know the beginning address of the frame in memory, the frame number is multiplied by the frame size.
14. EX: Given that, the page size is 512 bytes, find the exact location in memory of line 518.
Solution: 518/512= 1 (page #), 6 (offset).
From the table, frame# = 3
Starting address of frame3 = 3 * 512 = 1536
The exact address of line 518 in memory = 1536 + 6 = 1542
16. Advantages & Disadvantages Advantages:
Jobs are allocated in noncontiguous memory locations.
More efficient use of memory, more jobs can fit in it.
Compaction process is eliminated.
Disadvantages:
Overhead is increased due to address resolution.
Internal fragmentation is still a problem (in last page only).