[Autogenerated] mutual address translation is done by the processor.
Every address encountered while reading code or trying to access data is
interpreted as a mutual address which means it needs to be translated to
where it actually is in physical memory if at all.
And so our input is some virtual address and that virtual address
consists of just a simple address but remember everything in terms of
memory is always managed in chunks of pages and the standard page size
is four kB which means that translation is also about page is not
about the particular bike.
And so if you look at the lower 12 bits of the address, that's the four K range.
This is never actually being translated,
it's simply going to be copied as is to the final address in
physical memory if the translation is successful.
So the purpose of the CPU here is to translate the mutual
page number and then get to the where the actual physical
page number is in physical memory.
The bite within the page, the offset is always copied as is to the final address.
So this is what it's supposed to look like now.
How does the CPU perform this translation?
The CPU has to consult some database and that
consists of various data structures, some of them known as page directories,
some of them are called page tables which will see in the next videos as
we dig deeper into specifics of a certain translation.
And so these tables are prepared by the memory manager up
front to allow the CPU to do the right thing.
The CPU will blindly go and look at these tables to make the conversion
happen or the translation happen as we'll see there's another item here
that the CPU uses which is very important for a performance perspective
but not important from a conceptual perspective and this is sometimes
referred to as the translation.
Look aside buffer or T L.
B.
So the T L B is a cache of recently tried translated pages
because as we'll see in the next few slides,
translation actually requires extra memory access which means that we have
some penalty here in order to perform the actual translation.
We first have to go through more memory accesses before
actually getting to the real address we're supposed to be
accessing from the Cpus perspective.
So the T.
L.
B.
Is there to help when you access pages that we have
recently accessed the superiority,
knows where that page is in physical memory so it can consult the
teal be cash and just go there directly without having to go
through the translation process again.
And so accessing memory which is close by is always going to be better than
trying to access memory which is far away from the previous access because
that would very likely will not be in the T.
L.
B.
cache in any case it's not something I'm going to discuss in
detail because it's not really important from an understanding
perspective but just know that Cpus rely on that to have the
mutual others translation go faster.
Lastly, we know that virtual other translation does not always work out.
Sometimes virtual address is not mapped to anywhere.
Maybe it's mapped to something that has already been put in the page fire.
In that case the CPI will say hey, page fault, I have no idea what to do.
The CPU understands memory but it doesn't understand anything else.
And so in that case and we'll see when the CPU gets to that conclusion,
How it gets that conclusion, it will raise an exception known as a page fault.
It expects the underlying operating system to handle
that page fall in some meaningful way.
So in the classic case,
the memory manager might say ah I see that this thing is
actually this page is really in the page file.
Let me bring it back into physical memory,
fix the page table entries and then ask the process or to try again.
Then the process will try again and hopefully we'll
succeed with the translation.
So a page fault is one of those cases where the CPU gives up and says,
hey I have no idea what to do with that.
Let the operating system handle that and tell me what to do next