testb - check for an available buffer
#include <sys/stream.h> int testb(size_t size, uint_t pri);
Architecture independent level 1 (DDI/DKI).
Size of the requested buffer.
Priority of the allocb request..
Returns 1 if a buffer of the requested size is available, and 0 if one is not.
The testb() function can be called user, interrupt, or kernel context. queue_t *q; 3 { 4 mblk_t *mp; 5 mblk_t *nmp; . . . 6 if ((nmp = copymsg(mp)) == NULL) { 7 putbq(q, mp); 8 timeout(tryagain, (intptr_t)q, drv_usectohz(100000)); 9 return; 10 } . . . 11 } 12 13 tryagain(q) 14 queue_t *q; 15 { 16 register int can_alloc = 0; 17 register int num_blks = 0; 18 register mblk_t *mp; 19 20 if (!q->q_first) 21 return; 22 for (mp = q->q_first; mp; mp = mp->b_cont) { 23 num_blks++; 24 can_alloc += testb((mp->b_datap->db_lim - 25 mp->b_datap->db_base), BPRI_MED); 26 } 27 if (num_blks == can_alloc) 28 qenable(q); 29 else 30 timeout(tryagain, (intptr_t)q, drv_usectohz(100000)); 31 }
allocb(9F), bufcall(9F), copymsg(9F), timeout(9F)
Writing Device Drivers for Oracle Solaris 11.3
STREAMS Programming Guide
The pri argument is provided for compatibility only. Its value is ignored.