BlackBerry Interview Question

Design and implement a thread dispatch pool using a latched hardware timer

Interview Answer

Anonymous

May 4, 2012

Oddly enough I actually implemented one of these in real life about sixteen years ago. It's very tricky to get correct without race conditions and coping with things like the timer routine deleting itself. Tip: implement an absolute monotonic timer count from the hardware latch first, then write the thread pool using differentials from the absolute count. It also really helps if you know the new atomics support in C11 and C++11 as you can employ acquire/release load/store semantics and atomic increments/decrements.