STREAMS Introduction

STREAMS represent a collection of system calls, kernel resources, and kernel utility routines that can create, use, and dismantle a stream. A stream is a full-duplex processing and data transfer path between a driver in kernel space and a process in user space.

The STREAMS mechanism constructs a stream by serially connecting kernel-resident STREAMS components, each constructed from a specific set of structures. As shown in the Stream Detail figure (Figure 1), the primary STREAMS components are:
Item Description
stream head Provides the interface between the stream and user processes. Its principal function is to process STREAMS-related user system calls. STREAMS system calls can be used from 64-bit and 32-bit user processes.
module Processes data that travels between the stream head and driver. Modules are optional.
stream end Provides the services of an external input/output device or an internal software driver. The internal software driver is commonly called a pseudo-device driver.
Figure 1. Stream Detail
This diagram shows the user process at the top with a bidirectional arrow going into the kernel space to the stream head. On the downstream path (or left) an arrow travels from the stream head to queue Bd in module B, and then an arrow goes to queue Ad in module A (with message Ad as a parameter). An arrow then travels from queue Ad to queue pair in the stream end. The driver routine is connected to the queue pair in the driver. There is a bidirectional arrow from the driver routine to the external interface. On the upstream path (or right), an arrow travels from the queue pair to queue Au in module A, and then an arrow travels to queue Bu in module B (with message Bu as a parameter). An arrow then travels from queue Bu to the stream head.

STREAMS defines standard interfaces for character input and output within the system kernel and between the kernel and the rest of the system. The associated mechanism is simple and open-ended. It consists of a set of system calls, kernel resources, and kernel utility routines. The standard interface and open-ended mechanism enable modular, portable development and easy integration of high-performance network services and components. STREAMS does not impose any specific network architecture. Instead, it provides a powerful framework with a consistent user interface that is compatible with the existing character input/output interface.

Using a combination of system calls, kernel routines, and kernel utilities, STREAMS passes data between a driver and the stream head in the form of messages. Messages that are passed from the stream head toward the driver are said to travel downstream while messages passed in the other direction travel upstream.