Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

pthread_rwlockattr_settype_np(3C)

Name

pthread_rwlockattr_gettype_np, pthread_rwlockattr_settype_np - get or set type attribute of read-write lock attributes object

Synopsis

#include <pthread.h>

int pthread_rwlockattr_gettype_np(const pthread_rwlockattr_t *restrict attr, int *restrict type);
int pthread_rwlockattr_settype_np(pthread_rwlockattr_t *attr, int type);

Description

The pthread_rwlockattr_gettype_np() and pthread_rwlockattr_settype_np() functions respectively get and set the type attribute of read-write lock attributes object. This attribute is set in the type parameter to these functions.

The type of read-write lock is contained in the type attribute of the read-write lock attributes. It augments the process-shared attribute of the read-write lock and can be set to bitwise-inclusive-OR of one or more of the following flags:

PTHREAD_RWLOCK_NORMAL_NP

This is a regular rwlock type that can be used to synchronize threads in the same or different processes.

PTHREAD_RWLOCK_SCALABLE_NP

This type of read-write lock is NUMA-aware and scales well on large systems. A read-write lock of this type can only synchronize threads in the same process, thus it is compatible only with process-shared read-write lock attribute PTHREAD_PROCESS_PRIVATE. A read-write lock of this type cannot be initialized statically. A read-write lock of this type is read-reentrant, that is, if a thread has already acquired it as a reader it can acquire it as a reader more times even if a writer is waiting; it must be released the same number of times as it was acquired. Attempts to initialize a read-write lock with this type attribute may fail if insufficient memory exists to initialize it.

Return Values

Upon successful completion, the pthread_rwlockattr_gettype_np() function returns 0 and stores the value of the type attribute of attr in the object referenced by the type parameter. Otherwise, an error number is returned to indicate the error.

Upon successful completion, the pthread_rwlockattr_settype_np() function returns 0. Otherwise, an error number is returned to indicate the error.

Errors

The pthread_rwlockattr_gettype_np() and pthread_rwlockattr_settype_np() functions may fail if:

EINVAL

The value specified by attr or type is invalid.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe
Standard

See Also

pthread_rwlock_init(3C), pthread_rwlock_rdlock(3C), pthread_rwlock_unlock(3C), pthread_rwlock_wrlock(3C), pthread_rwlockattr_getpshared(3C), attributes(7), standards(7)