[comp.unix.questions] pipes under streams

odyssey@unix.SRI.COM (Odyssey Research Associates) (06/22/89)

How hard would it be to write a streams driver for named pipes?
How about regular pipes?  I want to sleep until data arrives from one
of several processes - is this possible under V.3.2 Unix?

B<
-- 
B<   Brian Kahn   unix.sri.com!orawest!brian   odyssey@unix.sri.com

les@chinet.chi.il.us (Leslie Mikesell) (06/22/89)

In article <256@unix.SRI.COM> unix.sri.com!orawest!brian writes:
>
>How hard would it be to write a streams driver for named pipes?
>How about regular pipes?  I want to sleep until data arrives from one
>of several processes - is this possible under V.3.2 Unix?

The way to do this using only normal FIFO's is to have all processes
write their data to a single FIFO.  If necessary, put the data in
packets with a tag to identify where it came from (the packet should
be <= PIPE_BUF in size and written in a single write()).  You may
need separate processes to collect from each source stream and generate
the packets.

I'm working on something similar but need to have high and low priority
inputs.  There will be a large volume of low priority input and I need
a way to prevent it from filling the FIFO and making the high priority
processes block.  Can someone suggest a way to do this without adding
a lot of overhead? Perhaps the low priority process could stat() the
FIFO before each write and wait awhile unless it is nearly empty.

Les Mikesell

lars@myab.se (Lars Pensj|) (06/26/89)

In article <256@unix.SRI.COM> unix.sri.com!orawest!brian writes:
>How hard would it be to write a streams driver for named pipes?
>How about regular pipes?  I want to sleep until data arrives from one
>of several processes - is this possible under V.3.2 Unix?

There is a stream pipe, "/dev/spx", which I think is standard under SYSV.
Open one pipe for every process you want to communicate with, and use
poll() to select. Note that "/dev/spx" is a clone device.

This should give you what you want.
-- 
    Lars Pensj|
    lars@myab.se