pthread_once(PTHREAD)
pthread_once --
dynamic package initialization
Synopsis
cc [options] -Kthread file
#include <pthread.h>
int pthread_once(pthread_once_t *once_control,
void (*init_routine) (void));
pthread_once_t once_control = PTHREAD_ONCE_INIT;
Description
pthread_once performs dynamic library
initialization in a multithreaded process, thus aiding
in the reliable construction of multithreaded and
realtime systems.
The first call to pthread_once by any thread in
a process, with a given once_control,
will call init_routine with no arguments.
Subsequent calls of pthread_once
with the same once_control will not call
init_routine.
On return from pthread_once,
it is guaranteed that init_routine
has completed.
The once_control parameter is used to
determine whether the associated initialization
routine has been called.
The function pthread_once is not a cancellation point.
However, if init_routine is a cancellation point
and the calling thread is canceled in init_routine,
the effect on once_control is as if
pthread_once was never called.
The macro PTHREAD_ONCE_INIT is defined in the
header <pthread.h>.
The behavior of pthread_once is undefined if
once_control is not initialized by
PTHREAD_ONCE_INIT.
The once_control parameter is a pointer to a value
that indicates whether init_routine has been called.
init_routine is a pointer to a library-exported
initialization routine.
Return values
pthread_once returns zero on success.
Otherwise, an error number is returned and no signal is sent.
Diagnostics
pthread_once returns the following value if the
corresponding condition is detected:
EINVAL-
once_control is not a valid argument.
Standards Compliance
The Single UNIX Specification, Version 2; The Open Group.
References
Intro(PTHREAD),
pthread(F)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005