Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Robust mutexes merged from devel branch

  • Loading branch information...
commit 6c545bb427c1f27fb1eea19b0155afb5b7cc9855 1 parent 0eed0cc
rpj authored
Showing with 3,165 additions and 805 deletions.
  1. +16 −19 ANNOUNCE
  2. +4 −1 Bmakefile
  3. +16 −0 ChangeLog
  4. +12 −3 GNUmakefile
  5. +9 −1 Makefile
  6. +45 −10 NEWS
  7. +7 −13 README.NONPORTABLE
  8. +41 −38 create.c
  9. +11 −6 global.c
  10. +49 −23 implement.h
  11. +9 −1 manual/ChangeLog
  12. +145 −133 manual/index.html
  13. +76 −0 manual/pthread_getunique_np.html
  14. +152 −73 manual/pthread_mutex_init.html
  15. +111 −61 manual/pthread_mutexattr_init.html
  16. +3 −0  mutex.c
  17. +4 −0 need_errno.h
  18. +1 −0  nonportable.c
  19. +32 −8 pthread.h
  20. +1 −1  pthread_barrier_destroy.c
  21. +1 −1  pthread_barrier_wait.c
  22. +5 −4 pthread_cancel.c
  23. +4 −3 pthread_delay_np.c
  24. +14 −20 pthread_detach.c
  25. +47 −0 pthread_getunique_np.c
  26. +1 −1  pthread_key_create.c
  27. +16 −24 pthread_key_delete.c
  28. +190 −0 pthread_mutex_consistent.c
  29. +7 −3 pthread_mutex_destroy.c
  30. +39 −13 pthread_mutex_init.c
  31. +181 −51 pthread_mutex_lock.c
  32. +175 −47 pthread_mutex_timedlock.c
  33. +80 −18 pthread_mutex_trylock.c
  34. +100 −44 pthread_mutex_unlock.c
  35. +113 −0 pthread_mutexattr_getrobust.c
  36. +119 −0 pthread_mutexattr_setrobust.c
  37. +4 −3 pthread_setcancelstate.c
  38. +4 −3 pthread_setcanceltype.c
  39. +16 −18 pthread_setschedparam.c
  40. +27 −28 pthread_setspecific.c
  41. +4 −3 pthread_testcancel.c
  42. +22 −2 pthread_win32_attach_detach_np.c
  43. +7 −7 ptw32_MCS_lock.c
  44. +13 −11 ptw32_callUserDestroyRoutines.c
  45. +5 −2 ptw32_new.c
  46. +2 −0  ptw32_reuse.c
  47. +0 −3  ptw32_threadDestroy.c
  48. +12 −9 ptw32_threadStart.c
  49. +2 −0  ptw32_throw.c
  50. +1 −1  ptw32_tkAssocCreate.c
  51. +1 −1  ptw32_tkAssocDestroy.c
  52. +8 −1 tests/Bmakefile
  53. +26 −0 tests/ChangeLog
  54. +18 −4 tests/GNUmakefile
  55. +10 −2 tests/Makefile
  56. +3 −3 tests/SIZES.GC
  57. +3 −3 tests/SIZES.VC
  58. +21 −19 tests/SIZES.VSE
  59. +8 −1 tests/Wmakefile
  60. +20 −4 tests/benchtest1.c
  61. +21 −5 tests/benchtest2.c
  62. +20 −4 tests/benchtest3.c
  63. +20 −4 tests/benchtest4.c
  64. +4 −1 tests/cancel6d.c
  65. +4 −0 tests/mutex1e.c
  66. +4 −0 tests/mutex1n.c
  67. +4 −0 tests/mutex1r.c
  68. +10 −12 tests/mutex4.c
  69. +8 −1 tests/mutex6e.c
  70. +12 −9 tests/mutex6n.c
  71. +8 −1 tests/mutex6r.c
  72. +1 −1  tests/mutex7.c
  73. +8 −2 tests/mutex7e.c
  74. +10 −3 tests/mutex7n.c
  75. +8 −1 tests/mutex7r.c
  76. +7 −1 tests/mutex8e.c
  77. +7 −1 tests/mutex8n.c
  78. +7 −1 tests/mutex8r.c
  79. +141 −0 tests/robust1.c
  80. +143 −0 tests/robust2.c
  81. +149 −0 tests/robust3.c
  82. +199 −0 tests/robust4.c
  83. +120 −0 tests/robust5.c
  84. +1 −1  tests/rwlock3.c
  85. +1 −1  tests/rwlock4.c
  86. +1 −1  tests/rwlock5.c
  87. +3 −3 tests/rwlock6.c
  88. +142 −0 tests/sequence1.c
  89. +25 −1 tests/test.h
  90. +4 −3 w32_CancelableWait.c
View
35 ANNOUNCE
@@ -154,12 +154,16 @@ The following functions are implemented:
PTHREAD_MUTEX_NORMAL
PTHREAD_MUTEX_ERRORCHECK
PTHREAD_MUTEX_RECURSIVE )
+ pthread_mutexattr_getrobust
+ pthread_mutexattr_setrobust (values: PTHREAD_MUTEX_STALLED
+ PTHREAD_MUTEX_ROBUST)
pthread_mutex_init
pthread_mutex_destroy
pthread_mutex_lock
pthread_mutex_trylock
pthread_mutex_timedlock
pthread_mutex_unlock
+ pthread_mutex_consistent
---------------------------
Condition Variables
@@ -262,6 +266,7 @@ The following functions are implemented:
pthread_getw32threadhandle_np
pthread_timechange_handler_np
pthread_delay_np
+ pthread_getunique_np
pthread_mutexattr_getkind_np
pthread_mutexattr_setkind_np (types: PTHREAD_MUTEX_FAST_NP,
PTHREAD_MUTEX_ERRORCHECK_NP,
@@ -292,16 +297,15 @@ The following functions are implemented:
PTHREAD_SPINLOCK_INITIALIZER
-The following functions are not implemented:
-
- ---------------------------
- Mutexes
- ---------------------------
- pthread_mutexattr_getrobust
- pthread_mutexattr_setrobust
+The library includes two non-API functions for creating cancellation
+points in applications and libraries:
+
+ pthreadCancelableWait
+ pthreadCancelableTimedWait
- pthread_mutex_consistent
+The following functions are not implemented:
+
---------------------------
RealTime Scheduling
---------------------------
@@ -360,13 +364,6 @@ The following functions are not implemented:
rand_r
-The library includes two non-API functions for creating cancellation
-points in applications and libraries:
-
- pthreadCancelableWait
- pthreadCancelableTimedWait
-
-
Availability
------------
@@ -416,7 +413,7 @@ Mingw using C setjmp/longjmp works. Distribute pthreadGC.dll with your applicati
Cygwin: (http://sourceware.cygnus.com/cygwin/)
-Developers using Cygwin will not need pthreads-win32 since it has POSIX threads
+Developers using Cygwin do not need pthreads-win32 since it has POSIX threads
support. Refer to its documentation for details and extent.
@@ -429,9 +426,9 @@ Generally:
For convenience, the following pre-built files are available on the FTP site
(see Availability above):
- pthread.h - for POSIX 1c threads
- semaphore.h - for POSIX 1b semaphores
- sched.h - for POSIX 1b scheduling
+ pthread.h - for POSIX threads
+ semaphore.h - for POSIX semaphores
+ sched.h - for POSIX scheduling
pthreadVCE.dll - built with MSVC++ compiler using C++ EH
pthreadVCE.lib
pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp
View
5 Bmakefile
@@ -116,10 +116,13 @@ MUTEX_SRCS = \
pthread_mutexattr_setpshared.c \
pthread_mutexattr_settype.c \
pthread_mutexattr_gettype.c \
+ pthread_mutexattr_setrobust.c \
+ pthread_mutexattr_getrobust.c \
pthread_mutex_lock.c \
pthread_mutex_timedlock.c \
pthread_mutex_unlock.c \
- pthread_mutex_trylock.c
+ pthread_mutex_trylock.c \
+ pthread_mutex_consistent.c
NONPORTABLE_SRCS = \
pthread_mutexattr_setkind_np.c \
View
16 ChangeLog
@@ -1,3 +1,19 @@
+2011-03-26 Ross Johnson <ross.johnson at homemail.com.au>
+
+ * pthread_getunique_np.c: New non-POSIX interface for compatibility
+ with some other implementations; returns a 64 bit sequence number
+ that is unique to each thread in the process.
+ * pthread.h (pthread_getunique_np): Added.
+ * global.c: Add global sequence counter for above.
+ * implement.h: Likewise.
+
+2011-03-25 Ross Johnson <ross.johnson at homemail.com.au>
+
+ * (cancelLock): Convert to an MCS lock and rename to stateLock.
+ * (threadLock): Likewise.
+ * (keyLock): Likewise.
+ * pthread_mutex*.c: First working robust mutexes.
+
2011-03-11 Ross Johnson <ross.johnson at homemail.com.au>
* implement.h (PTW32_INTERLOCKED_*CREMENT macros): increment/decrement
View
15 GNUmakefile
@@ -48,7 +48,7 @@ CP = cp -f
#CP = copy
# For cross compiling use e.g.
-# make CROSS=i386-mingw32msvc- clean GC-inlined
+# make CROSS=x86_64-w64-mingw32- clean GC-inlined
CROSS =
AR = $(CROSS)ar
@@ -58,7 +58,7 @@ CXX = $(CROSS)g++
RANLIB = $(CROSS)ranlib
RC = $(CROSS)windres
-OPT = $(CLEANUP) -O3 -finline-functions
+OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining
DOPT = $(CLEANUP) -g -O0
XOPT =
@@ -184,13 +184,17 @@ SMALL_STATIC_OBJS = \
pthread_mutexattr_setpshared.o \
pthread_mutexattr_settype.o \
pthread_mutexattr_gettype.o \
+ pthread_mutexattr_setrobust.o \
+ pthread_mutexattr_getrobust.o \
pthread_mutex_lock.o \
pthread_mutex_timedlock.o \
pthread_mutex_unlock.o \
pthread_mutex_trylock.o \
+ pthread_mutex_consistent.o \
pthread_mutexattr_setkind_np.o \
pthread_mutexattr_getkind_np.o \
pthread_getw32threadhandle_np.o \
+ pthread_getunique_np.o \
pthread_delay_np.o \
pthread_num_processors_np.o \
pthread_win32_attach_detach_np.o \
@@ -338,15 +342,19 @@ MUTEX_SRCS = \
pthread_mutexattr_setpshared.c \
pthread_mutexattr_settype.c \
pthread_mutexattr_gettype.c \
+ pthread_mutexattr_setrobust.c \
+ pthread_mutexattr_getrobust.c \
pthread_mutex_lock.c \
pthread_mutex_timedlock.c \
pthread_mutex_unlock.c \
- pthread_mutex_trylock.c
+ pthread_mutex_trylock.c \
+ pthread_mutex_consistent.c
NONPORTABLE_SRCS = \
pthread_mutexattr_setkind_np.c \
pthread_mutexattr_getkind_np.c \
pthread_getw32threadhandle_np.c \
+ pthread_getunique_np.c \
pthread_delay_np.c \
pthread_num_processors_np.c \
pthread_win32_attach_detach_np.c \
@@ -548,6 +556,7 @@ $(GC_STATIC_STAMP) $(GCD_STATIC_STAMP): $(DLL_INLINED_OBJS)
clean:
-$(RM) *~
-$(RM) *.i
+ -$(RM) *.s
-$(RM) *.o
-$(RM) *.obj
-$(RM) *.exe
View
10 Makefile
@@ -130,13 +130,17 @@ SMALL_STATIC_OBJS = \
pthread_mutexattr_setpshared.obj \
pthread_mutexattr_settype.obj \
pthread_mutexattr_gettype.obj \
+ pthread_mutexattr_setrobust.obj \
+ pthread_mutexattr_getrobust.obj \
pthread_mutex_lock.obj \
pthread_mutex_timedlock.obj \
pthread_mutex_unlock.obj \
pthread_mutex_trylock.obj \
+ pthread_mutex_consistent.obj \
pthread_mutexattr_setkind_np.obj \
pthread_mutexattr_getkind_np.obj \
pthread_getw32threadhandle_np.obj \
+ pthread_getunique_np.obj \
pthread_delay_np.obj \
pthread_num_processors_np.obj \
pthread_win32_attach_detach_np.obj \
@@ -280,15 +284,19 @@ MUTEX_SRCS = \
pthread_mutexattr_setpshared.c \
pthread_mutexattr_settype.c \
pthread_mutexattr_gettype.c \
+ pthread_mutexattr_setrobust.c \
+ pthread_mutexattr_getrobust.c \
pthread_mutex_lock.c \
pthread_mutex_timedlock.c \
pthread_mutex_unlock.c \
- pthread_mutex_trylock.c
+ pthread_mutex_trylock.c \
+ pthread_mutex_consistent.c
NONPORTABLE_SRCS = \
pthread_mutexattr_setkind_np.c \
pthread_mutexattr_getkind_np.c \
pthread_getw32threadhandle_np.c \
+ pthread_getunique_np.c \
pthread_delay_np.c \
pthread_num_processors_np.c \
pthread_win32_attach_detach_np.c \
View
55 NEWS
@@ -31,11 +31,6 @@ the full test suite, stress tests and benchmarks.
New Features
------------
-Dependence on the winsock library is now discretionary via
-#define RETAIN_WSALASTERROR in config.h. It is undefined by default unless
-WINCE is defined (because I (RJ) am unsure of the dependency there).
-- Ramiro Polla
-
(MSC and GNU builds) The statically linked library now automatically
initialises and cleans up on program start/exit, i.e. statically linked
applications need not call the routines pthread_win32_process_attach_np()
@@ -49,6 +44,19 @@ POSIX TSD (TLS) destructors.
See README.NONPORTABLE for descriptions of these routines.
- Ramiro Polla
+Robust mutexes are implemented within the PROCESS_PRIVATE scope. NOTE that
+pthread_mutex_* functions may return different error codes for robust
+mutexes than they otherwise do in normal usage, e.g. pthread_mutex_unlock
+is required to check ownership for all mutex types when the mutex is
+robust, whereas this does not occur for the "normal" non-robust mutex type.
+- Ross Johnson
+
+pthread_getunique_np is implemented for source level compatibility
+with some other implementations. This routine returns a 64 bit
+sequence number that is uniquely associated with a thread. It can be
+used by applications to order or hash POSIX thread handles.
+- Ross Johnson
+
Bug fixes
---------
Many more changes for 64 bit systems.
@@ -75,11 +83,10 @@ Removed potential NULL pointer reference.
- Robert Kindred
Removed the requirement that applications restrict the number of threads
-calling pthread_barrier_wait() [on the same barrier] to just the barrier
-count in order to avoid contention and dead lock. Also reduced the
-contention between barrier_wait and barrier_destroy. This change will
-have slowed barriers down slightly but halves the number of semaphores
-consumed per barrier to one.
+calling pthread_barrier_wait to just the barrier count. Also reduced the
+contention between barrier_wait and barrier_destroy. This change will have
+slowed barriers down slightly but halves the number of semaphores consumed
+per barrier to one.
- Ross Johnson
Fixed a handle leak in sched_[gs]etscheduler.
@@ -89,6 +96,34 @@ Removed all of the POSIX re-entrant function compatibility macros from pthread.h
Some were simply not semanticly correct.
- Igor Lubashev
+Threads no longer attempt to pass uncaught exceptions out of thread scope (C++
+and SEH builds only). Uncaught exceptions now cause the thread to exit with
+the return code PTHREAD_CANCELED.
+- Ross Johnson
+
+Other changes
+-------------
+Dependence on the winsock library is now discretionary via
+#define RETAIN_WSALASTERROR in config.h. It is undefined by default unless
+WINCE is defined (because RJ is unsure of the dependency there).
+- Ramiro Polla
+
+Several static POSIX mutexes used for internal management were replaced by
+MCS queue-based locks to reduce resource consumption, in particular use of Win32
+objects.
+- Ross Johnson
+
+New tests
+---------
+robust[1-5].c - Robust mutexes
+sequence1.c - per-thread unique sequence numbers
+
+Modified tests and benchtests
+-----------------------------
+All mutex*.c tests wherever appropriate have been modified to also test
+robust mutexes under the same conditions.
+Added robust mutex benchtests to benchtest*.c wherever appropriate.
+
RELEASE 2.8.0
-------------
View
20 README.NONPORTABLE
@@ -347,8 +347,6 @@ rewritten.]
Doesn't the compiler take care of padding?
-Answer a question with two questions: Which compiler? Which language?
-
The C89 and later standards only effectively guarrantee element-by-element
equivalence following an assignment or pass by value of a struct or union,
therefore undefined areas of any two otherwise equivalent pthread_t instances
@@ -396,11 +394,10 @@ pthread_null()
pthread_compare()
pthread_hash()
-However these are very specific and are unlikely to make it into the
-standard. A signle more general purpose function can be defined as a
-basis for all three of the above functions.
+A single more general purpose function could also be defined as a
+basis for at least the last two of the above functions.
-But first we need to list the freedoms and constraints with restpect
+First we need to list the freedoms and constraints with restpect
to pthread_t so that we can be sure our solution is compatible with the
standard.
@@ -414,13 +411,10 @@ itself.
at compile-time and size-invariant, because it must be able to copy the object
(i.e. through assignment and pass-by-value). Such copies must be genuine
duplicates, not merely a copy of a pointer to a common instance such as
-would be the case if pthread_t were defined as an array. There is evidence that
-this is or was the intention also in the rationale, where it expects that
-pthread_t is hashable, and that is only possible if the application can
-determine the size of pthread_t (e.g. via sizeof() in C).
+would be the case if pthread_t were defined as an array.
-The following candidate function is proposed
+Suppose we define the following function:
/* This function shall return it's argument */
pthread_t* pthread_normalize(pthread_t* thread);
@@ -446,7 +440,7 @@ Advantages:
1) In most existing implementations this function would reduce to a no-op that
emits no additional instructions, i.e after in-lining or optimisation, or if
defined as a macro:
-#define pthread_normalise(tptr) tptr
+#define pthread_normalise(tptr) (tptr)
2) This single function allows an application to portably derive
application-level versions of any of the other required functions.
@@ -633,7 +627,7 @@ t = null_tid;
Note that we don't have to explicitly make use of the __size array at all. It's
-there just to alter the semantics of the compiler.
+there just to force the compiler behaviour we want.
Partial solutions without a pthread_normalize function
View
79 create.c
@@ -227,44 +227,47 @@ pthread_create (pthread_t * tid,
#else
- /*
- * This lock will force pthread_threadStart() to wait until we have
- * the thread handle and have set the priority.
- */
- (void) pthread_mutex_lock (&tp->cancelLock);
-
- tp->threadH =
- threadH =
- (HANDLE) _beginthread (ptw32_threadStart, (unsigned) stackSize, /* default stack size */
- parms);
-
- /*
- * Make the return code match _beginthreadex's.
- */
- if (threadH == (HANDLE) - 1L)
- {
- tp->threadH = threadH = 0;
- }
- else
- {
- if (!run)
- {
- /*
- * beginthread does not allow for create flags, so we do it now.
- * Note that beginthread itself creates the thread in SUSPENDED
- * mode, and then calls ResumeThread to start it.
- */
- SuspendThread (threadH);
- }
-
- if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
- }
-
- (void) pthread_mutex_unlock (&tp->cancelLock);
-
+ {
+ ptw32_mcs_local_node_t stateLock;
+
+ /*
+ * This lock will force pthread_threadStart() to wait until we have
+ * the thread handle and have set the priority.
+ */
+ ptw32_mcs_lock_acquire(&tp->stateLock, &stateLock);
+
+ tp->threadH =
+ threadH =
+ (HANDLE) _beginthread (ptw32_threadStart, (unsigned) stackSize, /* default stack size */
+ parms);
+
+ /*
+ * Make the return code match _beginthreadex's.
+ */
+ if (threadH == (HANDLE) - 1L)
+ {
+ tp->threadH = threadH = 0;
+ }
+ else
+ {
+ if (!run)
+ {
+ /*
+ * beginthread does not allow for create flags, so we do it now.
+ * Note that beginthread itself creates the thread in SUSPENDED
+ * mode, and then calls ResumeThread to start it.
+ */
+ SuspendThread (threadH);
+ }
+
+ if (a != NULL)
+ {
+ (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
+ }
+ }
+
+ ptw32_mcs_lock_release (&stateLock);
+ }
#endif
result = (threadH != 0) ? 0 : EAGAIN;
View
17 global.c
@@ -52,6 +52,11 @@ int ptw32_concurrency = 0;
/* What features have been auto-detected */
int ptw32_features = 0;
+/*
+ * Global [process wide] thread sequence Number
+ */
+unsigned long long ptw32_threadSeqNumber = 0;
+
/*
* Function pointer to QueueUserAPCEx if it exists, otherwise
* it will be set at runtime to a substitute routine which cannot unblock
@@ -62,37 +67,37 @@ DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD) = NULL;
/*
* Global lock for managing pthread_t struct reuse.
*/
-ptw32_mcs_lock_t ptw32_thread_reuse_lock;
+ptw32_mcs_lock_t ptw32_thread_reuse_lock = 0;
/*
* Global lock for testing internal state of statically declared mutexes.
*/
-ptw32_mcs_lock_t ptw32_mutex_test_init_lock;
+ptw32_mcs_lock_t ptw32_mutex_test_init_lock = 0;
/*
* Global lock for testing internal state of PTHREAD_COND_INITIALIZER
* created condition variables.
*/
-ptw32_mcs_lock_t ptw32_cond_test_init_lock;
+ptw32_mcs_lock_t ptw32_cond_test_init_lock = 0;
/*
* Global lock for testing internal state of PTHREAD_RWLOCK_INITIALIZER
* created read/write locks.
*/
-ptw32_mcs_lock_t ptw32_rwlock_test_init_lock;
+ptw32_mcs_lock_t ptw32_rwlock_test_init_lock = 0;
/*
* Global lock for testing internal state of PTHREAD_SPINLOCK_INITIALIZER
* created spin locks.
*/
-ptw32_mcs_lock_t ptw32_spinlock_test_init_lock;
+ptw32_mcs_lock_t ptw32_spinlock_test_init_lock = 0;
/*
* Global lock for condition variable linked list. The list exists
* to wake up CVs when a WM_TIMECHANGE message arrives. See
* w32_TimeChangeHandler.c.
*/
-ptw32_mcs_lock_t ptw32_cond_list_lock;
+ptw32_mcs_lock_t ptw32_cond_list_lock = 0;
#ifdef _UWIN
/*
View
72 implement.h
@@ -112,19 +112,24 @@ typedef enum
PThreadStateInitial = 0, /* Thread not running */
PThreadStateRunning, /* Thread alive & kicking */
PThreadStateSuspended, /* Thread alive but suspended */
- PThreadStateCancelPending, /* Thread alive but is */
- /* has cancelation pending. */
+ PThreadStateCancelPending, /* Thread alive but */
+ /* has cancelation pending. */
PThreadStateCanceling, /* Thread alive but is */
- /* in the process of terminating */
- /* due to a cancellation request */
- PThreadStateException, /* Thread alive but exiting */
- /* due to an exception */
- PThreadStateLast
+ /* in the process of terminating */
+ /* due to a cancellation request */
+ PThreadStateExiting, /* Thread alive but exiting */
+ /* due to an exception */
+ PThreadStateLast, /* All handlers have been run and now */
+ /* final cleanup can be done. */
+ PThreadStateReuse /* In reuse pool. */
}
PThreadState;
+typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t;
+typedef struct ptw32_mcs_node_t_* ptw32_mcs_lock_t;
+typedef struct ptw32_robust_node_t_ ptw32_robust_node_t;
+typedef struct ptw32_thread_t_ ptw32_thread_t;
-typedef struct ptw32_thread_t_ ptw32_thread_t;
struct ptw32_thread_t_
{
@@ -141,9 +146,9 @@ struct ptw32_thread_t_
void *parms;
int ptErrno;
int detachState;
- pthread_mutex_t threadLock; /* Used for serialised access to public thread state */
+ ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */
int sched_priority; /* As set, not as currently is */
- pthread_mutex_t cancelLock; /* Used for async-cancel safety */
+ ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */
int cancelState;
int cancelType;
HANDLE cancelEvent;
@@ -156,6 +161,10 @@ struct ptw32_thread_t_
int implicit:1;
void *keys;
void *nextAssoc;
+ ptw32_mcs_lock_t
+ robustMxListLock; /* robustMxList lock */
+ ptw32_robust_node_t*
+ robustMxList; /* List of currenty held robust mutexes */
};
@@ -215,12 +224,35 @@ struct pthread_mutex_t_
pthread_t ownerThread;
HANDLE event; /* Mutex release notification to waiting
threads. */
+ ptw32_robust_node_t*
+ robustNode; /* Extra state for robust mutexes */
+};
+
+enum ptw32_robust_state_t_
+{
+ PTW32_ROBUST_CONSISTENT,
+ PTW32_ROBUST_INCONSISTENT,
+ PTW32_ROBUST_NOTRECOVERABLE
+};
+
+typedef enum ptw32_robust_state_t_ ptw32_robust_state_t;
+
+/*
+ * Node used to manage per-thread lists of currently-held robust mutexes.
+ */
+struct ptw32_robust_node_t_
+{
+ pthread_mutex_t mx;
+ ptw32_robust_state_t stateInconsistent;
+ ptw32_robust_node_t* prev;
+ ptw32_robust_node_t* next;
};
struct pthread_mutexattr_t_
{
int pshared;
int kind;
+ int robustness;
};
/*
@@ -267,9 +299,6 @@ struct ptw32_mcs_node_t_
successor */
};
-typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t;
-typedef struct ptw32_mcs_node_t_ *ptw32_mcs_lock_t;
-
struct pthread_barrier_t_
{
@@ -277,7 +306,7 @@ struct pthread_barrier_t_
unsigned int nInitialBarrierHeight;
int pshared;
sem_t semBarrierBreeched;
- void * lock; /* MCS lock */
+ ptw32_mcs_lock_t lock;
ptw32_mcs_local_node_t proxynode;
};
@@ -290,7 +319,7 @@ struct pthread_key_t_
{
DWORD key;
void (*destructor) (void *);
- pthread_mutex_t keyLock;
+ ptw32_mcs_lock_t keyLock;
void *threads;
};
@@ -532,6 +561,8 @@ extern pthread_cond_t ptw32_cond_list_tail;
extern int ptw32_mutex_default_kind;
+extern unsigned long long ptw32_threadSeqNumber;
+
extern int ptw32_concurrency;
extern int ptw32_features;
@@ -566,14 +597,9 @@ extern "C"
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
- PTW32_INTERLOCKED_LONG WINAPI
- ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LPLONG location,
- PTW32_INTERLOCKED_LONG value,
- PTW32_INTERLOCKED_LONG comparand);
-
- LONG WINAPI
- ptw32_InterlockedExchange (LPLONG location,
- LONG value);
+ int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
+ void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
+ void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
DWORD
ptw32_RegisterCancelation (PAPCFUNC callback,
View
10 manual/ChangeLog
@@ -1,6 +1,14 @@
+2011-03-26 Ross Johnson <ross at homemail dot com dot au>
+
+ * pthread_nutex_init.html (robust mutexes): Added
+ descriptions for newly implemented interface.
+ * pthread_mutexattr_init.html (robust mutexes): Likewise.
+ * pthread_getsequence_np.html: New.
+ * index.html: Updated.
+
2008-06-30 Ross Johnson <ross at callisto.canberra.edu.au>
- pthread_setschedparam.html: Fix "see also" links.
+ * pthread_setschedparam.html: Fix "see also" links.
2005-05-06 Ross Johnson <ross at callisto.canberra.edu.au>
View
278 manual/index.html
@@ -3,144 +3,156 @@
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<TITLE></TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Linux)">
<META NAME="CREATED" CONTENT="20050504;17350500">
- <META NAME="CHANGED" CONTENT="20050506;12240700">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <META NAME="CHANGED" CONTENT="20110326;18352700">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "AR PL UMing CN" }
+ H4.ctl { font-family: "Lohit Devanagari" }
+ H3.cjk { font-family: "AR PL UMing CN" }
+ H3.ctl { font-family: "Lohit Devanagari" }
+ H2.cjk { font-family: "AR PL UMing CN" }
+ H2.ctl { font-family: "Lohit Devanagari" }
+ -->
+ </STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
-<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
-<H3>Table of Contents</H3>
-<P STYLE="margin-left: 2cm"><A HREF="#sect1" NAME="toc1">POSIX
+<H4 CLASS="western">POSIX Threads for Windows – REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<H3 CLASS="western">Table of Contents</H3>
+<P STYLE="margin-left: 0.79in"><A HREF="#sect1" NAME="toc1">POSIX
threads API reference</A><BR><A HREF="#sect2" NAME="toc2">Miscellaneous
POSIX thread safe routines provided by Pthreads-w32</A><BR><A HREF="#sect3" NAME="toc3">Non-portable
Pthreads-w32 routines</A><BR><A HREF="#sect4" NAME="toc4">Other</A></P>
-<H2><A HREF="#toc1" NAME="sect1">POSIX threads API reference</A></H2>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getinheritsched</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedparam</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedpolicy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getscope</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_getstackaddr</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_getstacksize</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setdetachstate</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setinheritsched</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedparam</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedpolicy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setscope</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_setstackaddr</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_setstacksize</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_getpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_setpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_cancel</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_pop</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_getpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_setpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_broadcast</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_signal</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_create.html"><B>pthread_create</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_detach.html"><B>pthread_detach</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_equal.html"><B>pthread_equal</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_exit.html"><B>pthread_exit</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_setconcurrency.html"><B>pthread_getconcurrency</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_setschedparam.html"><B>pthread_getschedparam</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_getspecific</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_join.html"><B>pthread_join</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_key_create</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_key_delete</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_kill.html"><B>pthread_kill</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getkind_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_getpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_gettype</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setkind_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_setpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_lock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_timedlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_trylock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_unlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_once.html"><B>pthread_once</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_getpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_setpshared</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_self.html"><B>pthread_self</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_setcancelstate</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_setconcurrency.html"><B>pthread_setconcurrency</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_setspecific</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_kill.html"><B>pthread_sigmask</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_init.html"><B>pthread_spin_init</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_testcancel</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_max</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_min</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sched_yield.html"><B>sched_yield</B></A></P>
-<P STYLE="margin-left: 2cm"><B>sem_close</B></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_destroy</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_getvalue</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_init</B></A></P>
-<P STYLE="margin-left: 2cm"><B>sem_open</B></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_post</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_post_multiple</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_timedwait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_trywait</B></A></P>
-<P STYLE="margin-left: 2cm"><B>sem_unlink</B></P>
-<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_wait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_kill.html"><B>sigwait</B></A></P>
-<H2><A HREF="#toc2" NAME="sect2">Miscellaneous POSIX thread safe
-routines provided by Pthreads-w32</A></H2>
-<P STYLE="margin-left: 2cm"><B>asctime_r</B></P>
-<P STYLE="margin-left: 2cm"><B>ctime_r</B></P>
-<P STYLE="margin-left: 2cm"><B>gmtime_r</B></P>
-<P STYLE="margin-left: 2cm"><B>localtime_r</B></P>
-<P STYLE="margin-left: 2cm"><B>rand_r</B></P>
-<H2><A HREF="#toc3" NAME="sect3">Non-portable Pthreads-w32 routines</A></H2>
-<P STYLE="margin-left: 2cm"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableTimedWait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableWait</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_delay_np.html"><B>pthread_delay_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_getw32threadhandle_np.html"><B>pthread_getw32threadhandle_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_num_processors_np.html"><B>pthread_num_processors_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_test_features_np.html"><B>pthread_win32_test_features_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_timechange_handler_np.html"><B>pthread_timechange_handler_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_attach_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_detach_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_attach_np</B></A></P>
-<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_detach_np</B></A></P>
-<H2><A HREF="#toc4" NAME="sect4">Other</A></H2>
-<P STYLE="margin-left: 2cm"><A HREF="PortabilityIssues.html"><B>Portability
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">POSIX threads API
+reference</A></H2>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getinheritsched</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedparam</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedpolicy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_getscope</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_getstackaddr</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_getstacksize</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setdetachstate</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setinheritsched</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedparam</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedpolicy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_init.html"><B>pthread_attr_setscope</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_setstackaddr</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_setstacksize</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_getpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_setpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_cancel</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_pop</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_getpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_setpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_broadcast</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_signal</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_create.html"><B>pthread_create</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_detach.html"><B>pthread_detach</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_equal.html"><B>pthread_equal</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_exit.html"><B>pthread_exit</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_setconcurrency.html"><B>pthread_getconcurrency</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_setschedparam.html"><B>pthread_getschedparam</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_getunique_np.html"><B>pthread_getunique_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_getspecific</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_join.html"><B>pthread_join</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_key_create</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_key_delete</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_kill.html"><B>pthread_kill</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getkind_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_getpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getrobust</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_gettype</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setkind_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_setpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setrobust</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_consistent</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_lock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_timedlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_trylock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_unlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_once.html"><B>pthread_once</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_getpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_setpshared</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_self.html"><B>pthread_self</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_setcancelstate</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_setconcurrency.html"><B>pthread_setconcurrency</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_key_create.html"><B>pthread_setspecific</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_kill.html"><B>pthread_sigmask</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_init.html"><B>pthread_spin_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_cancel.html"><B>pthread_testcancel</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_max</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_min</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sched_yield.html"><B>sched_yield</B></A></P>
+<P STYLE="margin-left: 0.79in"><B>sem_close</B></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_destroy</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_getvalue</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_init</B></A></P>
+<P STYLE="margin-left: 0.79in"><B>sem_open</B></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_post</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_post_multiple</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_timedwait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_trywait</B></A></P>
+<P STYLE="margin-left: 0.79in"><B>sem_unlink</B></P>
+<P STYLE="margin-left: 0.79in"><A HREF="sem_init.html"><B>sem_wait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_kill.html"><B>sigwait</B></A></P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Non-portable
+Pthreads-w32 routines</A></H2>
+<P STYLE="margin-left: 0.79in"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableTimedWait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableWait</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_delay_np.html"><B>pthread_delay_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_getw32threadhandle_np.html"><B>pthread_getw32threadhandle_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_num_processors_np.html"><B>pthread_num_processors_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_test_features_np.html"><B>pthread_win32_test_features_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_timechange_handler_np.html"><B>pthread_timechange_handler_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_attach_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_detach_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_attach_np</B></A></P>
+<P STYLE="margin-left: 0.79in"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_detach_np</B></A></P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Other</A></H2>
+<P STYLE="margin-left: 0.79in"><A HREF="PortabilityIssues.html"><B>Portability
issues</B></A></P>
</BODY>
-</HTML>
+</HTML>
View
76 manual/pthread_getunique_np.html
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
+ <TITLE>PTHREAD_GETW32THREADHANDLE_NP manual page</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Linux)">
+ <META NAME="CREATED" CONTENT="20050505;322600">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <META NAME="CHANGED" CONTENT="20110326;18290500">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <!-- manual page source format generated by PolyglotMan v3.2, -->
+ <!-- available at http://polyglotman.sourceforge.net/ -->
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "AR PL UMing CN" }
+ H4.ctl { font-family: "Lohit Devanagari" }
+ H2.cjk { font-family: "AR PL UMing CN" }
+ H2.ctl { font-family: "Lohit Devanagari" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
+<H4 CLASS="western">POSIX Threads for Windows – REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<P><A HREF="index.html">Reference Index</A></P>
+<P><A HREF="#toc">Table of Contents</A></P>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<P STYLE="font-weight: normal">pthread_getunique_np – get the
+unique sequence number associated with a thread</P>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<P><B>#include &lt;pthread.h&gt;</B>
+</P>
+<P><B>unsigned long long pthread_getunique_np(pthread_t</B> <I>thread</I><B>);</B></P>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P>Returns the <B>unique </B><SPAN STYLE="font-weight: normal">64 bit
+sequence number</SPAN> assigned to <I>thread</I>.</P>
+<P>In <B>Pthreads-win32:</B></P>
+<UL>
+ <LI><P>the value returned is not reused after the thread terminates
+ so it is unique for the life of the process</P>
+ <LI><P>Windows native threads may obtain their own POSIX thread
+ sequence number by first retrieving their <B>pthread_t</B> handle
+ via <B>pthread_self</B> to use as the <I>thread</I> argument.</P>
+</UL>
+<P>This function was added for source code compatibility with some
+other POSIX threads implementations.</P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Cancellation</A></H2>
+<P>None.</P>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Return Value</A></H2>
+<P><B>pthread_getunique_np</B> returns the unique sequence number for
+<I>thread</I>.</P>
+<H2 CLASS="western"><A HREF="#toc5" NAME="sect5">Errors</A></H2>
+<P>None.</P>
+<H2 CLASS="western"><A HREF="#toc6" NAME="sect6">Author</A></H2>
+<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
+<HR>
+<P><A NAME="toc"></A><B>Table of Contents</B></P>
+<UL>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect0" NAME="toc0">Name</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect2" NAME="toc2">Description</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect3" NAME="toc3">Cancellation</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect4" NAME="toc4">Return
+ Value</A>
+ </P>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect5" NAME="toc5">Errors</A>
+ </P>
+ <LI><P><A HREF="#sect6" NAME="toc6">Author</A>
+ </P>
+</UL>
+</BODY>
+</HTML>
View
225 manual/pthread_mutex_init.html
@@ -3,22 +3,37 @@
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<TITLE>PTHREAD_MUTEX(3) manual page</TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Linux)">
<META NAME="CREATED" CONTENT="20050505;5000">
- <META NAME="CHANGED" CONTENT="20050505;19000600">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <META NAME="CHANGED" CONTENT="20110326;15072100">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
<!-- manual page source format generated by PolyglotMan v3.2, -->
<!-- available at http://polyglotman.sourceforge.net/ -->
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "AR PL UMing CN" }
+ H4.ctl { font-family: "Lohit Devanagari" }
+ H2.cjk { font-family: "AR PL UMing CN" }
+ H2.ctl { font-family: "Lohit Devanagari" }
+ PRE.cjk { font-family: "AR PL UMing CN", monospace }
+ PRE.ctl { font-family: "Lohit Devanagari", monospace }
+ -->
+ </STYLE>
</HEAD>
<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
-<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<H4 CLASS="western">POSIX Threads for Windows – REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
<P><A HREF="index.html">Reference Index</A></P>
<P><A HREF="#toc">Table of Contents</A></P>
-<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
<P>pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock,
-pthread_mutex_timedlock, pthread_mutex_unlock, pthread_mutex_destroy
-- operations on mutexes
+pthread_mutex_timedlock, pthread_mutex_unlock,
+pthread_mutex_consistent, pthread_mutex_destroy - operations on
+mutexes
</P>
-<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
<P><B>#include &lt;pthread.h&gt;</B>
</P>
<P><B>#include &lt;time.h&gt;</B></P>
@@ -49,9 +64,11 @@
</P>
<P><B>int pthread_mutex_unlock(pthread_mutex_t *</B><I>mutex</I><B>);</B>
</P>
+<P><B>int pthread_mutex_consistent(pthread_mutex_t *</B><I>mutex</I><B>);</B>
+</P>
<P><B>int pthread_mutex_destroy(pthread_mutex_t *</B><I>mutex</I><B>);</B>
</P>
-<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
<P>A mutex is a MUTual EXclusion device, and is useful for protecting
shared data structures from concurrent modifications, and
implementing critical sections and monitors.
@@ -76,16 +93,22 @@
statically, using the constants <B>PTHREAD_MUTEX_INITIALIZER</B> (for
normal “fast” mutexes), <B>PTHREAD_RECURSIVE_MUTEX_INITIALIZER</B>
(for recursive mutexes), and <B>PTHREAD_ERRORCHECK_MUTEX_INITIALIZER</B>
-(for error checking mutexes). <SPAN STYLE="font-weight: medium"> In
-the <B>Pthreads-w32</B> implementation, an application should still
-call <B>pthread_mutex_destroy</B> at some point to ensure that any
+(for error checking mutexes). <SPAN STYLE="font-weight: normal">In
+the </SPAN><B>Pthreads-w32</B> <SPAN STYLE="font-weight: normal">implementation,
+an application should still call </SPAN><B>pthread_mutex_destroy</B>
+<SPAN STYLE="font-weight: normal">at some point to ensure that any
resources consumed by the mutex are released.</SPAN></P>
+<P><SPAN STYLE="font-weight: normal">Any mutex type can be
+initialized as a </SPAN><B>robust mutex</B><SPAN STYLE="font-weight: normal">.
+See </SPAN><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B><SPAN STYLE="font-weight: normal">(3)</SPAN></A>
+<SPAN STYLE="font-weight: normal">for more information as well as the
+section </SPAN><I><U><SPAN STYLE="font-weight: normal">Robust Mutexes</SPAN></U></I>
+<SPAN STYLE="font-weight: normal">below.</SPAN></P>
<P><B>pthread_mutex_lock</B> locks the given mutex. If the mutex is
currently unlocked, it becomes locked and owned by the calling
thread, and <B>pthread_mutex_lock</B> returns immediately. If the
mutex is already locked by another thread, <B>pthread_mutex_lock</B>
-suspends the calling thread until the mutex is unlocked.
-</P>
+suspends the calling thread until the mutex is unlocked.</P>
<P>If the mutex is already locked by the calling thread, the behavior
of <B>pthread_mutex_lock</B> depends on the type of the mutex. If the
mutex is of the “normal” type, the calling thread is suspended
@@ -101,15 +124,18 @@
<P><B>pthread_mutex_trylock</B> behaves identically to
<B>pthread_mutex_lock</B>, except that it does not block the calling
thread if the mutex is already locked by another thread (or by the
-calling thread in the case of a “normal” mutex). Instead,
-<B>pthread_mutex_trylock</B> returns immediately with the error code
-<B>EBUSY</B>.
+calling thread in the case of a “normal” or “<SPAN STYLE="font-style: normal">errorcheck</SPAN>”
+mutex). Instead, <B>pthread_mutex_trylock</B> returns immediately
+with the error code <B>EBUSY</B>.
</P>
<P><B>pthread_mutex_timedlock</B> behaves identically to
<B>pthread_mutex_lock</B>, except that if it cannot acquire the lock
before the <I>abs_timeout</I> time, the call returns with the error
code <B>ETIMEDOUT</B>. If the mutex can be locked immediately it is,
and the <B>abs_timeout</B> parameter is ignored.</P>
+<P><B>pthread_mutex_consistent</B> may only be called for
+<B>PTHREAD_MUTEX_ROBUST</B> mutexes. It simply marks the mutex as
+consistent. See <I><U>Robust Mutexes</U></I> below.</P>
<P><B>pthread_mutex_unlock</B> unlocks the given mutex. The mutex is
assumed to be locked and owned by the calling thread on entrance to
<B>pthread_mutex_unlock</B>. If the mutex is of the “normal”
@@ -117,19 +143,53 @@
state. If it is of the ‘‘recursive’’ type, it decrements the
locking count of the mutex (number of <B>pthread_mutex_lock</B>
operations performed on it by the calling thread), and only when this
-count reaches zero is the mutex actually unlocked.
-</P>
+count reaches zero is the mutex actually unlocked. In <B>Pthreads-win32</B>,
+non-robust normal or default mutex types do not check the owner of
+the mutex. For all types of robust mutexes the owner is checked and
+an error code is returned if the calling thread does not own the
+mutex.</P>
<P>On ‘‘error checking’’ mutexes, <B>pthread_mutex_unlock</B>
actually checks at run-time that the mutex is locked on entrance, and
that it was locked by the same thread that is now calling
<B>pthread_mutex_unlock</B>. If these conditions are not met, an
error code is returned and the mutex remains unchanged. ‘‘Normal’’
-mutexes perform no such checks, thus allowing a locked mutex to be
-unlocked by a thread other than its owner. This is non-portable
-behavior and is not meant to be used as a feature.</P>
+[non-robust] mutexes perform no such checks, thus allowing a locked
+mutex to be unlocked by a thread other than its owner. This is
+non-portable behavior and is not meant to be used as a feature.</P>
<P><B>pthread_mutex_destroy</B> destroys a mutex object, freeing the
resources it might hold. The mutex must be unlocked on entrance.</P>
-<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2>
+<H2 CLASS="western"><A HREF="#toc10" NAME="sect10">Robust Mutexes</A></H2>
+<P>If the mutex is <B>PTHREAD_MUTEX_ROBUST</B> and the owning thread
+terminates without unlocking the mutex the implementation will wake
+one waiting thread, if any. The next thread to acquire the mutex will
+receive the error code <B>EOWNERDEAD</B><SPAN STYLE="font-weight: normal">,
+in which case that thread should if possible ensure that the state
+protected by the mutex is consistent and then call
+</SPAN><B>pthread_mutex_consistent</B> <SPAN STYLE="font-weight: normal">before
+unlocking. The mutex may then be used normally from then on.</SPAN></P>
+<P><SPAN STYLE="font-weight: normal">If the thread cannot recover the
+state then it must call </SPAN><B>pthread_mutex_unlock</B><SPAN STYLE="font-weight: normal">
+without calling </SPAN><B>pthread_mutex_consistent</B><SPAN STYLE="font-weight: normal">.
+This will mark the mutex as unusable and wake all currently waiting
+threads with the return code </SPAN><B>ENOTRECOVERABLE</B><SPAN STYLE="font-weight: normal">.
+The error indicates that the mutex is no longer usable and any
+threads that receive this error code from any lock operation have not
+acquired the mutex. The mutex can be made consistent by calling
+</SPAN><B>pthread_mutex_destroy</B> <SPAN STYLE="font-weight: normal">to
+uninitialize the mutex, and calling </SPAN><B>pthread_mutex_int</B>
+<SPAN STYLE="font-weight: normal">to reinitialize the mutex. However,
+the state that was protected by the mutex remains inconsistent and
+some form of application recovery is required.</SPAN></P>
+<P><SPAN STYLE="font-weight: normal">If a thread that receives the
+</SPAN><B>EOWNERDEAD</B> <SPAN STYLE="font-weight: normal">error code
+itself terminates without unlocking the mutex then this behaviour
+repeats for the next acquiring thread.</SPAN></P>
+<P><SPAN STYLE="font-weight: normal">Applications must ensure that
+they check the return values from all calls targeting robust mutexes.</SPAN></P>
+<P STYLE="font-weight: normal">Robust mutexes are slower because they
+require some additional overhead, however they are not very much
+slower than the non-robust recursive type.</P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Cancellation</A></H2>
<P>None of the mutex functions is a cancellation point, not even
<B>pthread_mutex_lock</B>, in spite of the fact that it can suspend a
thread for arbitrary durations. This way, the status of mutexes at
@@ -138,46 +198,56 @@
thread stops executing. Consequently, threads using deferred
cancellation should never hold a mutex for extended periods of time.
</P>
-<H2><A HREF="#toc4" NAME="sect4">Async-signal Safety</A></H2>
+<H2 CLASS="western"><A HREF="#toc4" NAME="sect4">Async-signal Safety</A></H2>
<P>The mutex functions are not async-signal safe. What this means is
that they should not be called from a signal handler. In particular,
calling <B>pthread_mutex_lock</B> or <B>pthread_mutex_unlock</B> from
a signal handler may deadlock the calling thread.
</P>
-<H2><A HREF="#toc5" NAME="sect5">Return Value</A></H2>
+<H2 CLASS="western"><A HREF="#toc5" NAME="sect5">Return Value</A></H2>
<P><B>pthread_mutex_init</B> always returns 0. The other mutex
functions return 0 on success and a non-zero error code on error.
</P>
-<H2><A HREF="#toc6" NAME="sect6">Errors</A></H2>
+<H2 CLASS="western"><A HREF="#toc6" NAME="sect6">Errors</A></H2>
<P>The <B>pthread_mutex_lock</B> function returns the following error
code on error:
</P>
<DL>
<DL>
- <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ <DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in"><B>EINVAL</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex has not been properly initialized.
- </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
- <B>EDEADLK</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>EDEADLK</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex is already locked by the calling thread (‘‘error
checking’’ mutexes only).
- </DD></DL>
-</DL>
-<P>
-The <B>pthread_mutex_trylock</B> function returns the following error
-codes on error:
-</P>
-<DL>
- <DL>
- <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EBUSY</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>EOWNERDEAD</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ the robust mutex is now locked by the calling thread after the
+ previous owner terminated without unlocking it.</DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>ENOTRECOVERABLE</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ the robust mutex is not locked and is no longer usable after the
+ previous owner unlocked it without calling
+ pthread_mutex_consistent.</DD></DL>
+ <DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ The <B>pthread_mutex_trylock</B> function returns the following
+ error codes on error:
+ </DD><DL>
+ <DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>EBUSY</B>
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex could not be acquired because it was currently locked.
- </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
<B>EINVAL</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex has not been properly initialized.
- </DD></DL>
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>EOWNERDEAD</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ the robust mutex is now locked by the calling thread after the
+ previous owner terminated without unlocking it.</DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>ENOTRECOVERABLE</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ the robust mutex is not locked and is no longer usable after the
+ previous owner unlocked it without calling
+ pthread_mutex_consistent.</DD></DL>
</DL>
<P>
The <B>pthread_mutex_timedlock</B> function returns the following
@@ -185,15 +255,22 @@
</P>
<DL>
<DL>
- <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ETIMEDOUT</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ <DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in"><B>ETIMEDOUT</B>
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex could not be acquired before the <I>abs_timeout</I> time
arrived.
- </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
<B>EINVAL</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex has not been properly initialized.
- </DD></DL>
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>EOWNERDEAD</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ the robust mutex is now locked by the calling thread after the
+ previous owner terminated without unlocking it.</DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ <B>ENOTRECOVERABLE</B></DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
+ the robust mutex is not locked and is no longer usable after the
+ previous owner unlocked it without calling
+ pthread_mutex_consistent.</DD></DL>
</DL>
<P>
The <B>pthread_mutex_unlock</B> function returns the following error
@@ -201,12 +278,12 @@
</P>
<DL>
<DL>
- <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ <DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in"><B>EINVAL</B>
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex has not been properly initialized.
- </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DD><DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
<B>EPERM</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the calling thread does not own the mutex (‘‘error checking’’
mutexes only).
</DD></DL>
@@ -217,61 +294,63 @@
</P>
<DL>
<DL>
- <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EBUSY</B>
- </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ <DT STYLE="margin-right: 0.39in; margin-bottom: 0.2in"><B>EBUSY</B>
+ </DT><DD STYLE="margin-right: 0.39in; margin-bottom: 0.2in">
the mutex is currently locked.
</DD></DL>
</DL>
-<H2>
+<H2 CLASS="western">
<A HREF="#toc7" NAME="sect7">Author</A></H2>
<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
</P>
<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
-<H2><A HREF="#toc8" NAME="sect8">See Also</A></H2>
+<H2 CLASS="western"><A HREF="#toc8" NAME="sect8">See Also</A></H2>
<P><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B>(3)</A>
, <A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B>(3)</A>
, <A HREF="pthread_cancel.html"><B>pthread_cancel</B>(3)</A> .
</P>
-<H2><A HREF="#toc9" NAME="sect9">Example</A></H2>
+<H2 CLASS="western"><A HREF="#toc9" NAME="sect9">Example</A></H2>
<P>A shared global variable <I>x</I> can be protected by a mutex as
follows:
</P>
-<PRE STYLE="margin-left: 1cm; margin-right: 1cm">int x;
-pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;</PRE><BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">
+<PRE CLASS="western" STYLE="margin-left: 0.39in; margin-right: 0.39in">int x;
+pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;</PRE><BLOCKQUOTE STYLE="margin-left: 0in; margin-right: 0in">
All accesses and modifications to <I>x</I> should be bracketed by
calls to <B>pthread_mutex_lock</B> and <B>pthread_mutex_unlock</B> as
follows:
</BLOCKQUOTE>
-<PRE STYLE="margin-left: 1.03cm; margin-right: 2cm">pthread_mutex_lock(&amp;mut);
+<PRE CLASS="western" STYLE="margin-left: 0.41in; margin-right: 0.79in">pthread_mutex_lock(&amp;mut);
/* operate on x */
pthread_mutex_unlock(&amp;mut);</PRE>
<HR>
-<BLOCKQUOTE STYLE="margin-right: 4cm"><A NAME="toc"></A><B>Table of
-Contents</B></BLOCKQUOTE>
+<BLOCKQUOTE STYLE="margin-right: 2.75in"><A NAME="toc"></A><B>Table
+of Contents</B></BLOCKQUOTE>
<UL>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect0" NAME="toc0">Name</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect1" NAME="toc1">Synopsis</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect2" NAME="toc2">Description</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect10" NAME="toc10">Robust
+ Mutexes</A></BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect3" NAME="toc3">Cancellation</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Async-signal
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect4" NAME="toc4">Async-signal
Safety</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Return
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect5" NAME="toc5">Return
Value</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Errors</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect6" NAME="toc6">Errors</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Author</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect7" NAME="toc7">Author</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">See
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in; margin-bottom: 0in"><A HREF="#sect8" NAME="toc8">See
Also</A>
</BLOCKQUOTE>
- <LI><BLOCKQUOTE STYLE="margin-right: 4cm"><A HREF="#sect9" NAME="toc9">Example</A>
+ <LI><BLOCKQUOTE STYLE="margin-right: 2.75in"><A HREF="#sect9" NAME="toc9">Example</A>
</BLOCKQUOTE>
</UL>
</BODY>
-</HTML>
+</HTML>
View
172 manual/pthread_mutexattr_init.html
@@ -3,22 +3,32 @@
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<TITLE>PTHREAD_MUTEXATTR(3) manual page</TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Linux)">
<META NAME="CREATED" CONTENT="20050504;23040500">
- <META NAME="CHANGED" CONTENT="20050505;18370400">
+ <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
+ <META NAME="CHANGED" CONTENT="20110326;13190500">
<!-- manual page source format generated by PolyglotMan v3.2, -->
<!-- available at http://polyglotman.sourceforge.net/ -->
+ <STYLE TYPE="text/css">
+ <!--
+ H4.cjk { font-family: "AR PL UMing CN" }
+ H4.ctl { font-family: "Lohit Devanagari" }
+ H2.cjk { font-family: "AR PL UMing CN" }
+ H2.ctl { font-family: "Lohit Devanagari" }
+ -->
+ </STYLE>
</HEAD>
<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
-<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<H4 CLASS="western">POSIX Threads for Windows – REFERENCE -
+<A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
<P><A HREF="index.html">Reference Index</A></P>
<P><A HREF="#toc">Table of Contents</A></P>
-<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<H2 CLASS="western"><A HREF="#toc0" NAME="sect0">Name</A></H2>
<P>pthread_mutexattr_init, pthread_mutexattr_destroy,
pthread_mutexattr_settype, pthread_mutexattr_gettype - mutex creation
attributes
</P>
-<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<H2 CLASS="western"><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
<P><B>#include &lt;pthread.h&gt;</B>
</P>
<P><B>int pthread_mutexattr_init(pthread_mutexattr_t *</B><I>attr</I><B>);</B>
@@ -37,7 +47,13 @@
<P><B>int pthread_mutexattr_getkind_np(const pthread_mutexattr_t
*</B><I>attr</I><B>, int *</B><I>type</I><B>);</B>
</P>
-<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P><B>int pthread_mutexattr_setrobust(pthread_mutexattr_t *</B><I>attr</I><B>,
+int</B><SPAN STYLE="font-weight: normal"> </SPAN><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><B>);</B>
+</P>
+<P><B>int pthread_mutexattr_getrobust(pthread_mutexattr_t *</B><I>attr</I><B>,
+int</B><SPAN STYLE="font-weight: normal"> </SPAN><B>*</B><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><B>);</B>
+</P>
+<H2 CLASS="western"><A HREF="#toc2" NAME="sect2">Description</A></H2>
<P>Mutex attributes can be specified at mutex creation time, by
passing a mutex attribute object as second argument to
<A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B>(3)</A> .
@@ -50,12 +66,27 @@
</P>
<P><B>pthread_mutexattr_destroy</B> destroys a mutex attribute
object, which must not be reused until it is reinitialized.</P>
+<P><B>pthread_mutexattr_settype</B> sets the mutex type attribute in
+<I>attr</I> to the value specified by <I>type</I>.
+</P>
+<P><B>pthread_mutexattr_gettype</B> retrieves the current value of
+the mutex kind attribute in <I>attr</I> and stores it in the location
+pointed to by <I>type</I>.
+</P>
+<P><B>Pthreads-w32</B> also recognises the following equivalent
+functions that are used in Linux:</P>
+<P><B>pthread_mutexattr_setkind_np</B> is an alias for
+<B>pthread_mutexattr_settype</B>.
+</P>
+<P STYLE="font-weight: normal"><B>pthread_mutexattr_getkind_np</B> is
+an alias for <B>pthread_mutexattr_gettype</B>.
+</P>
<P>The following mutex types are supported:</P>
-<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_NORMAL</B> - for
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_NORMAL</B> - for
‘‘fast’’ mutexes.</P>
-<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_RECURSIVE</B> - for
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_RECURSIVE</B> - for
‘‘recursive’’ mutexes.</P>
-<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_ERRORCHECK</B> - for
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_ERRORCHECK</B> - for
‘‘error checking’’ mutexes.</P>
<P>The mutex type determines what happens if a thread attempts to
lock a mutex it already owns with <A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A>
@@ -75,83 +106,102 @@
<P>The default mutex type is <B>PTHREAD_MUTEX_NORMAL</B></P>
<P><B>Pthreads-w32</B> also recognises the following equivalent types
that are used by Linux:</P>
-<P STYLE="margin-left: 2cm; font-weight: medium"><B>PTHREAD_MUTEX_FAST_NP</B>
+<P STYLE="margin-left: 0.79in; font-weight: normal"><B>PTHREAD_MUTEX_FAST_NP</B>
– equivalent to <B>PTHREAD_MUTEX_NORMAL</B></P>
-<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_RECURSIVE_NP</B></P>
-<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_ERRORCHECK_NP</B></P>
-<P><B>pthread_mutexattr_settype</B> sets the mutex type attribute in
-<I>attr</I> to the value specified by <I>type</I>.
-</P>
-<P><B>pthread_mutexattr_gettype</B> retrieves the current value of
-the mutex kind attribute in <I>attr</I> and stores it in the location
-pointed to by <I>type</I>.
-</P>
-<P><B>Pthreads-w32</B> also recognises the following equivalent
-functions that are used in Linux:</P>
-<P><B>pthread_mutexattr_setkind_np</B> is an alias for
-<B>pthread_mutexattr_settype</B>.
-</P>
-<P STYLE="font-weight: medium"><B>pthread_mutexattr_getkind_np</B> is
-an alias for <B>pthread_mutexattr_gettype</B>.
-</P>
-<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
-<P><B>pthread_mutexattr_init</B>, <B>pthread_mutexattr_destroy</B>
-and <B>pthread_mutexattr_gettype</B> always return 0.
-</P>
-<P><B>pthread_mutexattr_settype</B> returns 0 on success and a
-non-zero error code on error.
-</P>
-<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
-<P>On error, <B>pthread_mutexattr_settype</B> returns the following
-error code:
-</P>
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_RECURSIVE_NP</B></P>
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_ERRORCHECK_NP</B></P>
+<P><B>pthread_mutexattr_setrobust</B><SPAN STYLE="font-weight: normal">
+sets the robustness attribute to the value given by </SPAN><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><SPAN STYLE="font-weight: normal">.</SPAN></P>
+<P><B>pthread_mutexattr_getrobust</B><SPAN STYLE="font-weight: normal">
+returns the current robustness value to the location given by
+*</SPAN><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><SPAN STYLE="font-weight: normal">.</SPAN></P>
+<P><SPAN STYLE="font-weight: normal">The possible values for </SPAN><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><SPAN STYLE="font-weight: normal">
+are:</SPAN></P>
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_STALLED</B><SPAN STYLE="font-weight: normal">
+- when the owner of the mutex terminates without unlocking the mutex,
+all subsequent calls
+ to pthread_mutex_*lock() are blocked from
+progress in an unspecified manner.</SPAN></P>
+<P STYLE="margin-left: 0.79in"><B>PTHREAD_MUTEX_ROBUST</B><SPAN STYLE="font-weight: normal">
+- when the owner of the mutex terminates without unlocking the mutex,
+the mutex is
+ unlocked. The next owner of this mutex acquires the
+mutex with an error return of
+EOWNERDEAD.</SPAN></P>
+<H2 CLASS="western"><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
+<P><SPAN STYLE="font-weight: normal">On success all functions return
+0, otherwise they return an error code as follows:</SPAN></P>
+<P><B>pthread_mutexattr_init</B></P>
+<P STYLE="margin-left: 0.79in"><B>ENOMEM</B><SPAN STYLE="font-weight: normal">
+- insufficient memory for </SPAN><I><SPAN STYLE="font-weight: normal">attr</SPAN></I><SPAN STYLE="font-weight: normal">.</SPAN></P>
+<P><B>pthread_mutexattr_destroy</B></P>
+<P STYLE="margin-left: 0.79in"><B>EINVAL</B><SPAN STYLE="font-weight: normal">
+- </SPAN><I><SPAN STYLE="font-weight: normal">attr</SPAN></I><SPAN STYLE="font-weight: normal">
+is invalid.</SPAN></P>
+<P><B>pthread_mutexattr_gettype</B></P>
+<P STYLE="margin-left: 0.79in"><B>EINVAL</B><SPAN STYLE="font-weight: normal">
- </SPAN><I><SPAN STYLE="font-weight: normal">attr</SPAN></I><SPAN STYLE="font-weight: normal">
- <DT><B>EINVAL</B>
- </DT><DD STYLE="margin-bottom: 0.5cm">
- <I>type</I> is none of:<BR><B>PTHREAD_MUTEX_NORMAL</B>,
- <B>PTHREAD_MUTEX_FAST_NP</B>,<BR><B>PTHREAD_MUTEX_RECURSIVE</B>,
- <B>PTHREAD_MUTEX_RECURSIVE_NP,<BR>PTHREAD_MUTEX_ERRORCHECK</B>,
- <B>PTHREAD_MUTEX_ERRORCHECK_NP</B>
+is invalid.</SPAN></P>
+<P><B>pthread_mutexattr_settype</B></P>
+<DL>
+ <DL>
+ <DL>
+ <DT><B>EINVAL</B><SPAN STYLE="font-weight: normal"> - </SPAN><I><SPAN STYLE="font-weight: normal">attr</SPAN></I><SPAN STYLE="font-weight: normal">
+ is invalid or </SPAN><I><SPAN STYLE="font-weight: normal">type</SPAN></I><SPAN STYLE="font-weight: normal">
+ is none of:</SPAN></DT><DL>
+ <DL>
+ <DT>
+ <B>PTHREAD_MUTEX_NORMAL<BR>PTHREAD_MUTEX_FAST_NP<BR>PTHREAD_MUTEX_RECURSIVE<BR>PTHREAD_MUTEX_RECURSIVE_NP<BR>PTHREAD_MUTEX_ERRORCHECK<BR>PTHREAD_MUTEX_ERRORCHECK_NP</B></DT></DL>
+ </DL>
+ </DL>
</DL>
-<H2>
-<A HREF="#toc5" NAME="sect5">Author</A></H2>
+ <DD STYLE="margin-left: 0in">
+ <BR>
+ </DD></DL>
+<P>
+<B>pthread_mutexattr_getrobust</B></P>
+<P STYLE="margin-left: 0.79in"><B>EINVAL</B><SPAN STYLE="font-weight: normal">
+– </SPAN><I><SPAN STYLE="font-weight: normal">attr</SPAN></I><SPAN STYLE="font-weight: normal">
+or </SPAN><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><SPAN STYLE="font-weight: normal">
+is invalid.</SPAN></P>
+<P><B>pthread_mutexattr_setrobust</B></P>
+<P STYLE="margin-left: 0.79in"><B>EINVAL</B><SPAN STYLE="font-weight: normal">
+– </SPAN><I><SPAN STYLE="font-weight: normal">attr</SPAN></I><SPAN STYLE="font-weight: normal">
or </SPAN><I><SPAN STYLE="font-weight: normal">robust</SPAN></I><SPAN STYLE="font-weight: normal">
is invalid.</SPAN></P>
<H2 CLASS="western"><A HREF="#toc5" NAME="sect5">Author</A></H2>
-<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2>
+<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
</P>
<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
<H2 CLASS="western"><A HREF="#toc6" NAME="sect6">See Also</A></H2>
<P><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B>(3)</A>
, <A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A>
-<H2><A HREF="#toc7" NAME="sect7"><U><FONT COLOR="#000080">Notes</FONT></U></A></H2>
+, <A HREF="pthread_mutex_unlock.html"><B>pthread_mutex_unlock</B>(3)</A>
.
-of mutexes of type <B>PTHREAD_MUTEX_NORMAL</B> (or
+</P>
<H2 CLASS="western"><A HREF="#toc7" NAME="sect7"><FONT COLOR="#000080"><U>Notes</U></FONT></A></H2>
<P>For speed, <B>Pthreads-w32</B> never checks the thread ownership
of non-robust mutexes of type <B>PTHREAD_MUTEX_NORMAL</B> (or
-<P><SPAN STYLE="font-weight: medium">When developing code, it is a
-common precaution to substitute the error checking type, and drop in
-the normal type for release if the extra performance is required.</SPAN></P>
+<B>PTHREAD_MUTEX_FAST_NP</B>) when performing operations on the
+mutex. It is therefore possible for one thread to lock such a mutex
+and another to unlock it.</P>
<P STYLE="font-weight: normal">When developing code, it is a common
precaution to substitute the error checking type, then drop in the
normal type for release if the extra performance is required.</P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+<HR>
<P><A NAME="toc"></A><B>Table of Contents</B></P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+<UL>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#sect0" NAME="toc0">Name</A>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ </P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#sect1" NAME="toc1">Synopsis</A>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
+ </P>
<LI><P STYLE="margin-bottom: 0in"><A HREF="#sect2" NAME="toc2">Description</A>
</P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
- </P>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A>
+ <LI><P STYLE="margin-bottom: 0in"><A HREF="#sect3" NAME="toc3">Return
Value</A>
- <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See