TOC PREV NEXT INDEX

POSIX 1.c Migration Guide


Synchronization Primitives

Mutex Initialization Attributes

POSIX.4a defines no mutex attributes, whereas POSIX.1c defines process-shared and priority-scheduling attributes. The following table contains a comparison of the interfaces:

Mutex Initialization Attributes Interface Changes  
POSIX.1c
POSIX.4a
int
pthread_mutexattr_init
(pthread_mutexattr_t *attr)
int
pthread_mutexattr_create
(pthread_mutexattr_t *attr)
int
pthread_mutexattr_destroy
(pthread_mutexattr_t *attr)
int
pthread_mutexattr_delete
(pthread_mutexattr_t *attr)
int
pthread_mutexattr_setpshared
(pthread_mutexattr_t *attr,
int pshared)
No equivalent
int
pthread_mutexattr_getpshared
(const pthread_mutexattr_t *attr,
int *pshared)
No equivalent
int
pthread_mutexattr_setprotocol
(pthread_mutex_attr *attr,
int protocol)
No equivalent
int
pthread_mutexattr_getprotocol
(const pthread_mutex_attr *attr,
int *protocol)
No equivalent
int
pthread_mutexattr_setprioceiling
(pthread_mutexattr_t *attr,int
prioceiling)
No equivalent
int
pthread_mutexattr_getprioceiling
(pthread_mutexattr_t *attr,int
*prioceiling)
No equivalent

In LynxOS, the POSIX.1c function pthread_mutexattr_destroy() sets the attribute object to an invalid value to prevent its subsequent use
without reinitialization.

POSIX.1c defines the values PTHREAD_PROCESS_SHARED and PTHREAD_PROCESS_PRIVATE for the process-shared attribute.

Note: In LynxOS, the process-shared attribute can be set to either value but has no effect when the mutex is created, because the actual interprocess shareability of a mutex is determined by whether it is allocated in shared or process-private memory.

POSIX.1c defines the PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, and PTHREAD_PRIO_PROTECT values for the protocol attribute. LynxOS supports all these values to provide normal, priority inheritance, and priority ceiling mutexes.

Mutex Initialization

POSIX.4a allows only dynamic mutex initialization. POSIX.1c supports static mutex initialization to default values using the PTHREAD_MUTEX_INITIALIZER macro, as follows:

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

This feature is useful in simplifying the initialization of libraries or other utility function packages that use mutexes by avoiding the need to use pthread_once() to ensure once-only initialization execution.

In POSIX.4a, the value pthread_mutexattr_default is used to dynamically initialize a mutex with default attributes. POSIX.1c specifies the use of NULL for this purpose.

Mutex Priority Ceiling Control

POSIX.1c provides interfaces for dynamically changing the priority ceiling of a mutex. Because POSIX.4a does not support mutex attributes, it has no corresponding interfaces, as shown in the following table:

Mutex Priority Ceiling Control Interface Changes  
POSIX.1c
POSIX.4a
int
pthread_mutex_setprioceiling
(pthread_mutex_t *mutex,int
prioceiling,int *old_ceiling)
No equivalent
int
pthread_mutex_getprioceiling
(pthread_mutex_t *mutex,int
*prioceiling)
No equivalent

Condition Variable Initialization Attributes

POSIX.4a defines no condition variable attributes, whereas POSIX.1c defines process-shared attributes. The following table compares the
corresponding interfaces:

Condition Variable Initialization Attributes Interface Changes  
POSIX.1c
POSIX.4a
int
pthread_condattr_init
(pthread_condattr_t *attr)
int
pthread_condattr_create
(pthread_condattr_t *attr)
int
pthread_condattr_destroy
(pthread_condattr_t *attr)
int
pthread_condattr_delete
(pthread_condattr_t *attr)
int
pthread_condattr_setpshared
(pthread_condattr_t *attr,
int pshared)
No equivalent
int
pthread_condattr_getpshared
(const pthread_condattr_t *attr,
int *pshared)
No equivalent

In LynxOS, the POSIX.1c function pthread_condattr_destroy() sets the attribute object to an invalid value to prevent its subsequent use
without reinitialization.

POSIX.1c defines the values PTHREAD_PROCESS_SHARED and PTHREAD_PROCESS_PRIVATE for the process-shared attribute.

Note: In LynxOS, the process-shared attribute can be set to either value but has no effect when the condition variable is created, because the actual interprocess shareability of a condition variable is determined by whether it is allocated in shared or process-private memory.

Condition Variable Initialization

POSIX.4a allows only dynamic condition variable initialization. POSIX.1c supports static condition variable initialization to default values using the PTHREAD_COND_INITIALIZER macro, as follows:

pthread_cond_t condvar = PTHREAD_COND_INITIALIZER;

This feature is useful in simplifying the initialization of libraries or other utility function packages that use condition variables by avoiding the need to use pthread_once() to ensure once-only initialization execution.

In POSIX.4a, the value pthread_condattr_default is used to dynamically initialize a condition variable with default attributes. POSIX.1c specifies the use of NULL for this purpose.



LynuxWorks, Inc.
855 Branham Lane East
San Jose, CA 95138
http://www.lynuxworks.com
1.800.255.5969
TOC PREV NEXT INDEX