0

I intend to run a periodic routine. Which way could guarantee more precise delay? nanosleep or timer_create, timer_settime?

The type of their input argument is same(struct itimerspec).

It would be better if there could be a description about the internal implenmetation in your answer.

Could anybody help to make it clear for me? I would be thankful for any hint on this question.

sunshilong369
  • 646
  • 1
  • 5
  • 17
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/214462/discussion-on-question-by-sunshilong369-i-intend-to-run-a-periodic-routine-whic). – Samuel Liew May 23 '20 at 04:03

1 Answers1

1

The kernel uses the same clock source for both of them under linux. And unless you're using a real-time OS, there are no guarantees of precise timing anyway. So neither of them could provide you a precise delay.

steve
  • 75
  • 6