Switch between lists when rap around occurs

michaeln32 wrote on Tuesday, July 31, 2018:

Hi,

When roll over of tick count occurs in the system there is an operation of switch between the lists

pxOverflowTimerList and pxCurrentTimerList.

Why we need this switch operation between those two lists ?

richarddamon wrote on Tuesday, July 31, 2018:

The lists are kept sorted, so smaller values are first, and larger values follow. The code then scans the current timer list from the beginning and activates any operation whose time has past.

If we want to set a timer past the wrap around of the tick roll over, then its value will be less than the current timer tick, so if we put it on the current timer list it would happen immediately, not after the tick rollover. The use of the overflow list is basically an extra bit to the tick value.