Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

pthread_attr_setprio(3thr)

Name

pthread_attr_setprio − Changes the scheduling priority attribute of thread creation. 

Syntax

#include <pthread.h>

int pthread_attr_setprio (attr, priority)
pthread_attr_t *attr;
int priority;

Arguments

attr Thread attributes object modified. 

priority New value for the priority attribute. The priority attribute is dependent upon scheduling policy.  Valid values fall within one of the following three ranges. 

Low High
PRI_FIFO_MIN  PRI_FIFO_MAX
PRI_RR_MIN  PRI_RR_MAX
PRI_OTHER_MIN  PRI_OTHER_MAX
PRI_FG_MIN_NP  PRI_FG_MAX_NP
PRI_BG_MIN_NP  PRI_BG_MAX_NP

The default priority is the midpoint between PRI_OTHER_MIN and PRI_OTHER_MAX. (<REFERENCE>(sched_sec) describes how to specify priorities between the minimum and maximum values.) 

Description

This routine sets the execution priority of threads that are created using the attributes object specified by the attr argument. 

By default, a created thread inherits the priority of the thread calling pthread_create. To specify a priority using this routine, scheduling inheritance must be disabled at the time the thread is created.  Call pthread_attr_setinheritsched and specify the value DEFAULT_SCHED for the inherit argument before calling this routine and pthread_create. 

An application specifies  priority only to express the urgency of executing the thread relative to other threads. Priority is not used to control mutual exclusion when accessing shared data.  With a sufficient number of processors executing, all ready threads, regardless of priority, execute simultaneously. 

Return Values

If an error condition occurs, this routine returns -1 and sets errno to the corresponding error value.  Possible return values are as follows. 

Return Error Description
0 Successful completion. 
-1 [EINVAL] The value specified by attr is invalid. 
-1 [ERANGE] One or more arguments supplied have an invalid value. 
-1 [ESRCH] The value specified by attr does not refer to an existing thread attributes object. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026