Open System Services Programmer's Guide
/********************************************************/
/* Set the concurrency level for the thread scheduler */
/********************************************************/
pthread_setconcurrency(CONCURRENCY_LEVEL);
/**********************************/
/* Create all of the I/O threads */
/**********************************/
for (i = 1; i < argc; i = i + 2)
{
if (strcmp(argv[i], "-r") == 0)
{
pthread_create(&thread_handle[nmbr_created_threads++],
NULL, &OSS_read_thread, OSS_read_filename);
}
else if (strcmp(argv[i], "-w") == 0)
{
pthread_create(&thread_handle[nmbr_created_threads++],
NULL, &OSS_write_thread, OSS_write_filename);
}
else if (strcmp(argv[i], "-R") == 0)
{
pthread_create(&thread_handle[nmbr_created_threads++],
NULL, &Grd_READ_thread, Grd_READ_filename);
}
else if (strcmp(argv[i], "-W") == 0)
{
pthread_create(&thread_handle[nmbr_created_threads++],
NULL, &Grd_WRITE_thread, Grd_WRITE_filename);
}
}
printf("\n==> All threads created...\n");
/************************************************************************/
/* wait for the threads to complete - this is where control is passed */
/* to the threads */
/************************************************************************/
for (i = 0; i < nmbr_created_threads; ++i)
{
pthread_join(thread_handle[i], NULL);
}
} /* main() */
Example 73 (page 360) is a multithreaded program similar to Example 72 (page 350) except that
performs I/O on multiple OSS regular files using the thread-aware functions that are available
when you use the define SPT_THREAD_AWARE_XNONBLOCK (available on systems running J06.04
and later J-series RVUs and H06.15 and later H-series RVUs). With these functions, you do not
have to use Guardian functions to allow other threads to continue to work while another thread
waits for I/O to complete on an open file.
Thread-Aware and Nonblocking OSS Functions 359