Hari
Hari

Reputation: 5227

TLB Hit - Checking if the page is within the process's memory space

I have been reading about the translation of virtual addresses to physical addresses. I understand that the TLB is a hardware cache that resides in the CPU's Memory Management Unit and contains mappings of recent pages accessed.

However, say there is a TLB hit - How does the OS ensure that the page can actually be accessed by the process (is within the process's allocated address space)?

I believe that one way to do that would be to check with the process's page table, but that seems to defeat the whole purpose of using a TLB. Any insights ?

Upvotes: 1

Views: 816

Answers (2)

Ian Ringrose
Ian Ringrose

Reputation: 51917

At a basic level the TLB only contains pages that are in ram, and the os clears the TLB whenever a page is removed from ram.

Upvotes: 0

An Cong Tran
An Cong Tran

Reputation: 360

It depends upon the memory management strategy that the OS is using. For examples, in case of the OS using the inverted paging table, each entry in the page table contains the id of the process (PID) that are owning the page.

For the "normal" paging, each paging entry may contain extra bits for memory protection and sharing.

Upvotes: 1

Related Questions