---
name: "hal_add_funct_to_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_add_funct_to_thread"
---

# hal\_add\_funct\_to\_thread(3hal)

cause a function to be executed at regular intervals

## NAME

hal\_add\_funct\_to\_thread - cause a function to be executed at regular intervals

## SYNTAX

int hal\_add\_funct\_to\_thread(const char \**funct\_name*, const char \**thread\_name*, int position)

int hal\_del\_funct\_from\_thread(const char \**funct\_name*, const char \**thread\_name*)

## ARGUMENTS

- *funct\_name*

  The name of the function.

- *thread\_name*

  The name of the thread.

- *position*

  The desired location within the thread. This determines when the function will run, in relation to other functions in the thread. A positive number indicates the desired location as measured from the beginning of the thread, and a negative is measured from the end. So +1 means this function will become the first one to run, +5 means it will be the fifth one to run, -2 means it will be next to last, and -1 means it will be last.  Zero is illegal.

## DESCRIPTION

**hal\_add\_funct\_to\_thread** adds a function exported by a realtime HAL component to a realtime thread. This determines how often and in what order functions are executed.

**hal\_del\_funct\_from\_thread** removes a function from a thread.

## RETURN VALUE

Returns a HAL status code.

## REALTIME CONSIDERATIONS

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

## SEE ALSO

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