rtapi_prio(3rtapi)

πŸ’– rtapi_prio β€” thread priority functions πŸ’–

okay bestie, welcome to the rtapi_prio(3rtapi) page, aka the part of the RTAPI manual where we figure out who gets to cut the line πŸ”₯


✨ SYNTAX ✨

int rtapi_prio_highest()

int rtapi_prio_lowest()

int rtapi_prio_next_higher(int prio)

int rtapi_prio_next_lower(int prio)

four lil functions, four lil vibes, all of them returning an int πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • prio β€” a value that came out of a previous rtapi_prio_xxx call. that's it. that's the whole argument. don't get cute and pass a random number, it has to be one of these numbers 🫢

🌸 DESCRIPTION 🌸

so the rtapi_prio_xxxx functions are your portable glow-up for setting task priority ✨ like, the actual mapping from "real priority" to "priority number" is RTOS-dependent β€” every realtime OS does its own thing β€” but this API keeps you from having to care about that. iconic behaviour honestly.

priorities range from rtapi_prio_lowest all the way up to rtapi_prio_highest, inclusive πŸ¦‹ and to use this API you pick one of two methods, no third option, we don't do that here:

  1. Set your lowest priority task to rtapi_prio_lowest, and then for each task at the next lowest priority, set their priorities to rtapi_prio_next_higher(previous). you're building the ladder from the bottom up, bestie πŸͺœ
  2. Set your highest priority task to rtapi_prio_highest, and then for each task at the next highest priority, set their priorities to rtapi_prio_next_lower(previous). same ladder, but you're climbing down from the top πŸ‘‘
N.B. a high priority task will preempt or interrupt a lower priority task. and Linux is always the lowest priority! no cap. Linux is the lowest. periodt. πŸ’€

πŸ’œ REALTIME CONSIDERATIONS πŸ’œ

call these functions only from within init/cleanup code. not from realtime tasks. like, do not. I'm serious. realtime tasks are not the place for this, it's giving "undefined chaos" and we are not about that πŸ™ˆ


⭐ RETURN VALUE ⭐

returns an opaque real-time priority number. opaque means: you don't peek inside it, you don't do math on it, you just hand it back to the API and let it cook πŸ‘‘


🌈 SEE ALSO 🌈


okay that's the whole page, you ate that πŸ’… go forth and prioritise responsibly. this little love letter came from the LinuxCNC Documentation, dated 2006-10-12, filed under rtapi_prio(3rtapi) πŸŽ€βœ¨ bye bestie, mwah πŸ’–