| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- get or set protocol attribute of mutex attribute object
cc –mt [flag... ]file... –lpthread [library... ]#include <pthread.h>intpthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrictattr,int *restrictprotocol);
intpthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,intprotocol);
Thepthread_mutexattr_setprotocol() andpthread_mutexattr_getprotocol() functions, respectively, set and get the protocol attributeof a mutex attribute object pointed to byattr, which was previouslycreated by thepthread_mutexattr_init() function.
Theprotocol attribute defines the protocol to be followed in utilizing mutexes.The value ofprotocol may be one ofPTHREAD_PRIO_NONE,PTHREAD_PRIO_INHERIT, orPTHREAD_PRIO_PROTECT, which are defined by the header <pthread.h>.
When a thread owns a mutex with thePTHREAD_PRIO_NONE protocol attribute,its priority and scheduling are not affected by its mutex ownership.
When a thread is blocking higher priority threads because of owning oneor more mutexes with thePTHREAD_PRIO_INHERIT protocol attribute, it executes atthe higher of its priority or the priority of the highest prioritythread waiting on any of the mutexes owned by this thread and initializedwith this protocol.
When a thread owns one or more mutexes initialized with thePTHREAD_PRIO_PROTECTprotocol, it executes at the higher of its priority or the highestof the priority ceilings of all the mutexes owned by this threadand initialized with this attribute, regardless of whether other threads are blocked onany of these mutexes.
While a thread is holding a mutex that has been initialized withthePRIO_INHERIT orPRIO_PROTECT protocol attributes, it will not be subjectto being moved to the tail of the scheduling queue at itspriority in the event that its original priority is changed, such as bya call tosched_setparam(). Likewise, when a thread unlocks a mutex thathas been initialized with thePRIO_INHERIT orPRIO_PROTECT protocol attributes, it willnot be subject to being moved to the tail of the scheduling queueat its priority in the event that its original priority is changed.
If a thread simultaneously owns several mutexes initialized with different protocols, itwill execute at the highest of the priorities that it would haveobtained by each of these protocols.
If a thread makes a call topthread_mutex_lock() for a mutex thatwas initialized with the protocol attributePTHREAD_PRIO_INHERIT, and if the calling threadbecomes blocked because the mutex is owned by another thread, then theowner thread inherits the priority level of the calling thread for aslong as it continues to own the mutex. The implementation updates itsexecution priority to the maximum of its assigned priority and all itsinherited priorities. Furthermore, if this owner thread becomes blocked on another mutex,the same priority inheritance effect will be propagated to the other owner thread,in a recursive manner.
A thread that uses mutexes initialized with thePTHREAD_PRIO_INHERIT orPTHREAD_PRIO_PROTECTprotocolattribute values should have its scheduling policy equal toSCHED_FIFO or SCHED_RR (seepthread_attr_getschedparam(3C)andpthread_getschedparam(3C)).
If a thread with scheduling policy equal toSCHED_OTHER uses a mutexinitialized with thePTHREAD_PRIO_INHERIT orPTHREAD_PRIO_PROTECTprotocol attribute value, the effect onthe thread's scheduling and priority is unspecified.
The_POSIX_THREAD_PRIO_INHERIT and_POSIX_THREAD_PRIO_PROTECT options are designed to provide features to solvepriority inversion due to mutexes. A priority inheritance or priority ceiling mutexis designed to minimize the dispatch latency of a high priority thread whena low priority thread is holding a mutex required by the highpriority thread. This is a specific need for the realtime applicationdomain.
Threads created by realtime applications need to be such that their prioritiescan influence their access to system resources (CPU resources, at least), incompetition with all threads running on the system.
Upon successful completion, thepthread_mutexattr_getprotocol() andpthread_mutexattr_setprotocol() functions return0. Otherwise,an error number is returned to indicate the error.
Thepthread_mutexattr_getprotocol() andpthread_mutexattr_setprotocol() functions will fail if:
The value specified byattr isNULL.
Neither of the options_POSIX_THREAD_PRIO_PROTECT and_POSIX_THREAD_PRIO_INHERIT is defined and the system does not support the function.
The value specified byprotocol is an unsupported value.
Thepthread_mutexattr_getprotocol() andpthread_mutexattr_setprotocol() functions may fail if:
The value specified byattr orprotocol is invalid.
The caller does not have the privilege to perform the operation.
Seeattributes(5) for descriptions of the following attributes:
|
pthread_attr_getschedparam(3C),pthread_mutex_init(3C),pthread_mutexattr_init(3C),sched_setparam(3C),sched_setscheduler(3C),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |