---
name: "sched_setparam"
section: "2"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/sched_setparam"
---

# sched\_setparam(2)

set and get scheduling parameters

## NAME

sched\_setparam, sched\_getparam - set and get scheduling parameters

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <sched.h>
```

**int sched\_setparam(pid\_t** *pid***, const struct sched\_param \****param***);** **int sched\_getparam(pid\_t** *pid***, struct sched\_param \****param***);**

**struct sched\_param {**\
     **...**\
     **int** *sched\_priority***;**\
     **...** **};**

## DESCRIPTION

**sched\_setparam**() *sets the scheduling parameters associated with the scheduling policy* *for the thread whose thread ID is specified in* *pid*. *If* *pid* *is zero, then* *the parameters of the calling thread are set.* *The interpretation of* *the argument* *param* *depends on the scheduling policy* *of the thread identified by* *pid*. *See* [**sched**(7)](/sched/7.md) *for a description of the scheduling policies supported under Linux.*

**sched\_getparam**() *retrieves the scheduling parameters for the* *thread identified by* *pid*. *If* *pid* *is zero, then the parameters* *of the calling thread are retrieved.*

**sched\_setparam**() *checks the validity of* *param* *for the scheduling policy of the thread.* *The value* *param-\>sched\_priority* *must lie within the* *range given by* [**sched\_get\_priority\_min**(2)](/sched_get_priority_min/2.md) *and* [**sched\_get\_priority\_max**(2)](/sched_get_priority_max/2.md).

*For a discussion of the privileges and resource limits related to* *scheduling priority and policy, see* [**sched**(7)](/sched/7.md).

*POSIX systems on which* **sched\_setparam**() *and* **sched\_getparam**() *are available define* **\_POSIX\_PRIORITY\_SCHEDULING** *in* *\<unistd.h\>*.

## RETURN VALUE

*On success,* **sched\_setparam**() *and* **sched\_getparam**() *return 0.* *On error, -1 is returned, and* *errno* *is set to indicate the error.*

## ERRORS

- **EINVAL**

  *Invalid arguments:* *param* *is NULL or* *pid* *is negative*

- **EINVAL**

  (**sched\_setparam**()) *The argument* *param* *does not make sense for the current* *scheduling policy.*

- **EPERM**

  (**sched\_setparam**()) *The caller does not have appropriate privileges* *(Linux: does not have the* **CAP\_SYS\_NICE** *capability).*

- **ESRCH**

  *The thread whose ID is* *pid* *could not be found.*

## STANDARDS

*POSIX.1-2024.*

## HISTORY

*POSIX.1-2001.*

## SEE ALSO

[**getpriority**(2)](/getpriority/2.md), [**gettid**(2)](/gettid/2.md), [**nice**(2)](/nice/2.md), [**sched\_get\_priority\_max**(2)](/sched_get_priority_max/2.md), [**sched\_get\_priority\_min**(2)](/sched_get_priority_min/2.md), [**sched\_getaffinity**(2)](/sched_getaffinity/2.md), [**sched\_getscheduler**(2)](/sched_getscheduler/2.md), [**sched\_setaffinity**(2)](/sched_setaffinity/2.md), [**sched\_setattr**(2)](/sched_setattr/2.md), [**sched\_setscheduler**(2)](/sched_setscheduler/2.md), [**setpriority**(2)](/setpriority/2.md), [**capabilities**(7)](/capabilities/7.md), [**sched**(7)](/sched/7.md)
