-4

Suppose we have 28 bit virtual address space and 32 bit physical address space. And frame size is 1kb. I want to convert virtual address 0x000039A to a physical address.

[my attempt] 1kb = 1024byte = 2^10 so virtual page number is 0x0000 and offset is 0x39A. In this page table, 0x00 has 0x0100 physical page number. So I thought the physical address number is 0x010039A but the answer is 0x0004039A . Does anyone can explain this ?

  • 1
    [Questions asking for *homework help* must include a summary of the work you've done so far to solve the problem, and a detailed description of the difficulty you are having solving it.](https://softwareengineering.meta.stackexchange.com/questions/6166/open-letter-to-students-with-homework-problems) *does not work*, *please help me* are not acceptable. –  Jun 25 '18 at 16:15
  • 1
    Please read [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question) before attempting to ask more questions. –  Jun 25 '18 at 16:15

1 Answers1

3

Lets do it step by step, even though the answers here could have helped you do it your self.

__________
| STEP 1 |
¯¯¯¯¯¯¯¯¯¯
0x000039A is in virtual, lets convert it to binary representation

0b 0000 0000 0000 0000 0011 1001 1010
0x   0    0    0    0    3    9    A

__________
| STEP 2 |
¯¯¯¯¯¯¯¯¯¯
Calculate the number of bits needed to reference the whole 1KB

1K = 2^10

==> 10 bits are needed. Just do log2(page-size).

__________
| STEP 3 |
¯¯¯¯¯¯¯¯¯¯
Take away the first 10 bits of the binary presentation

0b 0000 0000 0000 0000 0011 1001 1010

offset = 0b 11 1001 1010
       = 0x  3   9    A 

__________
| STEP 4 |
¯¯¯¯¯¯¯¯¯¯
Get the virtual page out of what ever bits left

0b (00)(00 00)(00 00)(00 00)(00 00)
=  0x00000

__________
| STEP 5 |
¯¯¯¯¯¯¯¯¯¯
Go to the page table at the entry 0x00000, there you will find the corresponding frame number.

Suppose the page table is given: 
________________
| 0x0 | 0x0100 |
| 0x1 | 0xA    |
|  .  |        |
|  .  |        |
|     |        |
----------------

__________
| STEP 6 |
¯¯¯¯¯¯¯¯¯¯
Turn the frame number to binary representation and concatenate it to the offset

Frame                           |      offset
0x0100                          |
0b (00)(00 00)(01 00)(00 00)(00 | 11) (1001) (1010)

0x 004039A
Tony Tannous
  • 14,154
  • 10
  • 50
  • 86