Streams device driver programming questions

Jeremy G Harris jgh at root.co.uk
Wed Jan 17 19:53:31 AEST 1990


In article <1990Jan12.221134.15243 at icc.com> wdm at icc.com (William Mulert) writes:
[...]
> I am writing a driver, and the
>interrupt routine for the device has new data which it needs
>to put in an M_DATA message and send it upstream. Can anyone
>show me the proper way to:
>
>1. Allocate the message block?

if( (mp= allocb( sizeof(rxintr_data_t), BPRI_LO )) != NULL )
{

>2. Fill in the fields in the mblk_t and dblk_t structures?

mp->b_wptr += bytes_rxd;	/* everything else done by allocb() */

>3. Attend to any other important considerations?

/* copy data into mblk starting at b_rptr */

>I am assuming the isr can simply putq() the new message on the
>read side queue, and allow the drivers read side service routine
>to respond to the upstream flow control conditions, and pass
>the message upstream when canputnext() says it's ok.

So long as you don't exceed the configured limit on your read queue size.

>What should the driver programmer do if canput() says you
>can't use putq() to enqueue a message on the drivers own
>read queue? Is this a case where data may be lost due to
>flow control?

Yup.

References:  UNIX(tm) System V Release 3  STREAMS Programmer's Guide
	     AT&T  307-227  Issue 1

(The appendix is the most useful bit once you've read the thing once.
The intro-to-streams booklet [can't recall its real title, sorry]  may
be safely reserved for management types.)


Good luck,
	Jeremy
-- 
Jeremy Harris			jgh at root.co.uk



More information about the Comp.unix.questions mailing list