TOC PREV NEXT INDEX

POSIX 1.c Migration Guide


Thread Management

Thread Creation Attributes

POSIX.1c changes to thread creation attributes are relatively minor. The following table is a comparison of the revised interfaces and their corresponding
POSIX.4a versions:

Thread Creation Attribute Function Changes  
POSIX.1c
POSIX.4a
int
pthread_attr_init(
pthread_attr_t *attr)
int
pthread_attr_create(
pthread_attr_t *attr)
int
pthread_attr_destroy(
pthread_attr_t *attr)
int
pthread_attr_delete(
pthread_attr_t *attr)
int
pthread_attr_setstacksize(
pthread_attr_t *attr,
size_t stacksize)
int
pthread_attr_setstacksize(
pthread_attr_t *attr,
long stacksize)
int
pthread_attr_getstacksize
(pthread_attr_t *attr,size_t
*stacksize)
unsigned long
pthread_attr_getstacksize
(pthread_attr_t *attr)
int
pthread_attr_setdetachstate
(pthread_attr_t *attr,int
detachstate)
No equivalent
int
pthread_attr_getdetachstate
(pthread_attr_t *attr,int
*detachstate)
No equivalent

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

POSIX.4a does not provide a facility to create a thread in anything other than a joinable state, requiring a thread to be explicitly detached via pthread_detach(). POSIX.1c allows a thread to be created in a detached state by using pthread_attr_setdetachstate() to set the detachstate attribute to PTHREAD_CREATE_DETACHED (the default is PTHREAD_CREATE_JOINABLE).

Thread Management Functions

POSIX.1c changes to thread management are also relatively minor. The following table is a comparison of the revised interfaces and their corresponding
POSIX.4a versions:

Thread Management Function Changes  
POSIX.1c
POSIX.4a
int
pthread_create
(pthread_t *thread,pthread_attr_t
*attr,void *(*start_routine)
void *), void *arg)
int
pthread_create
(pthread_t *thread, pthread_attr_t
attr, void *(*start_routine)
(void *), void *arg)
int
pthread_detach(
pthread_t thread)
int
pthread_detach
(pthread_t *thread)

Thread Fork Handlers

POSIX.1c defines the pthead_atfork() function to register handler functions to be called before and after fork(), in the context of the thread that called fork(). POSIX.4a has no such facility.

Dynamic Package Initialization

In POSIX.4a the constant pthread_once_init (all lowercase letters) is defined as the initializer for a once control object used with pthread_once(),
as follows:

pthread_once_t once_block = pthread_once_init;

POSIX.1c defines the constant PTHREAD_ONCE_INIT (all uppercase letters) for this purpose:

pthread_once_t once_control = PTHREAD_ONCE_INIT;



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