fabiensanglard / cpsb

The book of CPS-1
MIT License
110 stars 34 forks source link

Control "Thread" does not wait for interrupt increased vsync counter (page 195) #157

Closed stefano-leone closed 1 year ago

stefano-leone commented 1 year ago

It seems there is an error in the C code on page 195.

Actually it is: if (frameCounter < vsyncCounter) continue;

It should be: if (frameCounter >= vsyncCounter) continue;

Reasoning: While (frameCounter >= vsyncCounter) the main flow actively waits. It executes one step when the interrupt increments vsyncCounter, that is when frameCounter becomes < vsyncCounter.

fabiensanglard commented 1 year ago

Fixed in 76ecef54425b3b5e904d06711af5e26283859181