Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Sep 2003 02:41:19 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Barry Bouwsma <freebsd-misuser@remove-NOSPAM-to-reply.NOSPAM.dyndns.dk>
Cc:        FreeBSD List of Hackers <hackers@freebsd.org>
Subject:   Re: Machine wedges solid after one serial-port source-lineaddition...
Message-ID:  <3F697DBF.9CE6E9C@mindspring.com>
References:  <200309152127.h8FLRrv71220@Mail.NOSPAM.DynDNS.dK> <200309180455.h8I4tBK58276@Mail.NOSPAM.DynDNS.dK>

next in thread | previous in thread | raw e-mail | index | archive | help
Barry Bouwsma wrote:
> You see, what I'm attempting to do, without knowing what I'm doing,
> is to implement the TIOCMIWAIT ioctl that apparently exists in Linux,
> to notify a userland program that there's been a status change on one
> or more of the modem status lines, and eliminate the need to poll the
> status line in question, cutting that program's cost to run by a factor
> of about 20 in the testing I did before the machine would wedge.
> 
> I did all this offline, with no examples to follow, but now I have
> something to look at and see if I have the general idea.  So I should
> probably shut up and study it.
> 
> So, since a printf() is right out, is it safe for me (as a non-
> programmer, so forgive my ignorance of the basics) to simply use
> little more than a wakeup() in its place?  Or does that, or the
> tsleep() corresponding, need some sort of careful handling to avoid
> the lockups I've experienced?

I remember wakeup() being bad.  Taking any time to do anything
at all more than just queueing data and going away is probably
bad.

If it were my project, I'd mirror the values out to a status
structure that's only written at interrupt, and read and reset
at software interrupt, and then use the soft interrupt handler
to raise the signals/send the wakeup/whatever and then resets
the flags bits to zero via a call down that synchronizes like
a baud rate or FIFO depth change (e.g. like the mouse line
discipline does to set the FIFO depth to avoid jerky mouse
movement).

Bruce Evans is the authority in this area; you would be well
advised to consult him directly.  He may even already have
code to do something similar to what you want (I think I
remember code to signal a program on an RI going high, but
I could be mistaken).

-- Terry



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F697DBF.9CE6E9C>