Open System Services Programmer's Guide
else if (strcmp(argv[i], "-w") == 0)
{
pthread_create(&thread_handle[nmbr_created_threads++],
NULL, &OSS_write_thread, OSS_write_filename);
}
}
printf("\n==> All threads created...\n");
/*****************************************************************/
/* wait for the threads to complete - this is where control is */
/* passes to the threads */
/*****************************************************************/
for (i = 0; i < nmbr_created_threads; ++i)
{
pthread_join(thread_handle[i], NULL);
}
} /* main() */
Reentrant OSS Functions
For systems running J-series RVUs, H06.05 and later H-series RVUs, and G06.28 and later G-series
RVUs, several new reentrant functions are provided (Table 63 (page 376)). Many existing functions
are also reentrant. To determine if a function is reentrant, see the reference page for that function
either online or in the Open System Services System Calls Reference Manual.
Many functions are unsafe in multithreaded applications, often because these functions return a
pointer to a string or structure that is in static storage. A second call to the function overwrites the
static storage (the results from the first call). Other issues for multithreaded applications include the
use of global variables and maintaining context across calls.
In programs that use multiple threads, the same functions and the same resources might be accessed
concurrently by several flows of control. To protect resource integrity, code written for multithreaded
programs must be reentrant and thread safe.
A reentrant function does not hold static data over successive calls and does not return a pointer
to static data. All data is provided by the caller of the function. Incoming signals are blocked until
the reentrant function completes.
To determine which RVUs support an OSS function, see Appendix A (page 438).
NOTE: On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs,
reentrant functions are also provided in the library that provides the base function. Therefore, to
use the Standard POSIX Threads version of the reentrant function, when you link your application
using eld, you must specify the Standard POSIX Threads library (ZSPTDLL) before you specify
public libraries such as ZSECDLL.
Reentrant OSS Functions 365