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

# pthread\_attr\_set\_getschedpolicy(3)

thread attribute operations

## NAME

**pthread\_attr\_getschedpolicy**, **pthread\_attr\_setschedpolicy** – thread attribute operations

## SYNOPSIS

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

*int*\

**pthread\_attr\_getschedpolicy**(*const pthread\_attr\_t \*restrict attr*, *int \*restrict policy*);

*int*\

**pthread\_attr\_setschedpolicy**(*pthread\_attr\_t \*attr*, *int policy*);

## DESCRIPTION

Thread attributes are used to specify parameters to **pthread\_create**(). One attribute object can be used in multiple calls to **pthread\_create**(), with or without modifications between calls.

The functions  **pthread\_attr\_setschedpolicy**() and  **pthread\_attr\_getschedpolicy**(), set and get the attribute in the  *attr* argument related to the scheduling policy. The value for the aforementioned attribute can be SCHED\_FIFO, SCHED\_RR and SCHED\_OTHER.

## RETURN VALUES

If successful, these functions return 0. Otherwise, an error number is returned to indicate the error. **pthread\_attr\_getschedpolicy**(), on success, will copy the value of the thread's scheduling policy attribute to the location pointed to by the second function parameter.

## ERRORS

**pthread\_attr\_getschedpolicy**() will fail if:

- \[EINVAL\]

  Invalid value for *attr*.

**pthread\_attr\_setschedpolicy**() will fail if:

- \[EINVAL\]

  Invalid value for *attr*.

- \[ENOTSUP\]

  Invalid or unsupported value for *policy*.

## SEE ALSO

[pthread\_create(3)](/pthread_create/3.md), [pthread\_attr\_init(3)](/pthread_attr_init/3.md), [pthread\_attr\_setschedparam(3)](/pthread_attr_setschedparam/3.md), [pthread\_attr\_setinheritsched(3)](/pthread_attr_setinheritsched/3.md)

## STANDARDS

**pthread\_attr\_setschedpolicy**(), **pthread\_attr\_getschedpolicy**() conform to Version 2 of the Single UNIX Specification (“SUSv2”)
