---
name: "pthread_getschedparam"
section: "3"
platform: "macos"
package: "libpthread"
version: "539.100.4"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/pthread_getschedparam"
---

# pthread\_getschedparam(3)

thread scheduling parameter manipulation

## NAME

**pthread\_setschedparam**, **pthread\_getschedparam** – thread scheduling parameter manipulation

## SYNOPSIS

**#include \<pthread.h\>**

*int*\

**pthread\_setschedparam**(*pthread\_t thread*, *int policy*, *const struct sched\_param \*param*);

*int*\

**pthread\_getschedparam**(*pthread\_t thread*, *int \*policy*, *struct sched\_param \*param*);

## DESCRIPTION

The **pthread\_setschedparam**() and **pthread\_getschedparam**() functions set and get the scheduling parameters of individual threads. The scheduling policy for a thread can either be SCHED\_FIFO (first in, first out), SCHED\_RR (round-robin), or SCHED\_OTHER (timesharing). Valid thread priorities (accessed via *param-\>sched\_priority*) must be within the range returned by the [sched\_get\_priority\_min(2)](/sched_get_priority_min/2.md) and [sched\_get\_priority\_max(2)](/sched_get_priority_max/2.md) system calls.

## RETURN VALUES

If successful, these functions return 0. Otherwise, an error number is returned to indicate the error.

## ERRORS

The **pthread\_setschedparam**() function will fail if:

- \[EINVAL\]

  Invalid value for *policy*.

- \[ENOTSUP\]

  Invalid value for scheduling parameters.

- \[ESRCH\]

  Non-existent thread *thread*.

The **pthread\_getschedparam**() function will fail if:

- \[ESRCH\]

  Non-existent thread *thread*.

## SEE ALSO

[sched\_get\_priority\_max(2)](/sched_get_priority_max/2.md), [sched\_get\_priority\_min(2)](/sched_get_priority_min/2.md)

## STANDARDS

The **pthread\_setschedparam**() and **pthread\_getschedparam**() functions conform to Version 2 of the Single UNIX Specification (“SUSv2”).
