Worked example 1
A computer system uses paging for memory management. The page size is 4 KB (4096 bytes). A program requires a logical address of 18000. Calculate: (i) The page number. (ii) The offset within the page. (iii) If this page is mapped to physical frame 7, what is the physical address?
Show solution outline
(i) Page Number: To find the page number, we perform integer division of the logical address by the page size. Page Number = FLOOR(Logical Address / Page Size) Page Number = FLOOR(18000 / 4096) = FLOOR(4.3945...) = 4. So, the logical address is in page 4. [1 mark]
(ii) Offset: The offset is the remainder of the division, or can be calculated using the modulo operator. Offset = Logical Address MOD Page Size Offset = 18000 MOD 4096 = 1616. Alternatively: . The offset is 1616. [1 mark]
(iii) Physical Address: The physical address is calculated by multiplying the frame number by the page size and adding the offset. Physical Address = (Frame Number * Page Size) + Offset Physical Address = (7 * 4096) + 1616 Physical Address = 28672 + 1616 = 30288. [1 mark]