---
name: "rtapi_delay"
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_delay"
---

# rtapi\_delay(3rtapi)

Busy-loop for short delays

## NAME

rtapi\_delay - Busy-loop for short delays

## SYNTAX

void rtapi\_delay(long int *nsec*)

void rtapi\_delay\_max()

## ARGUMENTS

- *nsec*

  The desired delay length in nanoseconds

## DESCRIPTION

**rtapi\_delay** is a simple delay.  It is intended only for short delays, since it simply loops, wasting CPU cycles.

**rtapi\_delay\_max** returns the max delay permitted (usually approximately 1/4 of the clock period).  Any call to **rtapi\_delay** requesting a delay longer than the max will delay for the max time only.

**rtapi\_delay\_max** should be called before using **rtapi\_delay** to make sure the required delays can be achieved.  The actual resolution of the delay may be as good as one nano-second, or as bad as a several microseconds.

## REALTIME CONSIDERATIONS

May be called from init/cleanup code, and from within realtime tasks.

## RETURN VALUE

**rtapi\_delay\_max returns the maximum delay permitted.**

## SEE ALSO

**[rtapi\_clock\_set\_period(3rtapi)](/rtapi_clock_set_period/3rtapi.md)**
