HPlogo STREAMS/UX for the HP 9000 Reference Manual > Chapter 3 Differences Between STREAMS/UX and System V Release 4 STREAMS

HP-UX Changes to STREAMS/UX System Calls

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NOTE: By default HP-UX terminal I/O is not implemented using STREAMS/UX in HP-UX 10.0. But a STREAMS-based pty is available in the STREAMS-TIO offering included in the HP-UX runtime product.

STREAMS/UX supports the following system calls:

  • close

  • fattach

  • fcntl

  • fdetach

  • getmsg

  • getpmsg

  • ioctl

  • isastream

  • open

  • pipe

  • poll

  • putmsg

  • putpmsg

  • read

  • readv

  • select

  • signal

  • write

  • writev

For STREAMS-based termio, see the following manpages (which are part of the STREAMS-TIO product): grantpt(3C), ptsname(3C), and unlockpt(3C).

There are HP-UX modifications to the fattach, ioctl, pipe, poll, putmsg, putpmsg, select, signal, write, and writev system calls. These modifications are as follows.

fattach Modifications

STREAMS/UX supports the fattach(3) and fdetach(3) library calls and the fdetach(1m) command as described in the UNIX SVR4.2 Operating System API Reference and the SVR4.2 Command Reference. In order to use fattach and fdetach, the kernel must have the ffs file system configured. ffs is added to the /stand/system file when STREAMS/UX is installed using swinstall. If ffs has been deleted after the install was done, re-include it as follows, regenerate a kernel, and reboot the system.

ffs

ioctl Modifications

STREAMS/UX supports ioctl as described in the SVR4.2 STREAMS manual.

Also, note that the multiplexor ID number returned by I_LINK and I_PLINK is a memory address, not a small integer such as 0, 1, 2, 3.

pipe Modifications

STREAMS/UX supports STREAMS-based pipes as an optional feature. STREAMS/UX's STREAMS-based pipes behave as described in the UNIX SVR4.2 Operating System API Reference and the UNIX System V Release 4 Programmer's Guide: STREAMS.

By default, pipes created by the pipe(2) system call are not STREAMS-based. In order to get STREAMS-based pipes, the /stand/system file must have the pipemod and pipedev module and driver configured, and the tunable parameter streampipes must be set to 1 (one).

When STREAMS/UX is installed, the /stand/system file is modified to include pipemod and pipedev, but streampipes is set to zero by default. The kernel must be regenerated and the system rebooted if the setting of streampipes to non-zero is to take effect. In other words, adb'ing the running system to turn streampipes on will have no effect on the type of pipes created by pipe(2). Once the kernel is regenerated and rebooted, all pipe(2) pipes on the system will be STREAMS-based. However, fifos will not be STREAMS-based. STREAMS/UX does not support STREAMS-based fifos.

The STREAMS/UX device pipedev is only for internal STREAMS/UX use in implementing STREAMS-based pipes. Opening a device file with pipedev's major number will not result in a STREAMS-based pipe, or even a properly functioning stream. STREAMS-based pipes must be created using the pipe(2) system call.

PIPE_BUF is a pathname variable value, and SVID, XPG4, POSIX, etc. define it as the maximum number of bytes that is guaranteed to be written atomically. To obtain the correct value of PIPE_BUF, use fpathconf() (see pathconf()). For STREAMS-based pipes, the value of PIPE_BUF depends on the configurable parameter STRMSGZ (by default, 8KB). For example, PIPE_BUF is set to 4KB if STRMSGSZ is 4KB, 8KB if STRMSGSZ is 8KB, and 16KB if STRMSGSZ is 16KB. There is one exception. If STRMSGSZ is set to 0 (i.e. infinite size), then PIPE_BUF for STREAMS/UX pipes is set to 8KB.

putmsg and putpmsg Modifications

Maximum and Minimum Data Buffer Size

The size of the user's data buffer must be within the minimum and maximum packet size range specified in the topmost STREAM module's streamtab. It must also be less than or equal to STRMSGSZ. If the number of bytes to transfer is not in this range, ERANGE will be returned.

Maximum and Minimum Control Buffer Size

The size of the user's control buffer must be less than or equal to both STRCTLSZ and STRMSGSZ. If STRCTLSZ is less than or equal to zero, the page size is used instead of STRCTLSZ for this check.

Data Buffer Segmentation

The user's data buffer may be sent in multiple data blocks chained together to form a message. The maximum number of bytes, including the write offset, that can be sent in one data block is equal to the page size.

Write Offset

A module or driver can send the stream head an M_SETOPTS message, telling the STREAM head to put an offset in the beginning of the first data block in a message sent by a putmsg call. STREAMS/UX will not put the offset into the data block if the amount of memory required is greater than the page size. See Chapter 5 of the SVR4.2 STREAMS manual for more information.

select Modifications

STREAMS/UX supports the select system call for STREAMS/UX devices. For information about the select system call, see the select(2) man page delivered with the HP-UX core system.

The select system call does not provide as much information as poll. If select returns an event for a STREAMS/UX device, the program can call poll to get more information.

A select read event is returned if a poll event POLLRDNORM, POLLERR, POLLNVAL or POLLHUP exists on the stream. In other words, a read event is returned for the following conditions:

  • a normal message is waiting to be read

  • a read error exists at the stream head

  • a write error exists at the stream head

  • the stream is linked under a multiplexor

  • a hang-up has occurred

A select write event is returned if a poll event POLLOUT, POLLWRNORM, POLLERR, POLLNVAL, or POLLHUP exists on the STREAM. This means that a write event is returned for the following conditions:

  • normal data can be written without blocking because of flow control

  • a read error exists at the stream head

  • a write error exists at the stream head

  • the stream is linked under a multiplexor

  • a hang-up has occurred

A select exception event is returned if a poll event POLLPRI or POLLRDBAND exists on the STREAM. More specifically, an exception event is returned if a high-priority message or a banded message is waiting to be read.

signal Modifications

STREAMS/UX supports signals and the HP-UX signal system call. However, STREAMS/UX does not support extended signals or the siginfo_t structure described in the siginfo(5) manpage.

write and writev Modifications

Maximum and Minimum Data Buffer Size

The size of the user's data buffer must be within the minimum and maximum packet size range specified in the topmost STREAM module's streamtab. If the number of bytes to transfer is not in this range, ERANGE will be returned. Two exceptions exist in which no error occurs. The first exception is if the data buffer is too large and either the maximum packet size is infinite or the minimum packet size is less than or equal to zero. (An infinite packet size is specified using the define INFPSZ in the stream.h file.) The second exception occurs if the buffer is too small and the minimum packet size is less than or equal to zero. With either exception, ERANGE is not returned, and the data is transferred.

Data Buffer Segmentation

The user's data buffer may be sent in multiple messages. The maximum amount of data that can be sent in one message is the lower value of the topmost module's maximum packet size and STRMSGSZ. If the maximum packet size is infinite, then the top module's high water mark is taken into consideration. If the high water mark is more than zero, half of the high water mark is used; otherwise the page size is used.

Write Offset

A module or driver can send the STREAM head an M_SETOPTS message telling it to put an offset in the beginning of each data buffer segment (i.e. message) sent by a write call. See Chapter 5 of the SVR4.2 STREAMS manual for more information. STREAMS/UX will not put the offset into a message if the resulting message size exceeds STRMSGZ.

© 1995 Hewlett-Packard Development Company, L.P.