This question evaluates a candidate's ability to design thread-safe, timer-driven systems, covering synchronization primitives, concurrency control for schedule/cancel APIs, timing assumptions such as a monotonic clock, and handling task overruns in periodic execution.
Implement a small in-process job scheduler that can run periodic tasks (functions/callbacks) at a target frequency.
50 Hz
(50 times per second). You must convert frequency to a period (time interval).
schedule(taskFn, frequencyHz) -> jobId
cancel(jobId) -> void
schedule()
and
cancel()
concurrently while the worker is running.