LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-21-2010, 01:30 AM   #1
pupillo
LQ Newbie
 
Registered: Jul 2009
Posts: 22

Rep: Reputation: 15
Question virtual address to physical memory access


Hi, a process is trying one access to memory, for example through an array (ex.: vect[0]=123. What happens?
Here below what I guess but I'm not sure and accept any comment (please, distinguish between "the system" and "the CPU" in case).
Let's suppose swapping to disk disbled.
We have two scenarios: without and with cache.

If no cache is present in the system:
1. The CPU must discover the phys addr of vect[0] virtual addr. To do that, has to read from 3 (or 2 depending on the system?) pages tables, stored in memory as well.
2. The CPU writes to the final address.
These mean 4 memory accesses.

If cache is present:
1. Like above but, if the pages tables are in cache, we have 3 accesses to that.
2. If the req. page is not in cache, it's reads from ram and transferred to it. Afterwards, cache is written.
In the best case we have 4 cache accesses.

Best regards
Pupillo
 
Old 02-21-2010, 07:35 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
You apparently don't know about the TLB, another cache-like thing that remembers complete translations.

So most often, the CPU finds the complete translation (virtual address to physical address) with one TLB access.
 
Old 02-22-2010, 10:07 AM   #3
pupillo
LQ Newbie
 
Registered: Jul 2009
Posts: 22

Original Poster
Rep: Reputation: 15
Yes, there is the TLB, but I didn't realized that it's an associative memory; I thought it was very fast but the CPU had to walk through its entries searching for that virtual address (or better virtual page start address). I knew that the TLB has very few entries.
Thanks
Tommaso
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to translate virtual address to physical address in linux application saurin Programming 1 11-18-2009 09:05 PM
How to access physical (as opposed to virtual) memory in C language for a Linux app. ss729 Programming 2 12-23-2008 03:02 PM
how to find physical address of kernel virtual address kushneeraj Programming 0 10-20-2006 07:29 PM
API for mapping Physical Address to Virtual Address Lakshman_smt Linux - Software 2 10-15-2006 09:08 PM
Memory Mapping (same physical address = virtual address) skd.tech Linux - Kernel 7 07-24-2006 11:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration