Don Corleone
Don Corleone

Reputation: 361

What's purpose of having valid-invalid bits is page table?

I was reading Operating System Concepts , I'm unable to understand use of valid-invalid bits in page table. Each process has it's own process table, shouldn't all entries be valid then ?

Valid-invalid bit attached to each entry in the page table:

“valid” indicates that the associated page is in the process’ logical address space, and is thus a legal page

“invalid” indicates that the page is not in the process’ logical address space

Upvotes: 5

Views: 21855

Answers (4)

Daniel Jour
Daniel Jour

Reputation: 16156

If an entry is invalid, then the MMU won't use it for address translation, causing a page fault when accessing the corresponding memory area.

Because the entry isn't used by the MMU the operating system can use it to store its own information, like for example a reference to the filesystem entity (for example inode number) where it stored the data to free the main memory for some other processes (it swapped that page out)

Upon a page fault the operating system can react then, using this information it previously stored inside that entry, to get back that data from the disk into the main memory.

Of course, the invalid bit is also used to mark just as it says pages as invalid: In most systems in user process needs to explicitly request memory from the operating system, accessing memory that hasn't been granted to that process is an access violation.

Upvotes: 1

SANAPATHI NAVEEN
SANAPATHI NAVEEN

Reputation: 1

Each process will have a page table. Each page contains frame_number field, valid/invalid bit and other info.

Let's assume there is no valid/invalid bit entry in the page table. Now CPU generated a logical address, MMU will translate to physical address. How? Hardware will be triggered and value of frame_number field of respective page number slot will be considered for translation. Whether it is garbage value, valid value or zero whatsoever it will be taken into consideration for translation. It might violates protection if the value is zero or any garbage value.

We don't want that too happen so we need special field that indicates the validity.

You may want delete the entry in page table instead of having a special field but that will lead lot of chaos. Now you have include page number field also to resolve inconsistencies in the absence of valid or invalid bit.

Upvotes: 0

Aditya
Aditya

Reputation: 817

In demand paging, only the pages that are required currently are brought into the main memory.

Assume that a process has 5 pages: A, B, C, D, E and A and B are in the memory. With the help of valid-invalid bit, the system can know, when required, that pages C, D and E are not in the memory.

In short:

a 1 in valid-invalid bit signifies that the page is in memory and 0 signifies that the page may be invalid or haven't brought into the memory just yet.

Upvotes: 6

Muhammad Bilal
Muhammad Bilal

Reputation: 1999

Valid indicates that the associated page is in the logical address space. Invalid indicates that the associated page is not in logical address space.

Upvotes: 1

Related Questions