Open System Services Programmer's Guide

spte = spt_awaitio(fnum, tag, -1, &count_read, &error, NULL);
if (spte != SPT_SUCCESS)
{
(void) CANCELREQ(fnum, tag);
printf("*** ERROR in Grd_READ_thread: spt_awaitio() failed
w/error %d ***\n", (int) error);
exit(0);
}
else if (error == 1) /* EOF */
break;
filesize += count_read;
}
} /* while */
spt_unregFile(fnum);
FILE_CLOSE_(fnum);
printf("==> Grd_READ_thread() read %ld bytes from file %s\n",
filesize, Grd_READ_file);
return(NULL);
}
/*
*----------------------------------------------------------------
*
* Grd_WRITE_thread --
*
* Description:
*
* This thread writes an OSS file using Guardian Nowait I/O.
*
* This function performs Guardian nowait I/O in a thread aware
* manner, such that the entire program never blocks.
* Note however that this thread blocks when it waits for
* I/O completions.
* Other threads are free to do work while this thread is
* blocked waiting for an I/O completion.
*
* Since Guardian nowait I/O is not serialized, this program can
* have multiple outstanding Guardian I/O requests.
*
* Results:
* none.
*
*-----------------------------------------------------------------
*/
void *Grd_WRITE_thread(void *Grd_WRITE_file)
{
short fnum;
long count_written;
char *iobuf;
short err;
spt_error_t spte;
long error;
_cc_status cc;
long tag;
off_t currsize = 0;
int fd;
if ((iobuf = malloc(IOSIZE)) == NULL)
{
printf("*** ERROR in Grd_WRITE_thread: unable to allocate
I/O buffer ***\n");
exit(0);
}
memset(iobuf, 0, IOSIZE);
356 Using the Standard POSIX Threads Library