the valid-invalid bit
Think of a hotel's room-status board at the front desk: next to each room number is a small light. Green means the room is ready and occupied as expected; red means do not send a guest there yet, check with the manager first. The valid-invalid bit is that little light next to each page in the page table. It tells the hardware, in a single bit, whether a page is right now sitting in real memory or whether touching it requires calling the operating system.
Concretely, every page-table entry contains, alongside the frame number, a single valid-invalid bit. Valid means two things together: the page belongs to the program's address space and it is currently resident in a physical frame, so the recorded frame number can be used directly. Invalid means either the page is not in memory at the moment (it is out on the backing store) or the address is not part of this program's legal space at all. When the hardware translates an address and finds the bit invalid, it does not complete the access; it traps to the OS. The OS then inspects its own records to decide which case it is: if the page is merely non-resident, it services a page fault and brings the page in; if the address is truly illegal, it raises a fault that usually kills the offending program (a segmentation fault).
Why it matters: this one bit is the hinge of demand paging. It is how the hardware, on every single memory reference, can ask the cheap question 'is this page here?' without the OS being involved, and only escalate to the OS in the rare case when the answer is no. Without it, there would be no fast way to mark which pages are resident, and the lazy-loading magic of demand paging could not work. A common confusion: invalid does not always mean error — most of the time it simply means 'not loaded yet,' which is a perfectly normal, recoverable event.
A page table shows entry 7 as valid -> frame 12, so address 7's data is read straight from frame 12. Entry 8 is invalid, so a read of page 8 traps to the OS, which loads page 8 from disk, sets entry 8 to valid -> frame 3, and lets the access proceed.
Valid means 'use the frame number'; invalid means 'trap to the OS first'.
The valid-invalid bit overloads two distinct meanings — 'not resident' versus 'not your memory at all'. The hardware treats both as a trap; only the OS, using its own bookkeeping, can tell a recoverable page fault apart from an illegal access.