pthread_attr_getscope and pthread_attr_setscope Subroutines

Purpose

Gets and sets the scope attribute in the attr object.

Library

Threads Library (libpthreads.a)

Syntax

#include <pthread.h>

int pthread_attr_setscope (attr, contentionscope)
pthread_attr_t *attr;
int contentionscope;

int pthread_attr_getscope (attr, contentionscope)
const pthread_attr_t *attr;
int *contentionscope;

Description

The scope attribute controls whether a thread is created in system or process scope.

The pthread_attr_getscope and pthread_attr_setscope subroutines get and set the scope attribute in the attr object.

The scope can be set to PTHREAD_SCOPE_SYSTEM or PTHREAD_SCOPE_PROCESS. A value of PTHREAD_SCOPE_SYSTEM causes all threads created with the attr parameter to be in system scope, whereas a value of PTHREAD_SCOPE_PROCESS causes all threads created with the attr parameter to be in process scope.

The default value of the contentionscope parameter is PTHREAD_SCOPE_SYSTEM.

Parameters

Item Description
attr Specifies the thread attributes object.
contentionscope Points to where the scope attribute value will be stored.

Return Values

Upon successful completion, the pthread_attr_getscope and pthread_attr_setscope subroutines return a value of 0. Otherwise, an error number is returned to indicate the error.

Error Codes

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