converting a logical address to a physical address

25,432

Solution 1

2KB = 2^1 * 2^10 = 2^11 ---> 11 Bits, Not 14

Solution 2

The logic address is continuous, and you can follow steps

(1) calculate 2500/(2*1024)

the quotient is 1 --> page no. of logic address

the remainder is 452 --> offset of logic address -->same is offset of physical address

(2) find frame no. of physical address page no. (ie, 1 from above calculation) of logical address refers to. Unfortunately the mapping is not given in the question. Let's assume page 1 in logic address is mapped into frame 4 in physical address.

(3) the physical address is [frame no.]*[frame full length] + offset, i.e.,

4*(2*1024)+452 = 8644 or 0010000111000100 (binary) or 21c4(H).

Hope it helps.

Share:
25,432
Ohad
Author by

Ohad

Updated on June 04, 2020

Comments

  • Ohad
    Ohad almost 4 years

    There is a logical address space of 8 pages, and each page is 2KB.

    The physical address space has 4 frames (size of a frame equals the size of a page).

    I am given a sketch where there is an arrow from page number 0 to frame 1 that indicate a mapping between page 0 to frame 1.

    I need to find the physical address of the logical address 2500.

    I would like to know if my solution is correct.

    This is my solution: Because a size of a page is 2KB, that means that we need 14 bits for the offset. (cause 2KB=2^14) And there are 8 pages (0 to 7) so we need 3 bits for the page number.

    So the given virtual address in binary is: 000 00100111000100 =2500
    first 3 bits from left - 000 - indicates page number 0 the rest of the bits - 00100111000100 - indicates the offset 2500

    page 0 ----->frame 1 (mapping in the sketch)

    So my physical address will be: 0100100111000100 = 18884.

    first 2 bits -indicate the frame number- 01.
    rest of the bits - indicates the offset - 00100111000100. (there are 4 frames and therefor we need 2 bits for frame number).

    I ll appreciate a response.
    Thanks, Shiran