Implementing virtual-to-physical address translation in C++
This medium-difficulty coding problem tests your ability to implement a core operating-systems concept: the memory address translation pipeline. It requires careful bit manipulation, proper exception handling, and faithful adherence to a multi-step algorithm that real hardware executes on every memory access.
The problem gives you a precise specification involving TLB lookup, page-table consultation, and validity/permission checks at each stage. Strong solutions extract the VPN and offset cleanly, handle the TLB hit/miss branch correctly, check all fault conditions in the right order, and assemble the final physical address using bitwise operations. The main challenge is keeping track of which exception to throw under which condition and ensuring the algorithm flow matches the specification exactly.
- Bit extraction and assembly using shifts and masks
- Optional types and null-checking in the TLB lookup path
- Multi-level permission and validity validation
- Exception semantics (SegFault vs. ProtectionFault vs. PageFault)