(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / man / pthread_mutexattr_init.man
blobb8389489046159aa397bf8f5c94596621c85d218
1 .TH PTHREAD_MUTEXATTR 3 LinuxThreads
3 .XREF pthread_mutexattr_destroy
4 .XREF pthread_mutexattr_settype
5 .XREF pthread_mutexattr_gettype
7 .SH NAME
8 pthread_mutexattr_init, pthread_mutexattr_destroy, pthread_mutexattr_settype, pthread_mutexattr_gettype \- mutex creation attributes
10 .SH SYNOPSIS
11 #include <pthread.h>
13 int pthread_mutexattr_init(pthread_mutexattr_t *attr);
15 int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
17 int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
19 int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind);
21 .SH DESCRIPTION
23 Mutex attributes can be specified at mutex creation time, by passing a
24 mutex attribute object as second argument to !pthread_mutex_init!(3).
25 Passing !NULL! is equivalent to passing a mutex attribute object with
26 all attributes set to their default values.
28 !pthread_mutexattr_init! initializes the mutex attribute object |attr|
29 and fills it with default values for the attributes.
31 !pthread_mutexattr_destroy! destroys a mutex attribute object, which
32 must not be reused until it is reinitialized. !pthread_mutexattr_destroy!
33 does nothing in the LinuxThreads implementation. 
35 LinuxThreads supports only one mutex attribute: the mutex kind, which
36 is either !PTHREAD_MUTEX_FAST_NP! for ``fast'' mutexes,
37 !PTHREAD_MUTEX_RECURSIVE_NP! for ``recursive'' mutexes,
38 or !PTHREAD_MUTEX_ERRORCHECK_NP! for ``error checking'' mutexes.
39 As the !NP! suffix indicates, this is a non-portable extension to the
40 POSIX standard and should not be employed in portable programs.
42 The mutex kind determines what happens if a thread attempts to lock a
43 mutex it already owns with !pthread_mutex_lock!(3). If the mutex is of
44 the ``fast'' kind, !pthread_mutex_lock!(3) simply suspends the calling
45 thread forever.  If the mutex is of the ``error checking'' kind,
46 !pthread_mutex_lock!(3) returns immediately with the error code
47 !EDEADLK!.  If the mutex is of the ``recursive'' kind, the call to
48 !pthread_mutex_lock!(3) returns immediately with a success return
49 code. The number of times the thread owning the mutex has locked it is
50 recorded in the mutex. The owning thread must call
51 !pthread_mutex_unlock!(3) the same number of times before the mutex
52 returns to the unlocked state.
54 The default mutex kind is ``fast'', that is, !PTHREAD_MUTEX_FAST_NP!.
56 !pthread_mutexattr_settype! sets the mutex kind attribute in |attr|
57 to the value specified by |kind|.
59 !pthread_mutexattr_gettype! retrieves the current value of the
60 mutex kind attribute in |attr| and stores it in the location pointed
61 to by |kind|.
63 .SH "RETURN VALUE"
64 !pthread_mutexattr_init!, !pthread_mutexattr_destroy! and
65 !pthread_mutexattr_gettype! always return 0.
67 !pthread_mutexattr_settype! returns 0 on success and a non-zero
68 error code on error.
70 .SH ERRORS
72 On error, !pthread_mutexattr_settype! returns the following error code:
73 .TP
74 !EINVAL!
75 |kind| is neither !PTHREAD_MUTEX_FAST_NP! nor !PTHREAD_MUTEX_RECURSIVE_NP!
76 nor !PTHREAD_MUTEX_ERRORCHECK_NP!
78 .SH AUTHOR
79 Xavier Leroy <Xavier.Leroy@inria.fr>
81 .SH "SEE ALSO"
82 !pthread_mutex_init!(3),
83 !pthread_mutex_lock!(3),
84 !pthread_mutex_unlock!(3).