Sleep Function Error In C

前端 未结 5 1213
眼角桃花
眼角桃花 2021-01-21 03:03

I have a file of data Dump, in with different timestamped data available, I get the time from timestamp and sleep my c thread for that time. But the problem is that The actual t

5条回答
  •  一生所求
    2021-01-21 03:34

    Any modern multitask OS's scheduler will not guarantee any exact timings to any user apps. You can try to assign 'realtime' priority to your app some way, from a windows task manager for instance. And see if it helps.

    Another solution is to implement a 'controlled' sleep, i.e. sleep a series of 500ms, checking current timestamp between them. so, if your all will sleep a 1s instead of 500ms at some step - you will notice it and not do additional sleep(500ms).

提交回复
热议问题