Download presentation
Presentation is loading. Please wait.
Published byPatricia Martin Modified over 8 years ago
1
Introduction to Paging
2
Readings r 4.3 of the text book
3
Outline r Introduction to Paging Concepts
4
Paging r Partition memory into small equal-size chunks and divide each process into the same size chunks r The chunks of a process are called pages and chunks of memory are called frames r Operating system maintains a page table for each process m Contains the frame location for each page in the process m Memory address consist of a page number and offset within the page
5
Page Example 0 1 2 3 Process A 0 1 2 3 0 1 2 Process B 7 8 9 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Frame Number A0 A1 A2 A3 B0 B1 B2
6
Paging r A program requires N free frames r There is a need to set up a page table to translate logical to physical addresses r Internal fragmentation
7
Address Translation Scheme r Address generated by CPU is divided into: m Page number (p) – used as an index into a page table which contains base address of each page in physical memory m Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit m The number of logical address bits is m page number page offset p d m - n n
8
Address Translation Scheme r If the number of logical address bits is m and the number of bits in the offset is n then r Logical address space is 2 m r Page size (number of entries) is 2 n r Example: m = 4, n = 2 r Number of address is 16 r Number of entries in a page is 4
9
Paging Hardware The hardware is referred to as the memory management unit (MMU)
10
Paging Hardware r The CPU issues a logical address (remember that all addresses are binary) r The hardware extracts the page number, p, and the page offset d r The page number, p, is used to index the page table m The entry in the page table consists of the frame number, f r The actual address is the concatenation of the bits that make up f and d.
11
Paging Example m=4 n=2 Page size of 4 bytes Physical memory of 32 bytes (8 pages) Binary representations: 0 00 1 01 2 10 3 11
12
Paging Example r First a little reminder. All addresses are in bits. The example on the previous page gives the base 10 equivalent of binary numbers 00000 10001 20010 30011 40100 50101 60110 70111 81000 91001 101010 111011 121100 131101 141110 151111
13
Example r Logical address in binary form is 0000 m From the bits we extract the page number as 00 and the offset as 00 m Page number 00 corresponds to the first entry of the page table. m There we find that the corresponding frame is 5 (or 0101) m The physical address produced is the concatenation of the bits of the frame number and the offset 010100 m In base 10 we find that the physical address is 20 (5*4+0)
14
Example r Logical address in binary form is 0101 m From the bits we extract the page number as 01 and the offset as 00 m Page number 01 corresponds to the second entry of the page table. m There we find that the corresponding frame is 6 (or 0110) m The physical address produced is the concatenation of the bits of the frame number and the offset 011000 m In base 10 we find that the physical address is 24(6*4+0) r What do you think logical address 13 maps to?
15
Observations r Let’s look at logical addresses: m 0000 (0), 0001 (1), 0010(2) and 0011(3) m The first two bits (page number) are the same m This means that these logical addresses will be in the same frame. m The position in the frame is determined by the offset r For a process its pages can be in any order m For our example page 1 is in a frame that appears “later” than the frame associated with page 2
16
Observations r The logical address space and the physical address space DO NOT have to be the same size r The logical address space can be larger then the physical address space (more on this later)
17
Paging r No external fragmentation m Any free frame can be allocated to a process that needs it r There may be some internal fragmentation m The memory requirements may not coincide with page boundaries m The last frame allocated may not be completely full
18
Paging r Internal fragmentation is on average one half page per process r Larger page sizes means more wasted space r Smaller page sizes means larger tables
19
Summary r This section introduced the concept of paging in memory
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.