Register to reply

Translate virtual address to physical address

by naspek
Tags: address, physical, translate, virtual
Share this thread:
naspek
#1
Dec13-10, 08:30 AM
P: 181
1. The problem statement, all variables and given/known data

A virtual memory system has a page size of 512 bytes, seven virtual pages, and four
physical page frames. The page table is as follows:
VPN.........PFN
0..............2
1..............0
2..............-
3..............1
4..............3
5..............-
6..............-
Note: VPN -> Virtual Page Number, PFN -> Page Frame Number


What physical address, if any, would each of the following virtual addresses
correspond to?
i. 0
ii. 2010
iii. 2046
iv. 3030
v. 1026

3. The attempt at a solution

i. 0============ 0000 0000 0000
ii. 2010========= 0111 1101 1010
iii. 2046========= 0111 1111 1110
iv. 3030======== 1011 1101 0110
v. 1026======== 0100 0000 0010

i've translate it to binary number already..
but.. i don't how to proceed..
can someone plz guide me..
Phys.Org News Partner Science news on Phys.org
World's largest solar boat on Greek prehistoric mission
Google searches hold key to future market crashes
Mineral magic? Common mineral capable of making and breaking bonds
Mark44
#2
Dec13-10, 09:35 AM
Mentor
P: 21,215
Quote Quote by naspek View Post
1. The problem statement, all variables and given/known data

A virtual memory system has a page size of 512 bytes, seven virtual pages, and four
physical page frames. The page table is as follows:
VPN.........PFN
0..............2
1..............0
2..............-
3..............1
4..............3
5..............-
6..............-
Note: VPN -> Virtual Page Number, PFN -> Page Frame Number


What physical address, if any, would each of the following virtual addresses
correspond to?
i. 0
ii. 2010
iii. 2046
iv. 3030
v. 1026

3. The attempt at a solution

i. 0============ 0000 0000 0000
ii. 2010========= 0111 1101 1010
iii. 2046========= 0111 1111 1110
iv. 3030======== 1011 1101 0110
v. 1026======== 0100 0000 0010

i've translate it to binary number already..
but.. i don't how to proceed..
can someone plz guide me..
I don't think converting the virtual address to binary is much help. I'm not certain, but I think what you need to do is to find the virtual page number for each virtual address, and then see which physical page that VPN is mapped to.

To do this, divide the virtual address by 512 using integer division. For example, your second virtual address is 2010. 2010/512 == 3, so the virtual page number is 3. From the information you provided, virtual page 3 maps to physical page 1.
naspek
#3
Dec13-10, 10:08 AM
P: 181
Quote Quote by Mark44 View Post
I don't think converting the virtual address to binary is much help. I'm not certain, but I think what you need to do is to find the virtual page number for each virtual address, and then see which physical page that VPN is mapped to.

To do this, divide the virtual address by 512 using integer division. For example, your second virtual address is 2010. 2010/512 == 3, so the virtual page number is 3. From the information you provided, virtual page 3 maps to physical page 1.
thanks for the idea..

now.. i proceed...

ii. 2010===== 2010/512
==========3.93 = 3 , virtual page number 3 maps to physical page 1..
but.. how do i get the physical address then?

Mark44
#4
Dec13-10, 10:30 AM
Mentor
P: 21,215
Translate virtual address to physical address

The remainder (or modulus) gives you the offset in the memory page. In C notation, this is 2010 % 512 == 474. In mathematical notation, this is 2010 (mod 512) = 474.
naspek
#5
Dec13-10, 05:36 PM
P: 181
Quote Quote by Mark44 View Post
The remainder (or modulus) gives you the offset in the memory page. In C notation, this is 2010 % 512 == 474. In mathematical notation, this is 2010 (mod 512) = 474.
get it.. then i need to change 474 to binary number to get my physical address?
Mark44
#6
Dec13-10, 06:38 PM
Mentor
P: 21,215
I don't see why you would need to do that. It's just an address. It could be 474 (decimal) or 1DA (hex) or 111011010 (binary). These all represent the same number, but in different bases.
naspek
#7
Dec13-10, 06:41 PM
P: 181
Quote Quote by Mark44 View Post
I don't see why you would need to do that. It's just an address. It could be 474 (decimal) or 1DA (hex) or 111011010 (binary). These all represent the same number, but in different bases.
thanks for the clarification.. but..
why do i need the table if, i can just do the calculation(divide by 512 and get the answer already)..?
Mark44
#8
Dec13-10, 06:59 PM
Mentor
P: 21,215
There's an important part you're missing. Rather than me telling you what it is, I will let you figure it out.

If the virtual address is 2010, what is the physical address?
naspek
#9
Dec13-10, 07:06 PM
P: 181
Quote Quote by Mark44 View Post
There's an important part you're missing. Rather than me telling you what it is, I will let you figure it out.

If the virtual address is 2010, what is the physical address?
the physical address is 0001 1101 1010.. right?
Mark44
#10
Dec13-10, 07:19 PM
Mentor
P: 21,215
How did you get that?
naspek
#11
Dec13-10, 07:30 PM
P: 181
Quote Quote by Mark44 View Post
How did you get that?
2010 mod 512 = 474

i change 474 into 12 bits binary number.. so.. i get 0001 1101 1010.. right?
Mark44
#12
Dec13-10, 07:32 PM
Mentor
P: 21,215
The 474 is just the offset within the page, but which page are we talking about? And by that, I mean, which physical page?
naspek
#13
Dec13-10, 07:36 PM
P: 181
Quote Quote by Mark44 View Post
The 474 is just the offset within the page, but which page are we talking about? And by that, I mean, which physical page?
ok... so..

VPN.........PFN
3..............1

it's on physical page 1.. right?

is it 1 is my physical address? can't be.. too odd...
Mark44
#14
Dec13-10, 07:42 PM
Mentor
P: 21,215
Yes, physical page 1. That's where the table comes in, so that you can translate a virtual page number to a physical page number.

OK, you have physical page 1, and an offset of 447. What's the physical address?
naspek
#15
Dec13-10, 07:49 PM
P: 181
Quote Quote by Mark44 View Post
Yes, physical page 1. That's where the table comes in, so that you can translate a virtual page number to a physical page number.

OK, you have physical page 1, and an offset of 447. What's the physical address?
ok... physical page number constitutes the upper portion of the physical address, while the page offset, constitutes the lower portion

so.. my physical address is...

1 | 0001 1101 1010

correct?
Mark44
#16
Dec13-10, 07:57 PM
Mentor
P: 21,215
No, that's too big. It would be helpful if you didn't change the numbers into binary. Your physical address is calculated using this formula:
physical address = (physical page number) * 512 + offset
naspek
#17
Dec13-10, 08:04 PM
P: 181
Quote Quote by Mark44 View Post
No, that's too big. It would be helpful if you didn't change the numbers into binary. Your physical address is calculated using this formula:
physical address = (physical page number) + offset
ok.. thanks for the formula..

*got question here.. is it [(physical page number)*512] + offset or..
................................. (physical page number) * (512 + offset)
the first one or the second formula is correct?

physical address = (1) * 512 + 474
.......................= 986 @ 0011 1101 1010
now.. this is the correct one?
Mark44
#18
Dec13-10, 08:06 PM
Mentor
P: 21,215
It's this one: (physical page number)*512 + offset

And 986 is the correct address.

To check: 986 / 512 = 1
and 986 (mod 512) = 474


Register to reply

Related Discussions
LAN address Computers 9
About physical address on a resume while traveling this summer Career Guidance 2
IP address Computers 4
Why was my IP address banned? Forum Feedback & Announcements 3