Open System Services Programmer's Guide

/********************/
/* LITERALS/DEFINES */
/********************/
/* the maximum number of I/O threads created by this program */
#define MAX_THREADS 4
/* concurreny level value passed to pthread_setconcurrency() */
/* the value of 100000 sets the minimum scheduled quantum to */
/* 0.000001 seconds. */
#define CONCURRENCY_LEVEL 100000
/* I/O size used by all threads */
#define IOSIZE 8192
/* size of files that are written - 1Mb */
#define WRITE_FILESIZE 1048576
/*
*-----------------------------------------------------------------
* OSS_read_thread --
*
* Description:
*
* This thread reads an OSS file using OSS I/O.
*
* Note that OSS I/O on regular files is serialized and only one OSS I/O
* per open can occur at a given time. Even though we use the
* thread-aware library, the entire
* program blocks while the OSS read() function performs the I/O.
*
* Results:
* none.
*
*------------------------------------------------------------------
*/
void *OSS_read_thread(void *OSS_read_file)
{
int fd;
int nbytes;
char *iobuf;
int ret;
long long filesize = 0;
/*****************************************************************/
/* prepare I/O buffer (page aligned, paged into physical memory) */
/*****************************************************************/
if ((iobuf = malloc(IOSIZE)) == NULL)
{
printf("*** ERROR in OSS_read_thread: unable to allocate
I/O buffer ***\n");
exit(0);
}
memset(iobuf, 0, IOSIZE);
/*********************/
/* open the OSS file */
/*********************/
if ((fd = open(OSS_read_file, O_RDONLY | O_NONBLOCK)) < 0)
{
printf("*** ERROR in OSS_read_thread: open() of %s failed
w/error %d ***\n", OSS_read_file, errno);
exit(0);
}
Thread-Aware and Nonblocking OSS Functions 351