Address translation process.
And the reason that translation has to happen is because process thinks it has
this big address space, contiguous going from zero through some x.
And then we said,
well the physical memory, one process may not have all of it at the same time.
Or physical memory maybe much smaller than the address space size itself.
So logical address or virtual address is actually going to be
different from the physical address that we're talking about.
So this is actually, if you think about it, this is a logical address here.
And addresses that we have here are going to be addresses into physical
memory.
Right, that's your real memory that you have in the system.
So what we're going to do is, we're saying, well, this part is going here.
That part is going here.
So, maybe 1 goes at the top here,
maybe 3 goes down here, and things like that.
We said we have to take data and code that is in the address space,
and we have to place that into physical memory, okay?
The way we sort of do that is, we don't want to do it for each byte or
each word, because we'll have to keep track of what's going where.
Okay, so one way to scale that process is is that we divide this
address space and the memory into some size chunks.
Okay, so if we do paging, it's divided into what's called pages.
A page typically may be 4 kilobytes, for example, 4K size.
So we would say, well, the address space really is a page number and
displacement within that page.
So this is page 0, and if your location 10, then it's page 0, 10, okay.
So 0 is the page, and 10 is displacement within that page.
If your address happens to be let's say, 4K plus 3,
then it's going to do a second page because second page starts at 4K.
First 0 through 4K minus goes in first page, and then the second one starts.
So then we'll say it's page 2 and maybe displacement 5 or 2 or whatever it is.
So the logical address you can think of that as a page number and
a displacement.
Essentially a page table says, this, it is a mapping isn't it?
So it says this logical page is currently stored in this physical page.
Okay, so if I want to think about it, a page table, essentially,
a page table we have all these entries.
And it's logical base 0, 1, 2.
We're saying this may be a 3.
This may be at 5.
This may be at 8.
And maybe 3 is currently not loaded.
Virtual memory, not everything is in memory at the same time.
So this a page table that actually we build, and the operating
system is responsible for actually building this and protecting this.
Remember, at this point, sort of a flow that we should understand,
it's really important.
A process, maybe executing in user space, generates an address,
okay, saying I need to fetch the next instruction.
That's where my instruction point or program counter points, or an operand,
or whatever it is.
And I need to access this memory location.
It sort of starts with a logical address.
The system now says,
well, where exactly is this information that the process needs?
We need to locate the physical address to which this logical address maps.
For that, what I'm going to do is I'm going to take the logical
address page #, and I'm going to look up this page table.
So this address translation requires that you access this page table,
and there are ways to speed this whole process up.
So it's saying if page number is 3, or let's say the page number is 2,
then I go down here and I say oh, it's in physical memory page 8.
So the address that we have, if it's 3 and some displacement,
d, could translate to 8 and the same displacement.
So it's say memory page 8 and go dig down d locations or d bytes in that.
This is what is called the address translation process.
So an important observation here is that we can only access physical memory
that is reachable through this page table that we have for this process.
I should say page table a lot more complicated than multilevel,
things like that.
But let's just sort of stay with this basic idea of how they help us get
this isolation which is important to us
because the process has to start with an address.
Address has to be translated.
Translation is only possible through this page table.
So whatever the page table points to is all a process can access.
Another observation here that we should be clearly understanding,
is, the page tables have to be maintained by the operating system.
They have to be managed by their trusted computing base
because whatever goes into the page table, we can access that.
So the operating system should make sure that whatever goes in the page table of
a particular process is only memory that belongs to that process.
So, that's the address translation.
It gives you a little bit more information about
what part of memory a given process is able to access,
and it relates to this isolation thing that we've been talking about.