Streams device driver - open and close routines

Streams device driver - open and close routines

Post by avnindr » Thu, 21 Jan 1999 04:00:00



Hello,

       Can anybody tell me why we are specifying 'close' and 'open'
routines of a STREAMS device driver, are normally processed in read
queue instead of the write queue of the streams queue pair?
Thanks in advance,
Avnindra
--
Surf Usenet at home, on the road, and by email -- always at Talkway.
http://www.talkway.com

 
 
 

Streams device driver - open and close routines

Post by Doug Hocki » Fri, 22 Jan 1999 04:00:00


I don't know what the designers thinking was, but it seems reasonable
to have open and close be consistent, both be delivered on either
the read queue or the write queue.

If you need to get at the write queue just use "WR(q)".  On older
Unixes it was a macro producing inline code but on newer ones
with multithreaded streams drivers (e.g. UnixWare) it's a function.

Quote:>       Can anybody tell me why we are specifying 'close' and 'open'
> routines of a STREAMS device driver, are normally processed in read
> queue instead of the write queue of the streams queue pair?

-- Doug

 
 
 

Streams device driver - open and close routines

Post by Casper H.S. Dik - Network Security Engine » Fri, 22 Jan 1999 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>I don't know what the designers thinking was, but it seems reasonable
>to have open and close be consistent, both be delivered on either
>the read queue or the write queue.
>If you need to get at the write queue just use "WR(q)".  On older
>Unixes it was a macro producing inline code but on newer ones
>with multithreaded streams drivers (e.g. UnixWare) it's a function.

Also, when the close is performed, the write queue is flushed and the
STREAMs are closed from the driver to stream head (i.e., in the direction
of the read queue)

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

Streams device driver - open and close routines

Post by Doug Hocki » Sat, 23 Jan 1999 04:00:00


Quote:> Also, when the close is performed, the write queue is flushed and the
> STREAMs are closed from the driver to stream head (i.e., in the direction
> of the read queue)

Are you sure?  I've seen the stream dismantled and the closes
performed in the opposite order from when it was constructed --
from the stream head down (at least on UnixWare).

-- Doug

 
 
 

Streams device driver - open and close routines

Post by Casper H.S. Dik - Network Security Engine » Sun, 24 Jan 1999 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>> Also, when the close is performed, the write queue is flushed and the
>> STREAMs are closed from the driver to stream head (i.e., in the direction
>> of the read queue)
>Are you sure?  I've seen the stream dismantled and the closes
>performed in the opposite order from when it was constructed --
>from the stream head down (at least on UnixWare).

The Solaris manual for close(9e) (9e being the section that describes the
entry points of kernel drivers), says:

     The close() routines of  STREAMS  drivers  and  modules  are
     called  when a stream is dismantled or a module popped.  The
     steps for dismantling a stream are performed in the  follow-
     ing   order.   First,  any  multiplexor  links  present  are
     unlinked and the lower streams are closed.  Next,  the  fol-
     lowing  steps are performed for each module or driver on the
     stream, starting at the head and working toward the tail:

          1. The write queue is given a chance to drain.

          2. The close() routine is called.

          3. The module or driver is removed from the stream.

(On second reading, I might had the order reversed.)

Casper

--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

1. STREAMS queue returned to stream head during service routine execution

We are seeing something rather strange when running our STREAMS multiplexor
drivers on a Solaris 2.3 dual CPU SPARC 20. What is happening is that
occasionally, I believe after an I_UNLINK, the queue associated w/ a
running lower write service routine will revert back to the stream head
part way thru execution of the service routine.  Needless to say this has
devastating consequences.  What seems to be happening is that there is a
lack of synchronization wrt the running of the lower service routines and
the return of a "borrowed" queue pair. We have never seen this occur on
single CPU SPARC 10s or on a dual CPU SPARC 20 w/ one CPU disabled.

We do not use perimeters (should we?), but instead do mutex locking on a
driver basis. I.e., each driver has a single mutex which is acquired first
thing in each put and service routine. The mutex is released prior to
putnext() and family, and qreply(), and it is reacquired afterwards if
necessary. Just prior to return from the service or put routine, the mutex
is released. You can't get much coarser granularity than that.

Is this a Solaris bug? If so, is there a work-around? If not, what are we
doing incorrectly? Is there a lock of some sort that we should grab prior
to performing processing in the service routine?

Any help gratefully accepted.

--
Jim Robinson

{ubc-cs!van-bc,uunet}!mdivax1!robinson

2. Lost windows partition.

3. STREAMS driver per-adaptor read service routine

4. DNS on Solaris 2.6

5. Multiple opens of a single STREAMS device

6. Network Unreachable???

7. how to open udp device in stream environment

8. ADIC 1200 DAT changer and Linux - info needed

9. Calling device-driver strategy routines

10. In a Driver Read/Write Routine, accessing a memory-mapped device

11. HELP: kernel routines for device driver

12. Mutexes in device driver interrupt service routines

13. Signalling a process from a devices driver's interrupt routine.