Open System Services Programmer's Guide

FILE_CLOSE_(fnum); /* close server */
exit(0); /* and exit(0) */
}
bytesread = (short)strlen(msg_buff);/* includes newline */
CC = WRITEREADX(fnum, /* file number */
msg_buff, /* msg buffer */
bytesread, /* size of string to server */
BUFF_LEN, /* length of buffer */
&bytesread); /* number read back */
if (_status_ne(CC)) /* if error, exit(1) */
{
fprintf(stderr, "WRITEREADX() to %s failed\n", procname);
retcode = FILE_GETINFO_(fnum, &error);
if (retcode == 0)
fprintf(stderr, "File error = %d\n", error);
else
fprintf(stderr, "FILE_GETINFO() failed, retcode = %d\n",
retcode);
exit(1);
}
printf("Read %d bytes back from server\n",bytesread);
} /* end while(1) */
}
Performance Considerations
You can improve the performance of your applications with respect to interprocess communication
by following these recommendations.
For input and output in general:
There can be delays due to the blocking nature of many input/output calls. It can take an
indeterminate amount of time to complete a blocked call. Use the select() function or
nonblocking input/output when indeterminate waits are not desirable. Refer to Example 43
(page 179) for an example of the use of the select() call.
For pipes and FIFOs:
Whenever possible, keep processes that use pipes and FIFOs on the same processor. When
processes reside on the same processor, there is no message system traffic. When processes
reside on different processors, a message system I/O path is created, which slightly degrades
performance. However, keeping processes on different processors can provide better load
balancing and scalability for your applications.
Make the size of the data buffer exchanged through pipes and FIFOs equal to or less than
the size of the PIPE_BUF system variable. A buffer the size of PIPE_BUF or smaller can be
written in one I/O operation.
An application can force the OSS file system to attempt to resize the buffer used for a specific
pipe or FIFO file by calling the write() or writev() function for a write of more than
PIPE_BUF bytes. If resizing occurs, subsequent reads of up to 52 kilobytes can occur in a
single operation. Because all pipes and FIFOs in a processor have buffers allocated from a
fixed amount of memory, increasing the buffer size for one pipe or FIFO to improve its
throughput reduces the number of pipes and FIFOs that can exist simultaneously in that
processor.
For semaphores:
Include deadlock-avoidance techniques in your applications.
For sockets:
OSS AF_UNIX Release 2 sockets have improved performance over AF_UNIX Release 1
sockets because AF_UNIX Release 2 sockets have fewer system processes involved in the
Performance Considerations 195