Base WG Resolution Ref: bwg96-09
Topic: mutex initialization

This is an approved Base Working Group Resolution for XSH Issue 5.

Last update: 23 February,1998

								Eastwood #9


	Topic:			mutex initialization
	Relevant Sections:	n/a
	Spec:			XSH Issue 5

Resolution Request:

ISO 9945-1:1996, page 255, lines 513 .. 515 states:

In cases where default mutex attributes are appropriate, the
macro PTHREAD_MUTEX_INITIALIZER can be used to initialize mutexes
that are STATICALLY allocated. (my emphasis)

Was it the intention of the standards committee to preclude
portablility of constructs such as:

	pthread_mutex_t	m;
	pthread_mutex_t	*pm;

	pm = (pthread_mutex_t *) malloc( ... );	/* case 2 */
	if (pm != NULL)

The same question is also asked for PTHREAD_COND_INITIALIZER discussed
on page 261.

Resolution Response
We believe that the "intention of the standards committee" was not so much
to preclude the [portable] use of the initializers in assigment statements,
as to allow portable use in initialization statements for various
implementations of the mutex type.  E.g.,

        pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;

The initializers may be array or structure initializers, depending on the
implementation of pthread_mutex_t; and may contain braces and commas which,
in general, would not work in assignment statements.  There may be
implementations for which the value of the initializers could be used for
the right hand operand of an assignment, but the standard does not require

Forwarded to Base group: Dec 11 1996
Approved: Feb 1998