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

# hal\_create\_thread(3hal)

Create a HAL thread

## NAME

hal\_create\_thread - Create a HAL thread

## SYNTAX

int hal\_create\_thread(const char \**name*, unsigned long *period*, int *uses\_fp*)

int hal\_thread\_delete(const char \**name*)

## ARGUMENTS

- *name*

  The name of the thread

- *period*

  The interval, in nanoseconds, between iterations of the thread

- *uses\_fp*

  Must be nonzero if a function which uses floating-point will be attached to this thread.

## DESCRIPTION

**hal\_create\_thread** establishes a realtime thread that will execute one or more HAL functions periodically.

All thread periods are rounded to integer multiples of the hardware timer period, and the timer period is based on the first thread created. Threads must be created in order, from the fastest to the slowest. HAL assigns decreasing priorities to threads that are created later, so creating them from fastest to slowest results in rate monotonic priority scheduling.

**hal\_delete\_thread** deletes a previously created thread.

## REALTIME CONSIDERATIONS

Call only from realtime init code, not from other realtime or non-realtime code.

## RETURN VALUE

Returns a HAL status code.

## SEE ALSO

**[hal\_export\_funct(3hal)](/hal_export_funct/3hal.md)**
