pthread_attr_setsched(3)
NAME
pthread_attr_setsched - Changes the scheduling policy attribute of thread creation
SYNOPSIS
#include <pthread.h> int pthread_attr_setsched( pthread_attr_t *attr int scheduler);
PARAMETERS
attrThread attributes object modified.
schedulerNew value for the scheduling policy attribute. Valid values are as follows:
SCHED_FIFO(First In, First Out) The highest-priority thread runs until it blocks. If there is more than one thread with the same priority, and that priority is the highest among other threads, the first thread to begin running continues until it blocks.
SCHED_RR(Round Robin) The highest-priority thread runs until it blocks; however, threads of equal priority, if that priority is the highest among other threads, are timesliced. Timeslicing is a process in which threads alternate using available processors.
SCHED_OTHER(Default) All threads are timesliced. SCHED_OTHER ensures that all threads, regardless of priority, receive some scheduling so that no thread is completely denied execution time. (However, SCHED_OTHER threads can be denied execution time by SCHED_FIFO or SCHED_RR threads.)
SCHED_FG_NP(Foreground) Same as SCHED_OTHER. Threads are timesliced and priorities can be modified dynamically by the scheduler to ensure fairness.
SCHED_BG_NP(Background) Ensures that all threads, regardless of priority, receive some scheduling. However, SCHED_BG_NP can be denied execution by SCHED_FIFO or SCHED_RR threads.
DESCRIPTION
The pthread_attr_setsched() routine sets the scheduling policy of a thread that is created using the attributes object specified by the attr parameter. The default value of the scheduling attribute is SCHED_OTHER.
RETURN VALUES
If the function fails, errno may be set to one of the following values:
| Return | Error | Description |
| 0 | Successful completion. | |
| \-1 | [EINVAL] | The value specified by attr is invalid. |
| \-1 | [EINVAL] | The value specified by scheduler is invalid. |
| \-1 | [EPERM] | The caller does not have the appropriate privileges to set the scheduling policy attribute in the specified threads attribute object. |
RELATED INFORMATION
Functions: pthread_attr_create(3), pthread_attr_getsched(3), pthread_attr_setinheritsched(3), pthread_create(3).
Hewlett-Packard Company — OSF DCE 1.1/HP DCE 1.5