---
name: "rtapi_prio"
section: "3rtapi"
platform: "linux"
package: "linuxcnc-uspace-dev"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rtapi_prio"
---

# rtapi\_prio(3rtapi)

thread priority functions

## NAME

rtapi\_prio - thread priority functions

## SYNTAX

int rtapi\_prio\_highest()

int rtapi\_prio\_lowest()

int rtapi\_prio\_next\_higher(int *prio*)

int rtapi\_prio\_next\_lower(int *prio*)

## ARGUMENTS

- *prio*

  A value returned by a prior **rtapi\_prio\_xxx** call

## DESCRIPTION

The **rtapi\_prio\_xxxx** functions provide a portable way to set task priority.  The mapping of actual priority to priority number depends on the RTOS.  Priorities range from **rtapi\_prio\_lowest** to **rtapi\_prio\_highest**, inclusive. To use this API, use one of two methods:

- 1\)

  Set your lowest priority task to **rtapi\_prio\_lowest**, and for each task of the next lowest priority, set their priorities to **rtapi\_prio\_next\_higher(previous)**.

- 2\)

  Set your highest priority task to **rtapi\_prio\_highest**, and for each task of the next highest priority, set their priorities to **rtapi\_prio\_next\_lower(previous)**.

N.B. A high priority task will preempt or interrupt a lower priority task. Linux is always the lowest priority!

## REALTIME CONSIDERATIONS

Call these functions only from within init/cleanup code, not from realtime tasks.

## RETURN VALUE

Returns an opaque real-time priority number.

## SEE ALSO

**[rtapi\_task\_new(3rtapi)](/rtapi_task_new/3rtapi.md)**
