public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Geir Thomassen <geirt@powertech.no>
To: Jim Penny <jpenny@universal-fasteners.com>, linux-kernel@vger.kernel.org
Subject: Re: Serial port latency
Date: Thu, 22 Mar 2001 22:02:00 +0100	[thread overview]
Message-ID: <3ABA6848.B56CB12B@powertech.no> (raw)
In-Reply-To: <3ABA42A8.A806D0E7@powertech.no> <20010322141937.C22479@universal-fasteners.com>

Jim Penny wrote:
> 
> On Thu, Mar 22, 2001 at 07:21:28PM +0100, Geir Thomassen wrote:
> > My program controls a device (a programmer for microcontrollers) via the
> > serial port. The program sits in a tight loop, writing a few (typical 6)
> > bytes to the port, and waits for a few (typ. two) bytes to be returned from
> > the programmer.
> >
> > The program works, but it is very slow. I use an oscilloscope to monitor the
> > serial lines, and notices that there is a large delay between the returned
> > data, and the next new command. I really don't know if the delay is on the
> > sending or the receiving side (or both).
> >


> 
> 500ms seems a bit too long, but the quick answer is scheduler latency.
> You will certainly be scheduled out by the read, after all, it is not
> your program that is doing the read, but the kernel.  I think you are
> scheduled out after the write, as well.

I do believe the write will make the kernel write the first byte
into the UART transmit buffer directly. If this is the case, then the
data should appear on the serial lines almost immediately. There might be a
delay before the bottom half handler process the byte (or is the bottom half
only used on receive ?), but I do believe that this happens before the next
process is scheduled (BH handlers are all finished before any syscalls returns).
If this is the case, then scheduling out on write should not do any harm.

> 
> Your task is then sitting idle until the scheduler's next pass, if nothing
> else is happening, an interrupt is scheduled on the RTC, the CPU is set to
> idle power, and your system sleeps until the RTC wakes it back up, and
> the schedule queue is re-examined.
> 
> This normally implies a wait of at least a jiffy after every read.
>


Isn't a jiffy 10ms on i386 ? Scheduling delays should not be any
more than say 50 ms, but I am measuring 500ms. I could live with
50ms, which would make my program finish in 3 min. Now it is using
30 min !!

> 
> (But your time seems really excessive.)

Yep  :-(

> The usual cure is to write a custom driver which does a single
> read/write command.  If, as I recall, you are scheduled out on reads
> as well as writes, this lets you get rid of half the jiffies.

That could be the solution to my problem, but I won't start on that
before I understand what the problem is ...


Geir, geirt@powertech.no

  parent reply	other threads:[~2001-03-22 21:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-22 18:21 Serial port latency Geir Thomassen
2001-03-22 20:08 ` Theodore Tso
2001-03-22 20:32   ` Geir Thomassen
2001-03-22 20:55     ` Paul Fulghum
2001-03-22 22:44     ` Theodore Tso
     [not found] ` <20010322141937.C22479@universal-fasteners.com>
2001-03-22 21:02   ` Geir Thomassen [this message]
2001-03-22 21:52 ` Jonathan Lundell
2001-03-22 23:25 ` Pavel Machek
2001-03-23 14:43   ` Geir Thomassen
     [not found] <Pine.LNX.4.20.0103221219410.3343-100000@linuxtaj.korpivaara.org>
2001-03-22 20:03 ` Geir Thomassen
2001-03-22 20:17   ` Trent Jarvi
  -- strict thread matches above, loose matches on Subject: below --
2001-03-22 21:45 Manfred Spraul
     [not found] <000401c0b319517fea9@local>
2001-03-25 23:10 ` Pavel Machek
2001-03-29  7:58   ` Manfred Spraul
2001-03-30 22:36     ` Pavel Machek
2001-03-31 22:09       ` Manfred Spraul
2001-04-10  0:37   ` Andrea Arcangeli

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=3ABA6848.B56CB12B@powertech.no \
    --to=geirt@powertech.no \
    --cc=jpenny@universal-fasteners.com \
    --cc=linux-kernel@vger.kernel.org \
    /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