Index: share/man/man3/pthread_mutex_init.3 =================================================================== --- share/man/man3/pthread_mutex_init.3 +++ share/man/man3/pthread_mutex_init.3 @@ -47,6 +47,104 @@ If .Fa attr is NULL the default attributes are used. +.Bd -literal +struct pthread_mutex_attr { + enum pthread_mutextype m_type; + int m_protocol; + int m_ceiling; + int m_pshared; + int m_robust; +}; +.Ed +.Pp +.Va m_type +can have the following values: +.Bl -tag -width "PTHREAD_MUTEX_ADAPTIVE_NP" +.It Dv PTHREAD_MUTEX_ERRORCHECK +Provide error checking. +This is the default. +An error will be returned when attempting to relock a mutex without +first unlocking it, when attempting to unlock a mutex which another +thread has locked, or when attempting to unlock an unlocked mutex. +.It Dv PTHREAD_MUTEX_DEFAULT +Use the implementation default scheduling. +For +.Fx , +this is PTHREAD_MUTEX_ERRORCHECK. +.It Dv PTHREAD_MUTEX_RECURSIVE +A recursive mutex. +Multiple locks of this mutex will require the same number of unlocks +to release the mutex before another thread can acquire the mutex. +A thread attempting to unlock a mutex held by another thread will +return with an error. +.It Dv PTHREAD_MUTEX_NORMAL +Do not check for deadlock. +A thread attempting to relock this mutex without first unlocking +it will deadlock. +Attempting to unlock a thread mutex locked by a different thread, +or attempting to unlock an unlocked mutex results in undefined behavior. +This is the default. +.It Dv PTHREAD_MUTEX_ADAPTIVE_NP +Adaptive mutex, spins briefly before blocking on lock. +.El +.Pp +.Va m_protocol +can have the following values: +.Bl -tag -width "PTHREAD_PRIO_PROTECT" +.It Dv PTHREAD_PRIO_NONE +Scheduling and priority of a thread are not affected by its mutex +ownership. +.It Dv PTHREAD_PRIO_INHERIT +Execute the thread at the higher of the thread's priority or the +highest priority thread waiting on any of the mutexes owned by this +thread and initialized with this protocol. +.It Dv PTHREAD_PRIO_PROTECT +Execute the thread at the higher of its priority or the highest of +the priority ceilings of all the mutexes owned by this thread and +initialized with this attribute, regardless of whether other threads +are blocked on any of these mutexes or not. +.El +.Pp +If a thread simultaneously owns several mutexes initialized with +different protocols, it will execute at the highest priority that +it would have obtained by each of these protocols. +.Pp +.Va m_ceiling +defines the priority ceiling of initialized mutexes, which is the +minimum priority level at which the critical section guarded by a +mutex is executed. +Defined values include: +.Pp +.Bl -tag -width "SCHED_OTHER" +.It Dv SCHED_FIFO +First in-first out (FIFO) fixed priority scheduling policy +with no round-robin scheduling. +If the thread is not interrupted by a higher-priority thread, the +thread will proceed to completion. +.It Dv SCHED_OTHER +The standard time sharing scheduler. +.It Dv SCHED_RR +Round-robin scheduling across same priority processes. +If the thread is not interrupted by a higher-priority thread, the +thread will execute for a time determined by the system. +.El +.Pp +.Va m_pshared +is the +.Em process-shared +attribute and can have the following values: +.Bl -tag -width "PTHREAD_PROCESS_PRIVATE" +.It Dv PTHREAD_PROCESS_PRIVATE +The mutex can only be operated on by threads created within the +same process as the thread that initialized the mutex. +Threads of differing processes attempting to access a mutex +with this set results in undefined behavior. +This is the default. +.It Dv PTHREAD_PROCESS_SHARED +Any thread that has access to the memory where mutex is allocated +can operate on this mutex, even if the memory is shared by +multiple processes. +.El .Sh RETURN VALUES If successful, .Fn pthread_mutex_init