I have a code
The “clock of counter” increments automatically every second by the system hardware. and i want to make it wait for a certain time taken as “wait_time” variable.Code:time_to_expire= counter_of_clock + wait_time; while (time_to_expire > counter_of_clock) { sleep ( sleep_time); }
in this all variables above have exactly the same number of bits. The issue here is when the clock counter reaches to the point when it overflows and overruns to zero. This new value of clock counter is thus less than expire_time and hence the loop will wait for more than expected time.