wdm@icc.com (William Mulert) (01/13/90)
I need some assistance with streams programming. None of the documentation I have tells me much about how to build and send a new message. 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? 2. Fill in the fields in the mblk_t and dblk_t structures? 3. Attend to any other important considerations? 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. 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? -- Bill Mulert Intercomputer Communications Corp. Cincinnati, Ohio 45236 (513)-745-0500 wdm@ICC.COM ...!ukma!spca6!icc!wdm
jgh@root.co.uk (Jeremy G Harris) (01/17/90)
In article <1990Jan12.221134.15243@icc.com> wdm@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@root.co.uk