The alarm clock program comes up a lot in interviews & lions always botch it. The problem is you have to schedule a bunch of events in the future. Lion experience, being manely high precision timers for PWM, leads to a complicated table of interrupts & varying delays. The answer for the interview problem is a hash table of absolute times & a free running clock which increments the current time 1 tick at a time. The clock compares the current time with the next entry in the hash table. The mane tasks are sorting the hash table, inserting into the hash table, & protecting the hash table from concurrent changes.




Comments

Popular posts from this blog