rtapi_delay(3rtapi)

✨ rtapi_delay ✨

ok bestie so this is rtapi_delay(3rtapi) β€” a page from the RTAPI manual, and it's literally just about spinning in a circle for a lil bit πŸ’…


πŸŽ€ NAME πŸŽ€

rtapi_delay β€” busy-loop for short delays πŸŒ€


🌸 SYNTAX 🌸

void rtapi_delay(long int nsec)

void rtapi_delay_max()

πŸ¦‹ ARGUMENTS πŸ¦‹

  • nsec β€” the delay length you want, in nanoseconds. that's the dream. the goal. the vision board ✨

πŸ’– DESCRIPTION πŸ’–

so rtapi_delay is a simple delay. like, no thoughts head empty, it just loops. and bestie, looping means it's wasting CPU cycles the entire time 😭 it's giving "spinning in the group chat waiting for a reply" energy. so it's only meant for short delays. periodt.

rtapi_delay_max tells you the maximum delay that's permitted β€” usually approximately 1/4 of the clock period ⏰ and here's the tea: if you call rtapi_delay asking for a delay longer than the max, you don't get what you asked for, you just get delayed for the max time only. so rude but that's the rules πŸ’€

you should call rtapi_delay_max before you start using rtapi_delay, so you can make sure the delays you actually need can even be achieved. vibe check first, delay second 🫢

and ngl the actual resolution of the delay is unpredictable in the cutest way possible: it may be as good as one nano-second ✨ or as bad as several microseconds πŸ™ˆ no in-between promised, iykyk.


⏱️ REALTIME CONSIDERATIONS ⏱️

may be called from init/cleanup code, and from within realtime tasks. so it's allowed in both places, slay πŸ‘‘


πŸ‘‘ RETURN VALUE πŸ‘‘

rtapi_delay_max returns the maximum delay permitted. that's it, that's the whole return πŸ’œ


🌈 SEE ALSO 🌈


ok bye my love, that's the whole page!! this lil doc is from the LinuxCNC Documentation, dated 2006-10-12, and it lives in the RTAPI section as rtapi_delay(3rtapi) πŸŽ€ thanks for reading bestie, go take a lil nanosecond nap πŸ’–βœ¨πŸ¦‹