From owner-freebsd-hackers Sun Dec 3 08:10:39 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id IAA03474 for hackers-outgoing; Sun, 3 Dec 1995 08:10:39 -0800 Received: from spooky.rwwa.com (rwwa.com [198.115.177.3]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id IAA03467 for ; Sun, 3 Dec 1995 08:10:34 -0800 Received: from localhost (localhost [127.0.0.1]) by spooky.rwwa.com (8.6.11/8.6.9) with SMTP id LAA13131; Sun, 3 Dec 1995 11:15:32 -0500 Message-Id: <199512031615.LAA13131@spooky.rwwa.com> X-Authentication-Warning: spooky.rwwa.com: Host localhost didn't use HELO protocol X-Mailer: exmh version 1.5.3 12/28/94 To: Bruce Evans cc: freebsd-hackers@freebsd.org, witr@rwwa.com Subject: Re: Proper way to determine non-blocking status... In-reply-to: Your message of "Sun, 03 Dec 1995 14:58:40 +1100." <199512030358.OAA07217@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 03 Dec 1995 11:15:31 -0500 From: Robert Withrow Sender: owner-hackers@freebsd.org Precedence: bulk Do you mind if I pepper you with some more questions? 1) Is there any guidance on what priority pass to tsleep? 2) Would I be correct in assuming that IPL will be the same *after* tsleep returns as it was *before*. (I'm already pretty sure of that, reading the code. It makes sense anyway.) 3) Is there anyway short of using timeout() to hook into the clock interrupt (like xxpoll() in SYSV)? 4) I'm porting a streams driver to FreeBSD. It isn't a network style device, so I need to use the character dev model. The backend (and parts of the frontend) construct and enqueue messages to pass to the user when he eventually does a read. I need to alloc memory for each of these messages (which have random sizes, from dozens of bytes up to 1024 bytes). I'm curently using malloc(size,M_DEVBUF,waitflag). Is there better way to do this? 5) Are there any ipl restrictions on calling wakeup()? 6) Where does device ipl come from? I don't see it in the config file? How do I know what ipl my device interrupts at? 7) xxintr(int unit). Which unit? How computed? I'm used to xxintr(int vec). 8) I see that people often avoid having xxread/xxwrite routines for this situation. I did the opposite: I have xxread/xxwrite routines and require the stuff sent to be protocol packets. Is there any major drawback to this besides the possiblity of having some butthead do ``cat /etc/passwd /dev/mcc''? Also: > The ugl^H^H^Hrightly formatted way is: Actual routine is: int mccread(dev_t dev, struct uio *uio, int ioflag) { mcc_t *mcc = MCC_DEV(dev); /* Private data for this channel */ mcc_mblk_t *mp; int oldspl; /* Send first accumulated message, or wait if possible */ again: oldspl = SPLINT(); /* Lock */ mp = l_remove_head(&mcc->mcc_done); /* Get anything there */ if (mp) { /* Return it */ mc_primitives_union_t *mcp = MCC_MBLK_DATA(mp); if (mcp->header.mc_length > uio->uio_resid) { /* We refuse to copy less than a complete message, so we requeue this one! */ l_add_head(&mcc->mcc_done,mp); /* Return it to head of list */ splx(oldspl); /* Unlock */ return EINVAL; } else { splx(oldspl); /* Unlock */ uiomove(mcp, mcp->header.mc_length, uio); free(mp,M_DEVBUF); return 0; } } else if (ioflag & IO_NDELAY) { /* Can't block, sorry */ splx(oldspl); /* Unlock */ return EWOULDBLOCK; } else { /* Otherwise try again */ int error; mcc->mcc_blocked = 1; /* Mark ourselves blocked */ error = tsleep(&mcc->mcc_done, PZERO | PCATCH, "mccin", 0); mcc->mcc_blocked = 0; /* Mark ourselves unblocked */ splx(oldspl); /* Unlock */ if (error && (error != ERESTART)) return error; goto again; } } ----------------------------------------------------------------------------- Robert Withrow, Tel: +1 617 598 4480, Fax: +1 617 598 4430 Net: witr@rwwa.COM R.W. Withrow Associates, 319 Lynnway Suite 201, Lynn MA 01901 USA