---
name: "rtapi_mutex"
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_mutex"
---

# rtapi\_mutex(3rtapi)

Mutex-related functions

## NAME

rtapi\_mutex - Mutex-related functions

## SYNTAX

**#include \<rtapi\_mutex.h\>**

**int rtapi\_mutex\_try(unsigned long \****mutex***);**\
 **int rtapi\_mutex\_get(unsigned long \****mutex***);**\
 **int rtapi\_mutex\_give(unsigned long \****mutex***);**

## ARGUMENTS

- *mutex*

  A pointer to the mutex.

## DESCRIPTION

**rtapi\_mutex\_try** makes a non-blocking attempt to get the mutex. If the mutex is available, it returns 0, and the mutex is no longer available. Otherwise, it returns a nonzero value.

**rtapi\_mutex\_get** blocks until the mutex is available.

**rtapi\_mutex\_give** releases a mutex acquired by **rtapi\_mutex\_try** or **rtapi\_mutex\_get**.

## REALTIME CONSIDERATIONS

**rtapi\_mutex\_give** and **rtapi\_mutex\_try** may be used from non-realtime, init/cleanup, and realtime code.

**rtapi\_mutex\_get** may not be used from realtime code.

## RETURN VALUE

**rtapi\_mutex\_try** returns 0 for if the mutex was claimed, and nonzero otherwise.

**rtapi\_mutex\_get** and **rtapi\_mutex\_gif** have no return value.
