---
name: "rtapi_task_new"
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_task_new"
---

# rtapi\_task\_new(3rtapi)

create a realtime task

## NAME

rtapi\_task\_new - create a realtime task

## SYNTAX

int rtapi\_task\_new(void (\**taskcode*)(void\*), void \**arg*,\
 	int *prio*, unsigned long *stacksize*, int *uses\_fp*)

int rtapi\_task\_delete(int *task\_id*)

## ARGUMENTS

- *taskcode*

  A pointer to the function to be called when the task is started

- *arg*

  An argument to be passed to the *taskcode* function when the task is started

- *prio*

  A task priority value returned by **rtapi\_prio\_xxxx**

- *uses\_fp*

  A flag that tells the OS whether the task uses floating point or not.

- *task\_id*

  A task ID returned by a previous call to **rtapi\_task\_new**

## DESCRIPTION

**rtapi\_task\_new** creates but does not start a realtime task.  The task is created in the "paused" state.  To start it, call either **rtapi\_task\_start** for periodic tasks, or **rtapi\_task\_resume** for free-running tasks.

## REALTIME CONSIDERATIONS

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

## RETURN VALUE

On success, returns a positive integer task ID.  This ID is used for all subsequent calls that need to act on the task.  On failure, returns an RTAPI status code.

## SEE ALSO

**[rtapi\_prio(3rtapi)](/rtapi_prio/3rtapi.md)**, **[rtapi\_task\_start(3rtapi)](/rtapi_task_start/3rtapi.md)**, **[rtapi\_task\_wait(3rtapi)](/rtapi_task_wait/3rtapi.md)**, **[rtapi\_task\_resume(3rtapi)](/rtapi_task_resume/3rtapi.md)**
