B.9.2.1  Entering the Subsystem-Parallel Stack

The STREAMS environment guarantees that only one open, close, or service procedure from the subsystem-parallel stack is executing at any given time. It also ensures that the service procedure completes before another service procedure is run. However, this protection is insufficient.

In STREAMS, both the stream head and the dndis driver are fully parallel. At a given moment, many instances of the read put procedure of dndis and the write put procedure of the stream head can be executing. These instances must be prevented from entering the sybsystem concurrently.

The solution to this problem is to serialize the concurrent putnext (Section B.3.1) calls, which can be done in either of two ways:

1.Make the subsystem boundary put procedures queue every message with the function putq (Section B.3.1) and defer all processing to the service procedure for its queue.

2.Plumb an insulating module between the subsystem-parallel stack and all other drivers. This module declares itself as part of the subsystem-parallel stack. Its put procedure queues every message with putq, and its service procedure handles every message using the putnext function.

The key to these two methods is that the put procedure at the boundary of a stack must defer all processing to its service procedure. The service procedures of a stack are serialized by the STREAMS environment. An insulating module is required at both the lower read and upper write queues of a subsystem stack.