![]() |
|
||||
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.4aIn 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.
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:
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
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.4aIn 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.
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:
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 |
![]() |
![]() |
![]() |
![]() |