<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="margin: 0;">This issue is very critial, it can make the select abnormally return timeout after long run time.</div><div style="margin: 0;">If the timeout is set to 5ms,  when the system run after 70000s(19.4h),</div><div style="margin: 0;">the select function will wait 10ms timeout, which is two times of setting value.</div><p style="margin: 0;"><br></p><div style="margin: 0;">This issue is created by calculating timeout watchdog expire tick using the absolute time since libbsd5 version.</div><p>ÔÚ 2020-11-03 10:26:39£¬"RUI Zhengxin" <ruizx@126.com> Ð´µÀ£º</p><blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><p style="margin:0;">Hello everyone,</p><p style="margin:0;"><br></p><p style="margin:0;">We meet an issue of select function timeout drift in rtems-libbsd5.1.</p><p style="margin:0;">The select timeout can drift 1ms every 14000 seconds.</p><p style="margin:0;"><br></p><p style="margin:0;">Kernel put the select thread to sleep queue in sleepq_set_timeout_sbt,</p><p style="margin:0;"><span class="typoRed" evid="1604370203443.973" id="1604370203443.973">the expire</span> value is calculated by this</p><p style="margin:0;">expire = (sbt - SBT_1S + sbt_per_tick - 1) / sbt_per_tick;</p><p style="margin:0;"><br></p><p style="margin:0;">sbt is the absolute time,</p><p style="margin:0;">Precision is a constant value, no time drift.</p><p style="margin:0;">but the sbt_per_tick is not an accurate value,</p><p style="margin:0;">It can make the <span class="typoRed" evid="1604370203444.6675" id="1604370203444.6675">expire</span> vaule bigger and bigger while sbt is increasing.</p><p style="margin:0;"><br></p><p style="margin:0;">in rtems_bsd_initialize function,</p><p style="margin:0;">rtems_bsd_sbt_per_watchdog_tick = SBT_1S / tps;</p><p style="margin:0;">in our system the tick rate is set to 1000Hz,</p><p style="margin:0;">The real value of rtems_bsd_sbt_per_watchdog_tick is 1<<32/1000=4294967.296</p><p style="margin:0;">but in integer type the value is 4294967.</p><p style="margin:0;">The error is 0.296/4294967 = 0.069ppm,</p><div style="margin:0;">and it can<span class="typoRed" evid="1604370203444.6912" id="1604370203444.6912"> increase the</span> expire value 1ms every 14000 seconds.</div><div style="margin:0;"><br></div><div style="margin:0;">Zhengxin</div><div style="margin:0;">Best regards.</div></div><br><br><span title="neteasefooter"><p> </p></span></blockquote></div>