---
name: "pthread_getschedparam"
section: "3thr"
platform: "linux"
package: "glibc-doc"
version: "2.1.3-20"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/pthread_setschedparam/3thr"
---

# pthread\_getschedparam(3thr)

control thread scheduling parameters

Part of [pthread\_setschedparam(3thr)](/pthread_setschedparam/3thr.md).

## NAME

pthread\_setschedparam, pthread\_getschedparam - control thread scheduling parameters

## SYNOPSIS

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

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

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

## DESCRIPTION

**pthread\_setschedparam** sets the scheduling parameters for the thread *target\_thread* as indicated by  *policy* and  *param*. *policy* can be either  **SCHED\_OTHER** (regular, non-realtime scheduling),  **SCHED\_RR** (realtime, round-robin) or  **SCHED\_FIFO** (realtime, first-in first-out).  *param* specifies the scheduling priority for the two realtime policies.  See  **sched\_setpolicy**(2) for more information on scheduling policies.

The realtime scheduling policies  **SCHED\_RR** and  **SCHED\_FIFO** are available only to processes with superuser privileges.

**pthread\_getschedparam** retrieves the scheduling policy and scheduling parameters for the thread  *target\_thread* and store them in the locations pointed to by  *policy* and  *param*, respectively.

## RETURN VALUE

**pthread\_setschedparam** and  **pthread\_getschedparam** return 0 on success and a non-zero error code on error.

## ERRORS

On error,  **pthread\_setschedparam** returns the following error codes:

- **EINVAL**

  *policy* is not one of  **SCHED\_OTHER**, **SCHED\_RR**, **SCHED\_FIFO**

- **EINVAL**

  the priority value specified by  *param* is not valid for the specified policy

- **EPERM**

  the calling process does not have superuser permissions

- **ESRCH**

  the  *target\_thread* is invalid or has already terminated

- **EFAULT**

  *param* points outside the process memory space

On error,  **pthread\_getschedparam** returns the following error codes:

- **ESRCH**

  the  *target\_thread* is invalid or has already terminated

- **EFAULT**

  *policy* or  *param* point outside the process memory space

## AUTHOR

Xavier Leroy \<Xavier.Leroy@inria.fr\>

## SEE ALSO

[**sched\_setscheduler**(2)](/sched_setscheduler/2.md), [**sched\_getscheduler**(2)](/sched_getscheduler/2.md), [**sched\_getparam**(2)](/sched_getparam/2.md), [**pthread\_attr\_setschedpolicy**(3)](/pthread_attr_setschedpolicy/3.md), [**pthread\_attr\_setschedparam**(3)](/pthread_attr_setschedparam/3.md).
