From 4f623056c916678dd77844e22e4c9012c7ff09f7 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 26 Mar 2011 04:18:48 +0000 Subject: Add new sections --- manual/pthread_mutexattr_init.html | 172 ++++++++++++++++++++++++------------- 1 file changed, 111 insertions(+), 61 deletions(-) (limited to 'manual/pthread_mutexattr_init.html') diff --git a/manual/pthread_mutexattr_init.html b/manual/pthread_mutexattr_init.html index f3df993..f69599b 100644 --- a/manual/pthread_mutexattr_init.html +++ b/manual/pthread_mutexattr_init.html @@ -3,22 +3,32 @@ PTHREAD_MUTEXATTR(3) manual page - + - + + + -

POSIX Threads for Windows – REFERENCE - Pthreads-w32

+

POSIX Threads for Windows – REFERENCE - +Pthreads-w32

Reference Index

Table of Contents

-

Name

+

Name

pthread_mutexattr_init, pthread_mutexattr_destroy, pthread_mutexattr_settype, pthread_mutexattr_gettype - mutex creation attributes

-

Synopsis

+

Synopsis

#include <pthread.h>

int pthread_mutexattr_init(pthread_mutexattr_t *attr); @@ -37,7 +47,13 @@ int type);

int pthread_mutexattr_getkind_np(const pthread_mutexattr_t *attr, int *type);

-

Description

+

int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, +int robust); +

+

int pthread_mutexattr_getrobust(pthread_mutexattr_t *attr, +int *robust); +

+

Description

Mutex attributes can be specified at mutex creation time, by passing a mutex attribute object as second argument to pthread_mutex_init(3) . @@ -50,12 +66,27 @@ attributes.

pthread_mutexattr_destroy destroys a mutex attribute object, which must not be reused until it is reinitialized.

+

pthread_mutexattr_settype sets the mutex type attribute in +attr to the value specified by type. +

+

pthread_mutexattr_gettype retrieves the current value of +the mutex kind attribute in attr and stores it in the location +pointed to by type. +

+

Pthreads-w32 also recognises the following equivalent +functions that are used in Linux:

+

pthread_mutexattr_setkind_np is an alias for +pthread_mutexattr_settype. +

+

pthread_mutexattr_getkind_np is +an alias for pthread_mutexattr_gettype. +

The following mutex types are supported:

-

PTHREAD_MUTEX_NORMAL - for +

PTHREAD_MUTEX_NORMAL - for ‘‘fast’’ mutexes.

-

PTHREAD_MUTEX_RECURSIVE - for +

PTHREAD_MUTEX_RECURSIVE - for ‘‘recursive’’ mutexes.

-

PTHREAD_MUTEX_ERRORCHECK - for +

PTHREAD_MUTEX_ERRORCHECK - for ‘‘error checking’’ mutexes.

The mutex type determines what happens if a thread attempts to lock a mutex it already owns with pthread_mutex_lock(3) @@ -75,83 +106,102 @@ state.

The default mutex type is PTHREAD_MUTEX_NORMAL

Pthreads-w32 also recognises the following equivalent types that are used by Linux:

-

PTHREAD_MUTEX_FAST_NP +

PTHREAD_MUTEX_FAST_NP – equivalent to PTHREAD_MUTEX_NORMAL

-

PTHREAD_MUTEX_RECURSIVE_NP

-

PTHREAD_MUTEX_ERRORCHECK_NP

-

pthread_mutexattr_settype sets the mutex type attribute in -attr to the value specified by type. -

-

pthread_mutexattr_gettype retrieves the current value of -the mutex kind attribute in attr and stores it in the location -pointed to by type. -

-

Pthreads-w32 also recognises the following equivalent -functions that are used in Linux:

-

pthread_mutexattr_setkind_np is an alias for -pthread_mutexattr_settype. -

-

pthread_mutexattr_getkind_np is -an alias for pthread_mutexattr_gettype. -

-

Return Value

-

pthread_mutexattr_init, pthread_mutexattr_destroy -and pthread_mutexattr_gettype always return 0. -

-

pthread_mutexattr_settype returns 0 on success and a -non-zero error code on error. -

-

Errors

-

On error, pthread_mutexattr_settype returns the following -error code: -

+

PTHREAD_MUTEX_RECURSIVE_NP

+

PTHREAD_MUTEX_ERRORCHECK_NP

+

pthread_mutexattr_setrobust +sets the robustness attribute to the value given by robust.

+

pthread_mutexattr_getrobust +returns the current robustness value to the location given by +*robust.

+

The possible values for robust +are:

+

PTHREAD_MUTEX_STALLED +- 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.

+

PTHREAD_MUTEX_ROBUST +- 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.

+

Return Value

+

On success all functions return +0, otherwise they return an error code as follows:

+

pthread_mutexattr_init

+

ENOMEM +- insufficient memory for attr.

+

pthread_mutexattr_destroy

+

EINVAL +- attr +is invalid.

+

pthread_mutexattr_gettype

+

EINVAL +- attr +is invalid.

+

pthread_mutexattr_settype

-
EINVAL -
- type is none of:
PTHREAD_MUTEX_NORMAL, - PTHREAD_MUTEX_FAST_NP,
PTHREAD_MUTEX_RECURSIVE, - PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK
, - PTHREAD_MUTEX_ERRORCHECK_NP +
+
+
EINVAL - attr + is invalid or type + is none of:
+
+
+ PTHREAD_MUTEX_NORMAL
PTHREAD_MUTEX_FAST_NP
PTHREAD_MUTEX_RECURSIVE
PTHREAD_MUTEX_RECURSIVE_NP
PTHREAD_MUTEX_ERRORCHECK
PTHREAD_MUTEX_ERRORCHECK_NP
+
+
+
+
+
-

-Author

+

+pthread_mutexattr_getrobust

+

EINVAL +– attr +or robust +is invalid.

+

pthread_mutexattr_setrobust

+

EINVAL +– attr +or robust +is invalid.

+

Author

Xavier Leroy <Xavier.Leroy@inria.fr>

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

+

See Also

pthread_mutex_init(3) , pthread_mutex_lock(3) , pthread_mutex_unlock(3) .

-

Notes

+

Notes

For speed, Pthreads-w32 never checks the thread ownership -of mutexes of type PTHREAD_MUTEX_NORMAL (or +of non-robust mutexes of type PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_FAST_NP) when performing operations on the mutex. It is therefore possible for one thread to lock such a mutex and another to unlock it.

-

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.

+

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.


Table of Contents

- + \ No newline at end of file -- cgit v1.2.3