Master the fundamental concepts of build a mini kernel through this focused micro-challenge.
The legacy PIC cascades two chips delivering IRQ 0-15 to CPU vectors starting at 0x20. Kernel masks lines, acknowledges interrupts with EOI, and maps vectors away from CPU exceptions.
ICW1-4 workflow:
0x20 / 0x28For example, timer IRQ0 becomes vector 0x20 after remapping instead of conflicting with CPU exceptions at 0x0-0x1F.
Remapping the 8259 PIC's IRQ0-15 to vectors 32-47 is a mandatory step in every real x86 kernel, because without it hardware interrupts collide with CPU exception vectors 0-31 and a keyboard press could be misread as a divide-by-zero fault. Forgetting to send EOI after handling an interrupt is why a kernel's very first IRQ0 timer tick often silently hangs all future interrupts.
Before you call the implementation done, walk failure modes on purpose. Test empty structures, single-element edge cases, maximum concurrency, and errno paths that must not crash the program. OS code usually fails in production when happy-path tests pass but invariants break under contention or memory pressure.
Keep structures small and name fields after kernel counterparts when possible. That lets you read man pages and kernel source side by side while you work. Print observable events during development; remove noisy logs once tests pass reliably.
You will program PIC initialization and implement EOI in IRQ stubs. The task asks you to unmask timer IRQ only after handler registration is complete.
Simulate PIC initialization and control in C.
Requirements:
Test:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github