Selecting Among Multiple Streams
Streaming I/O and Device Drivers 7-23
7.6 Selecting Among Multiple Streams
The SIO_select function allows a single DSP/BIOS task to wait until an I/O
operation can be performed on one or more of a set of SIO streams without
blocking. For example, this mechanism is useful in the following applications: 
❏ Non-blocking I/O. Real-time tasks that stream data to a slow device (for
example, a disk file) must ensure that SIO_put does not block. 
❏ Multitasking. In virtually any multitasking application there are daemon
tasks that route data from several sources. The SIO_select mechanism
allows a single task to handle all of these sources. 
SIO_select is called with an array of streams, an array length, and a time-out
value. SIO_select blocks (if timeout is not 0) until one of the streams is ready
for I/O or the time-out expires. In either case, the mask returned by
SIO_select indicates which devices are ready for service (a 1 in bit j indicates
that streamtab[ j ] is ready) as shown in Example 7-13. 
Example 7-13. Indicating That a Stream is Ready
7.6.1 Programming Example
In Example 7-14, two streams are polled to see if an I/O operation will block.
Uns SIO_select(streamtab, nstreams, timeout)
    SIO_Handle     streamtab[];   /* stream table */
    Uns            nstreams;      /* number of streams */
    Uns            timeout;       /* return after this many */
                                  /* system clock ticks */