Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
OSS Porting Considerations
Open System Services Porting Guide520573-006
6-6
Using Message Queues
overhead is much higher than for other IPC mechanisms. The following tradeoffs exist
for the use of sockets:
If you must have source compatibility with portability and POSIX standard socket
semantics, use OSS sockets.
If you require improved performance with socket-like semantics but portability is
not a primary consideration, consider making minor code changes to your program
to use Guardian sockets. Refer to the TCP/IP Programming Manual for more
information about Guardian sockets programming.
If you require even higher performance and can abandon portability and sockets
semantics, consider recoding your program to use $RECEIVE. Refer to the
Guardian Programmer’s Guide for more information about programs that use
$RECEIVE.
If you require maximum performance with portability and can abandon sockets
semantics, use OSS pipes or FIFO files. OSS pipes and FIFOs typically provide a
direct data path without intervening system processes.
Using Message Queues
Messages are classified according to their queueing priority: normal (nonpriority),
priority, or high priority. A message belongs to a particular priority band that determines
its ordering when placed on a queue. Message queues are an optional feature of the
XPG4 specifications. HP implements message queues in the OSS environment with
the services of the msgctl(), msgget(), msgrcv(), and msgsnd() function calls:
msgctl() performs message control operations such as queries, removal of
identifiers, and modifying qualities of message identifiers.
msgget() creates or returns the identifier for a message queue.
msgrcv() reads a message from a queue associated with the msgqid parameter.
msgsnd() sends a message to the queue associated with the msgqid parameter.
There is no message-queue support between the Guardian and OSS environments
with the OSS message-queue function calls.
The services provided by message queues also can be provided using other OSS IPC
mechanisms that are generally available on all UNIX systems. The following IPC
mechanisms can be used if you need to modify your application program to provide the
equivalent feature: pipes, FIFOs, and OSS sockets.
If the code you are porting uses message queues, you can redesign your code to use
the Guardian message system. The Guardian message system is available through
the use of $RECEIVE and the WRITEREAD Guardian procedure call.
The semantics of all these alternatives to message queues are different, so this must
be considered when redesigning this portion of your code. The NonStop system
supports both user-level (recommended) and system-level routines.