Skip to content

What exactly we want to achieve in delay function? #361

Answered by sirhcel
NitinSaxenait asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @NitinSaxenait, sections 9 is about shedding some light on the internals of a delay function to give you an impression how it could be implemented. It sketches two common approaches:

  • By "counting instructions": looping which does not get optimized away by the compiler
  • By "counting timer ticks": setting up a timer and polling its status until it expires

Without any special measures, the compiler will optimize away an empty loop. But it offers a "blessed no operation" which won't: The function aux9::nop resolves to the compiler intrinsic __nop which serves exactly this purpose.

The constant K is the number of loop iterations you have to perform for a millisecond. So K * ms is the nu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NitinSaxenait
Comment options

Answer selected by NitinSaxenait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants