pthread_attr_getschedpolicy, pthread_attr_setschedpolicy Subroutine

Purpose

Gets and sets the schedpolicy attribute (REALTIME THREADS).

Syntax

#include <pthread.h>
#include <time.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

The pthread_attr_getschedpolicy() and pthread_attr_setschedpolicy() functions, respectively, get and set the schedpolicy attribute in the attr argument.

The supported values of policy include SCHED_FIFO, SCHED_RR, and SCHED_OTHER, which are defined in the <sched.h> header. When threads executing with the scheduling policy SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC are waiting on a mutex, they acquire the mutex in priority order when the mutex is unlocked.

Application Usage

After these attributes have been set, a thread can be created with the specified attributes using pthread_create(). Using these routines does not affect the current running thread.

Return Values

If successful, the pthread_attr_getschedpolicy() and pthread_attr_setschedpolicy() functions return 0; otherwise, an error number is returned to indicate the error.

Error Codes

The pthread_attr_setschedpolicy() function might fail if:

Item Description
EINVAL The value of policy is not valid.
ENOTSUP An attempt was made to set the attribute to an unsupported value.

These functions do not return an error code of EINTR.