rtapi_is(3rtapi)

πŸ“¦
version 2.9.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ rtapi_is β€” details of rtapi configuration ✨

ok so this is a page from the RTAPI manual (section 3rtapi, we love a library-call section πŸ’–) and it's about two little functions that let you vibe-check your rtapi setup before you do anything wild. no cap, they're tiny, but they will save you from a confusing loadrt meltdown later. 🫢


🌸 SYNTAX 🌸

int rtapi_is_kernelspace()

int rtapi_is_realtime()

like. two functions. both return int. that's the whole mood. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

rtapi_is_kernelspace() 🌈

bestie, this one tells you where your rtapi modules are living.

  • returns nonzero when rtapi modules run in kernel space (e.g., under RTAI)
  • returns zero when they run in userspace (e.g., under uspace)

so it's giving "am i in the kernel rn or not" and honestly it's iconic for branching on that. ⭐

rtapi_is_realtime() πŸ”₯

this one is the "can we actually do realtime tho" check.

  • returns nonzero when capable of running with realtime guarantees
  • for rtai: this always returns nonzero β€” but heads up, actually loading realtime modules will fail if you're not running under the appropriate kernel. so like, it said yes but it lied. 😭
  • for uspace: returns nonzero when the running kernel indicates it is capable of realtime performance
  • if rtapi_app is not setuid root, this returns nonzero even though rtapi_app will not be able to obtain realtime scheduling or hardware access β€” so, e.g., attempting to loadrt a hardware driver will fail. πŸ’€
not me being nonzero and still useless. πŸ™ˆ anyway, remember: a nonzero here is not a promise that your hardware driver load is gonna slay. read the caveats. periodt.

🧚 REALTIME CONSIDERATIONS 🧚

  • May be called from non-realtime or from realtime setup code.
  • rtapi_is_realtime() may perform filesystem I/O. πŸ‘€

so yeah, call it in setup, not mid-cycle, iykyk. πŸ’œ


πŸ‘‘ RETURN VALUE πŸ‘‘

Zero for false, nonzero for true. that's it, that's the whole truth table, no cap. ✨


ok that's the whole page, ty for coming to my ted talk πŸ’– this was written up in the LinuxCNC Documentation, dated 2006-10-12, and yeah, she's been serving accurate answers since way before you were born bestie. mwah. πŸŽ€

πŸ“¦ where this page comes from