Implementing a TLB address translator in C++
This is an easy coding problem that tests your understanding of virtual memory and bitwise operations. It asks you to build a simple Translation Lookaside Buffer (TLB) simulator — a core concept in computer architecture that every systems programmer should grasp.
The problem requires you to extract a virtual page number (VPN) from the upper bits of a virtual address, look it up in a cache of mappings, and if found, assemble a physical address by replacing the VPN with the corresponding physical frame number (PFN) while preserving the page offset. The main challenge is getting the bit extraction and reconstruction logic correct, and choosing an appropriate data structure for fast lookups across up to a million translation calls.
- Bit masking and shifting operations
- Hash tables or maps for O(1) lookup
- Error handling with exceptions
- Working with fixed-width integer types