public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "David Airlie" <David.Airlie@parthus.com>
To: "Grant Edwards" <grante@visi.com>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] semi-blocking serial read
Date: Thu, 16 Aug 2001 03:30:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.21.0108161125540.26472-100000@platinum.limerick.sslinc.com> (raw)
In-Reply-To: <20010815171000.A6737@visi.com>

I thought about doing this before.. and never got around to it .. god this
would save me a lot of extra crap I've added to my code .. loads of tslp
and stuff waiting for data...

I might go code up a patch for this in the next couple of weeks, when I
get the chance to sit down with my eCos devel system.. that is unless
someone beats me to it ...

Dave.


On Wed, 15 Aug 2001, Grant Edwards wrote:

> 
> My serial.c driver code has diverged somewhat from the standard
> serial.c.  Most of the things I've done have either evolved in
> parallel in the official one (like a non-blocking mode) or are
> things that other people don't want.
> 
> One unique thing that mine does have that is both general and
> (IMO) pretty useful is semi-blocking reads.
> 
> A semi-blocking read will block until _some_ amount of data is
> available and return after transferring whatever is available.
> 
> This is primarily useful for UARTs with FIFOs such that receive
> data comes in "chunks".  A semi-blocking read waits for the
> next "chunk".  This allows you to process incoming data with
> the lowest possible latency without doing a non-blocking read
> in a busy-wait loop.
> 
> The change is pretty trivial.  In serial_read() you do
> something like this:
> 
>      1	        while (size < *len) {
>      2	            if (cbuf->nb > 0) {
>      3	#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL
>      4	                if ( (cbuf->nb <= cbuf->low_water) && 
>      5	                     (chan->flow_desc.flags & CYG_SERIAL_FLOW_IN_THROTTLED) )
>      6	                    restart_rx( chan, false );
>      7	#endif
>      8	                *buf++ = cbuf->data[cbuf->get];
>      9	                if (++cbuf->get == cbuf->len) cbuf->get = 0;
>     10	                cbuf->nb--;
>     11	                size++;
>     12	            } else {
>     13	#ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
> --- 14                  if (!cbuf->blocking) {
> +++ 14	                if (cbuf->nonblocking || (cbuf->semiblocking && size))) {
>     15	                    *len = size;        // characters actually read
>     16	                    res = -EAGAIN;
>     17	                    break;
>     18	                }
>     19	#endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
> 
> 
> The cbuf struct needs to change a little to accomodate the two
> flags "nonblocking" and "semiblocking", but I think you see
> what I mean.
> 
> I don't use serial.c and probably won't get around to
> submitting a patch for some time, but I thought I'd toss the
> idea out in case anybody else could use something like it.
> 
> 

-- 
      David Airlie, Software Engineer, Parthus Technologies plc.,
       Mary Rosse Centre, National Tech Park, Limerick, Ireland.
   t: +353-61-508116 / f: +353-61-508101 / David.Airlie@parthus.com

  reply	other threads:[~2001-08-16  3:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-15 15:08 Grant Edwards
2001-08-16  3:30 ` David Airlie [this message]
2001-08-16  6:30   ` Jonathan Larmour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0108161125540.26472-100000@platinum.limerick.sslinc.com \
    --to=david.airlie@parthus.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=grante@visi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).